Skip to content

Commit 4e243bb

Browse files
committed
Auto merge of rust-lang#137226 - Urgau:rollup-8htn7j0, r=Urgau
Rollup of 9 pull requests Successful merges: - rust-lang#137151 (Install more signal stack trace handlers) - rust-lang#137167 (tests: Also gate `f16::erfc()` doctest with `reliable_f16_math` cfg) - rust-lang#137195 (cg_clif: use exclusively ABI alignment) - rust-lang#137202 (Enforce T: Hash for Interned<...>) - rust-lang#137205 (Remove `std::os::wasi::fs::FileExt::tell`) - rust-lang#137211 (don't ICE for alias-relate goals with error term) - rust-lang#137213 (Remove `rustc_middle::mir::tcx` module.) - rust-lang#137214 (add last std diagnostic items for clippy) - rust-lang#137221 (Remove scrutinee_hir_id from ExprKind::Match) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3b022d8 + 2f81c1e commit 4e243bb

File tree

30 files changed

+530
-461
lines changed

30 files changed

+530
-461
lines changed

Diff for: compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,11 @@ use rustc_hir::intravisit::{Visitor, walk_block, walk_expr};
1818
use rustc_hir::{CoroutineDesugaring, CoroutineKind, CoroutineSource, LangItem, PatField};
1919
use rustc_middle::bug;
2020
use rustc_middle::hir::nested_filter::OnlyBodies;
21-
use rustc_middle::mir::tcx::PlaceTy;
2221
use rustc_middle::mir::{
2322
self, AggregateKind, BindingForm, BorrowKind, ClearCrossCrate, ConstraintCategory,
2423
FakeBorrowKind, FakeReadCause, LocalDecl, LocalInfo, LocalKind, Location, MutBorrowKind,
25-
Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement, StatementKind, Terminator,
26-
TerminatorKind, VarBindingForm, VarDebugInfoContents,
24+
Operand, Place, PlaceRef, PlaceTy, ProjectionElem, Rvalue, Statement, StatementKind,
25+
Terminator, TerminatorKind, VarBindingForm, VarDebugInfoContents,
2726
};
2827
use rustc_middle::ty::print::PrintTraitRefExt as _;
2928
use rustc_middle::ty::{

Diff for: compiler/rustc_borrowck/src/diagnostics/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,9 @@ use rustc_infer::infer::{
1313
};
1414
use rustc_infer::traits::SelectionError;
1515
use rustc_middle::bug;
16-
use rustc_middle::mir::tcx::PlaceTy;
1716
use rustc_middle::mir::{
1817
AggregateKind, CallSource, ConstOperand, ConstraintCategory, FakeReadCause, Local, LocalInfo,
19-
LocalKind, Location, Operand, Place, PlaceRef, ProjectionElem, Rvalue, Statement,
18+
LocalKind, Location, Operand, Place, PlaceRef, PlaceTy, ProjectionElem, Rvalue, Statement,
2019
StatementKind, Terminator, TerminatorKind, find_self_call,
2120
};
2221
use rustc_middle::ty::print::Print;

Diff for: compiler/rustc_borrowck/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ use rustc_index::{IndexSlice, IndexVec};
3333
use rustc_infer::infer::{
3434
InferCtxt, NllRegionVariableOrigin, RegionVariableOrigin, TyCtxtInferExt,
3535
};
36-
use rustc_middle::mir::tcx::PlaceTy;
3736
use rustc_middle::mir::*;
3837
use rustc_middle::query::Providers;
3938
use rustc_middle::ty::fold::fold_regions;

Diff for: compiler/rustc_borrowck/src/type_check/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ use rustc_infer::infer::{
1919
BoundRegion, BoundRegionConversionTime, InferCtxt, NllRegionVariableOrigin,
2020
};
2121
use rustc_infer::traits::PredicateObligations;
22-
use rustc_middle::mir::tcx::PlaceTy;
2322
use rustc_middle::mir::visit::{NonMutatingUseContext, PlaceContext, Visitor};
2423
use rustc_middle::mir::*;
2524
use rustc_middle::traits::query::NoSolution;

Diff for: compiler/rustc_codegen_cranelift/src/abi/comments.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub(super) fn add_locals_header_comment(fx: &mut FunctionCx<'_, '_, '_>) {
6565
if fx.clif_comments.enabled() {
6666
fx.add_global_comment(String::new());
6767
fx.add_global_comment(
68-
"kind local ty size align (abi,pref)".to_string(),
68+
"kind local ty size align (abi)".to_string(),
6969
);
7070
}
7171
}
@@ -84,14 +84,13 @@ pub(super) fn add_local_place_comments<'tcx>(
8484
let (kind, extra) = place.debug_comment();
8585

8686
fx.add_global_comment(format!(
87-
"{:<5} {:5} {:30} {:4}b {}, {}{}{}",
87+
"{:<5} {:5} {:30} {:4}b {}{}{}",
8888
kind,
8989
format!("{:?}", local),
9090
format!("{:?}", ty),
9191
size.bytes(),
9292
align.abi.bytes(),
93-
align.pref.bytes(),
94-
if extra.is_empty() { "" } else { " " },
93+
if extra.is_empty() { "" } else { " " },
9594
extra,
9695
));
9796
}

Diff for: compiler/rustc_codegen_cranelift/src/constant.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ fn data_id_for_static(
272272
.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(ty))
273273
.unwrap()
274274
.align
275-
.pref
275+
.abi
276276
.bytes();
277277

278278
let linkage = if import_linkage == rustc_middle::mir::mono::Linkage::ExternalWeak

Diff for: compiler/rustc_codegen_ssa/src/mir/place.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use rustc_abi::Primitive::{Int, Pointer};
22
use rustc_abi::{Align, BackendRepr, FieldsShape, Size, TagEncoding, VariantIdx, Variants};
3+
use rustc_middle::mir::PlaceTy;
34
use rustc_middle::mir::interpret::Scalar;
4-
use rustc_middle::mir::tcx::PlaceTy;
55
use rustc_middle::ty::layout::{HasTyCtxt, LayoutOf, TyAndLayout};
66
use rustc_middle::ty::{self, Ty};
77
use rustc_middle::{bug, mir};

Diff for: compiler/rustc_data_structures/src/intern.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,10 @@ impl<'a, T: Ord> Ord for Interned<'a, T> {
9292
}
9393
}
9494

95-
impl<'a, T> Hash for Interned<'a, T> {
95+
impl<'a, T> Hash for Interned<'a, T>
96+
where
97+
T: Hash,
98+
{
9699
#[inline]
97100
fn hash<H: Hasher>(&self, s: &mut H) {
98101
// Pointer hashing is sufficient, due to the uniqueness constraint.

Diff for: compiler/rustc_driver_impl/src/signal_handler.rs

+39-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ use std::{fmt, mem, ptr, slice};
66

77
use rustc_interface::util::{DEFAULT_STACK_SIZE, STACK_SIZE};
88

9+
/// Signals that represent that we have a bug, and our prompt termination has
10+
/// been ordered.
11+
#[rustfmt::skip]
12+
const KILL_SIGNALS: [(libc::c_int, &str); 3] = [
13+
(libc::SIGILL, "SIGILL"),
14+
(libc::SIGBUS, "SIGBUS"),
15+
(libc::SIGSEGV, "SIGSEGV")
16+
];
17+
918
unsafe extern "C" {
1019
fn backtrace_symbols_fd(buffer: *const *mut libc::c_void, size: libc::c_int, fd: libc::c_int);
1120
}
@@ -39,8 +48,19 @@ macro raw_errln($tokens:tt) {
3948
/// # Safety
4049
///
4150
/// Caller must ensure that this function is not re-entered.
42-
unsafe extern "C" fn print_stack_trace(_: libc::c_int) {
51+
unsafe extern "C" fn print_stack_trace(signum: libc::c_int) {
4352
const MAX_FRAMES: usize = 256;
53+
54+
let signame = {
55+
let mut signame = "<unknown>";
56+
for sig in KILL_SIGNALS {
57+
if sig.0 == signum {
58+
signame = sig.1;
59+
}
60+
}
61+
signame
62+
};
63+
4464
let stack = unsafe {
4565
// Reserve data segment so we don't have to malloc in a signal handler, which might fail
4666
// in incredibly undesirable and unexpected ways due to e.g. the allocator deadlocking
@@ -54,7 +74,8 @@ unsafe extern "C" fn print_stack_trace(_: libc::c_int) {
5474
};
5575

5676
// Just a stack trace is cryptic. Explain what we're doing.
57-
raw_errln!("error: rustc interrupted by SIGSEGV, printing backtrace\n");
77+
raw_errln!("error: rustc interrupted by {signame}, printing backtrace\n");
78+
5879
let mut written = 1;
5980
let mut consumed = 0;
6081
// Begin elaborating return addrs into symbols and writing them directly to stderr
@@ -94,7 +115,7 @@ unsafe extern "C" fn print_stack_trace(_: libc::c_int) {
94115
written += rem.len() + 1;
95116

96117
let random_depth = || 8 * 16; // chosen by random diceroll (2d20)
97-
if cyclic || stack.len() > random_depth() {
118+
if (cyclic || stack.len() > random_depth()) && signum == libc::SIGSEGV {
98119
// technically speculation, but assert it with confidence anyway.
99120
// rustc only arrived in this signal handler because bad things happened
100121
// and this message is for explaining it's not the programmer's fault
@@ -106,17 +127,22 @@ unsafe extern "C" fn print_stack_trace(_: libc::c_int) {
106127
written += 1;
107128
}
108129
raw_errln!("note: we would appreciate a report at https://github.com/rust-lang/rust");
109-
// get the current stack size WITHOUT blocking and double it
110-
let new_size = STACK_SIZE.get().copied().unwrap_or(DEFAULT_STACK_SIZE) * 2;
111-
raw_errln!("help: you can increase rustc's stack size by setting RUST_MIN_STACK={new_size}");
112-
written += 2;
130+
written += 1;
131+
if signum == libc::SIGSEGV {
132+
// get the current stack size WITHOUT blocking and double it
133+
let new_size = STACK_SIZE.get().copied().unwrap_or(DEFAULT_STACK_SIZE) * 2;
134+
raw_errln!(
135+
"help: you can increase rustc's stack size by setting RUST_MIN_STACK={new_size}"
136+
);
137+
written += 1;
138+
}
113139
if written > 24 {
114-
// We probably just scrolled the earlier "we got SIGSEGV" message off the terminal
115-
raw_errln!("note: backtrace dumped due to SIGSEGV! resuming signal");
140+
// We probably just scrolled the earlier "interrupted by {signame}" message off the terminal
141+
raw_errln!("note: backtrace dumped due to {signame}! resuming signal");
116142
};
117143
}
118144

119-
/// When SIGSEGV is delivered to the process, print a stack trace and then exit.
145+
/// When one of the KILL signals is delivered to the process, print a stack trace and then exit.
120146
pub(super) fn install() {
121147
unsafe {
122148
let alt_stack_size: usize = min_sigstack_size() + 64 * 1024;
@@ -129,7 +155,9 @@ pub(super) fn install() {
129155
sa.sa_sigaction = print_stack_trace as libc::sighandler_t;
130156
sa.sa_flags = libc::SA_NODEFER | libc::SA_RESETHAND | libc::SA_ONSTACK;
131157
libc::sigemptyset(&mut sa.sa_mask);
132-
libc::sigaction(libc::SIGSEGV, &sa, ptr::null_mut());
158+
for (signum, _signame) in KILL_SIGNALS {
159+
libc::sigaction(signum, &sa, ptr::null_mut());
160+
}
133161
}
134162
}
135163

Diff for: compiler/rustc_middle/src/mir/mod.rs

-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ pub mod pretty;
5353
mod query;
5454
mod statement;
5555
mod syntax;
56-
pub mod tcx;
5756
mod terminator;
5857

5958
pub mod traversal;

0 commit comments

Comments
 (0)