Skip to content

Commit 827a0d6

Browse files
committed
Auto merge of rust-lang#137231 - Urgau:rollup-heiq934, r=Urgau
Rollup of 9 pull requests Successful merges: - rust-lang#136750 (Make ub_check message clear that it's not an assert) - 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#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 + 3ebe11b commit 827a0d6

File tree

20 files changed

+134
-35
lines changed

20 files changed

+134
-35
lines changed

compiler/rustc_codegen_cranelift/src/abi/comments.rs

Lines changed: 3 additions & 4 deletions
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
}

compiler/rustc_codegen_cranelift/src/constant.rs

Lines changed: 1 addition & 1 deletion
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

compiler/rustc_data_structures/src/intern.rs

Lines changed: 4 additions & 1 deletion
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.

compiler/rustc_driver_impl/src/signal_handler.rs

Lines changed: 39 additions & 11 deletions
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

compiler/rustc_middle/src/thir.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,6 @@ pub enum ExprKind<'tcx> {
376376
/// A `match` expression.
377377
Match {
378378
scrutinee: ExprId,
379-
scrutinee_hir_id: HirId,
380379
arms: Box<[ArmId]>,
381380
match_source: MatchSource,
382381
},

compiler/rustc_mir_build/src/thir/cx/expr.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,6 @@ impl<'tcx> ThirBuildCx<'tcx> {
828828
},
829829
hir::ExprKind::Match(discr, arms, match_source) => ExprKind::Match {
830830
scrutinee: self.mirror_expr(discr),
831-
scrutinee_hir_id: discr.hir_id,
832831
arms: arms.iter().map(|a| self.convert_arm(a)).collect(),
833832
match_source,
834833
},

compiler/rustc_mir_build/src/thir/pattern/check_match.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ impl<'p, 'tcx> Visitor<'p, 'tcx> for MatchVisitor<'p, 'tcx> {
151151
}
152152
return;
153153
}
154-
ExprKind::Match { scrutinee, scrutinee_hir_id: _, box ref arms, match_source } => {
154+
ExprKind::Match { scrutinee, box ref arms, match_source } => {
155155
self.check_match(scrutinee, arms, match_source, ex.span);
156156
}
157157
ExprKind::Let { box ref pat, expr } => {

compiler/rustc_next_trait_solver/src/solve/alias_relate.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,17 @@ where
3434
) -> QueryResult<I> {
3535
let cx = self.cx();
3636
let Goal { param_env, predicate: (lhs, rhs, direction) } = goal;
37-
debug_assert!(lhs.to_alias_term().is_some() || rhs.to_alias_term().is_some());
37+
38+
// Check that the alias-relate goal is reasonable. Writeback for
39+
// `coroutine_stalled_predicates` can replace alias terms with
40+
// `{type error}` if the alias still contains infer vars, so we also
41+
// accept alias-relate goals where one of the terms is an error.
42+
debug_assert!(
43+
lhs.to_alias_term().is_some()
44+
|| rhs.to_alias_term().is_some()
45+
|| lhs.is_error()
46+
|| rhs.is_error()
47+
);
3848

3949
// Structurally normalize the lhs.
4050
let lhs = if let Some(alias) = lhs.to_alias_term() {

compiler/rustc_resolve/src/imports.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,19 @@ pub(crate) struct ImportData<'ra> {
182182
/// so we can use referential equality to compare them.
183183
pub(crate) type Import<'ra> = Interned<'ra, ImportData<'ra>>;
184184

185+
// Allows us to use Interned without actually enforcing (via Hash/PartialEq/...) uniqueness of the
186+
// contained data.
187+
// FIXME: We may wish to actually have at least debug-level assertions that Interned's guarantees
188+
// are upheld.
189+
impl std::hash::Hash for ImportData<'_> {
190+
fn hash<H>(&self, _: &mut H)
191+
where
192+
H: std::hash::Hasher,
193+
{
194+
unreachable!()
195+
}
196+
}
197+
185198
impl<'ra> ImportData<'ra> {
186199
pub(crate) fn is_glob(&self) -> bool {
187200
matches!(self.kind, ImportKind::Glob { .. })

compiler/rustc_resolve/src/lib.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,19 @@ struct ModuleData<'ra> {
589589
#[rustc_pass_by_value]
590590
struct Module<'ra>(Interned<'ra, ModuleData<'ra>>);
591591

592+
// Allows us to use Interned without actually enforcing (via Hash/PartialEq/...) uniqueness of the
593+
// contained data.
594+
// FIXME: We may wish to actually have at least debug-level assertions that Interned's guarantees
595+
// are upheld.
596+
impl std::hash::Hash for ModuleData<'_> {
597+
fn hash<H>(&self, _: &mut H)
598+
where
599+
H: std::hash::Hasher,
600+
{
601+
unreachable!()
602+
}
603+
}
604+
592605
impl<'ra> ModuleData<'ra> {
593606
fn new(
594607
parent: Option<Module<'ra>>,
@@ -739,6 +752,19 @@ struct NameBindingData<'ra> {
739752
/// so we can use referential equality to compare them.
740753
type NameBinding<'ra> = Interned<'ra, NameBindingData<'ra>>;
741754

755+
// Allows us to use Interned without actually enforcing (via Hash/PartialEq/...) uniqueness of the
756+
// contained data.
757+
// FIXME: We may wish to actually have at least debug-level assertions that Interned's guarantees
758+
// are upheld.
759+
impl std::hash::Hash for NameBindingData<'_> {
760+
fn hash<H>(&self, _: &mut H)
761+
where
762+
H: std::hash::Hasher,
763+
{
764+
unreachable!()
765+
}
766+
}
767+
742768
trait ToNameBinding<'ra> {
743769
fn to_name_binding(self, arenas: &'ra ResolverArenas<'ra>) -> NameBinding<'ra>;
744770
}

0 commit comments

Comments
 (0)