Skip to content

Commit 0004b3b

Browse files
committed
Auto merge of rust-lang#111960 - compiler-errors:rollup-onka2dl, r=compiler-errors
Rollup of 7 pull requests Successful merges: - rust-lang#107522 (Add Median of Medians fallback to introselect) - rust-lang#111152 (update `pulldown-cmark` to `0.9.3`) - rust-lang#111757 (Consider lint check attributes on match arms) - rust-lang#111831 (Always capture slice when pattern requires checking the length) - rust-lang#111929 (Don't print newlines in APITs) - rust-lang#111945 (Migrate GUI colors test to original CSS color format) - rust-lang#111950 (Remove ExpnKind::Inlined.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents a2b1646 + c2e3521 commit 0004b3b

File tree

37 files changed

+856
-411
lines changed

37 files changed

+856
-411
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2779,9 +2779,9 @@ dependencies = [
27792779

27802780
[[package]]
27812781
name = "pulldown-cmark"
2782-
version = "0.9.2"
2782+
version = "0.9.3"
27832783
source = "registry+https://github.com/rust-lang/crates.io-index"
2784-
checksum = "2d9cc634bc78768157b5cbfe988ffcd1dcba95cd2b2f03a88316c08c6d00ed63"
2784+
checksum = "77a1a2f1f0a7ecff9c31abbe177637be0e97a0aef46cf8738ece09327985d998"
27852785
dependencies = [
27862786
"bitflags",
27872787
"memchr",

compiler/rustc_ast_lowering/src/lib.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,7 +1425,16 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
14251425
DefPathData::ImplTrait,
14261426
span,
14271427
);
1428-
let ident = Ident::from_str_and_span(&pprust::ty_to_string(t), span);
1428+
1429+
// HACK: pprust breaks strings with newlines when the type
1430+
// gets too long. We don't want these to show up in compiler
1431+
// output or built artifacts, so replace them here...
1432+
// Perhaps we should instead format APITs more robustly.
1433+
let ident = Ident::from_str_and_span(
1434+
&pprust::ty_to_string(t).replace('\n', " "),
1435+
span,
1436+
);
1437+
14291438
let (param, bounds, path) = self.lower_universal_param_and_bounds(
14301439
*def_node_id,
14311440
span,

compiler/rustc_codegen_cranelift/src/common.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
413413

414414
// Note: must be kept in sync with get_caller_location from cg_ssa
415415
pub(crate) fn get_caller_location(&mut self, mut source_info: mir::SourceInfo) -> CValue<'tcx> {
416-
let span_to_caller_location = |fx: &mut FunctionCx<'_, '_, 'tcx>, mut span: Span| {
417-
// Remove `Inlined` marks as they pollute `expansion_cause`.
418-
while span.is_inlined() {
419-
span.remove_mark();
420-
}
416+
let span_to_caller_location = |fx: &mut FunctionCx<'_, '_, 'tcx>, span: Span| {
421417
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
422418
let caller = fx.tcx.sess.source_map().lookup_char_pos(topmost.lo());
423419
let const_loc = fx.tcx.const_caller_location((

compiler/rustc_codegen_ssa/src/mir/block.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1450,11 +1450,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
14501450
) -> OperandRef<'tcx, Bx::Value> {
14511451
let tcx = bx.tcx();
14521452

1453-
let mut span_to_caller_location = |mut span: Span| {
1454-
// Remove `Inlined` marks as they pollute `expansion_cause`.
1455-
while span.is_inlined() {
1456-
span.remove_mark();
1457-
}
1453+
let mut span_to_caller_location = |span: Span| {
14581454
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
14591455
let caller = tcx.sess.source_map().lookup_char_pos(topmost.lo());
14601456
let const_loc = tcx.const_caller_location((

compiler/rustc_const_eval/src/interpret/eval_context.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,20 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
949949
// This deliberately does *not* honor `requires_caller_location` since it is used for much
950950
// more than just panics.
951951
for frame in stack.iter().rev() {
952-
let span = frame.current_span();
952+
let span = match frame.loc {
953+
Left(loc) => {
954+
// If the stacktrace passes through MIR-inlined source scopes, add them.
955+
let mir::SourceInfo { mut span, scope } = *frame.body.source_info(loc);
956+
let mut scope_data = &frame.body.source_scopes[scope];
957+
while let Some((instance, call_span)) = scope_data.inlined {
958+
frames.push(FrameInfo { span, instance });
959+
span = call_span;
960+
scope_data = &frame.body.source_scopes[scope_data.parent_scope.unwrap()];
961+
}
962+
span
963+
}
964+
Right(span) => span,
965+
};
953966
frames.push(FrameInfo { span, instance: frame.instance });
954967
}
955968
trace!("generate stacktrace: {:#?}", frames);

compiler/rustc_const_eval/src/interpret/intrinsics/caller_location.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
111111
location
112112
}
113113

114-
pub(crate) fn location_triple_for_span(&self, mut span: Span) -> (Symbol, u32, u32) {
115-
// Remove `Inlined` marks as they pollute `expansion_cause`.
116-
while span.is_inlined() {
117-
span.remove_mark();
118-
}
114+
pub(crate) fn location_triple_for_span(&self, span: Span) -> (Symbol, u32, u32) {
119115
let topmost = span.ctxt().outer_expn().expansion_cause().unwrap_or(span);
120116
let caller = self.tcx.sess.source_map().lookup_char_pos(topmost.lo());
121117
(

compiler/rustc_errors/src/emitter.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ pub trait Emitter: Translate {
332332

333333
// Skip past non-macro entries, just in case there
334334
// are some which do actually involve macros.
335-
ExpnKind::Inlined | ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None,
335+
ExpnKind::Desugaring(..) | ExpnKind::AstPass(..) => None,
336336

337337
ExpnKind::Macro(macro_kind, name) => Some((macro_kind, name)),
338338
}
@@ -403,7 +403,7 @@ pub trait Emitter: Translate {
403403
continue;
404404
}
405405

406-
if always_backtrace && !matches!(trace.kind, ExpnKind::Inlined) {
406+
if always_backtrace {
407407
new_labels.push((
408408
trace.def_site,
409409
format!(
@@ -442,7 +442,6 @@ pub trait Emitter: Translate {
442442
"this derive macro expansion".into()
443443
}
444444
ExpnKind::Macro(MacroKind::Bang, _) => "this macro invocation".into(),
445-
ExpnKind::Inlined => "this inlined function call".into(),
446445
ExpnKind::Root => "the crate root".into(),
447446
ExpnKind::AstPass(kind) => kind.descr().into(),
448447
ExpnKind::Desugaring(kind) => {

compiler/rustc_hir_typeck/src/expr_use_visitor.rs

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -438,12 +438,19 @@ impl<'a, 'tcx> ExprUseVisitor<'a, 'tcx> {
438438
// to borrow discr.
439439
needs_to_be_read = true;
440440
}
441-
PatKind::Or(_)
442-
| PatKind::Box(_)
443-
| PatKind::Slice(..)
444-
| PatKind::Ref(..)
445-
| PatKind::Wild => {
446-
// If the PatKind is Or, Box, Slice or Ref, the decision is made later
441+
PatKind::Slice(lhs, wild, rhs) => {
442+
// We don't need to test the length if the pattern is `[..]`
443+
if matches!((lhs, wild, rhs), (&[], Some(_), &[]))
444+
// Arrays have a statically known size, so
445+
// there is no need to read their length
446+
|| discr_place.place.base_ty.is_array()
447+
{
448+
} else {
449+
needs_to_be_read = true;
450+
}
451+
}
452+
PatKind::Or(_) | PatKind::Box(_) | PatKind::Ref(..) | PatKind::Wild => {
453+
// If the PatKind is Or, Box, or Ref, the decision is made later
447454
// as these patterns contains subpatterns
448455
// If the PatKind is Wild, the decision is made based on the other patterns being
449456
// examined

compiler/rustc_lint/src/late.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,10 @@ impl<'tcx, T: LateLintPass<'tcx>> hir_visit::Visitor<'tcx> for LateContextAndPas
240240
}
241241

242242
fn visit_arm(&mut self, a: &'tcx hir::Arm<'tcx>) {
243-
lint_callback!(self, check_arm, a);
244-
hir_visit::walk_arm(self, a);
243+
self.with_lint_attrs(a.hir_id, |cx| {
244+
lint_callback!(cx, check_arm, a);
245+
hir_visit::walk_arm(cx, a);
246+
})
245247
}
246248

247249
fn visit_generic_param(&mut self, p: &'tcx hir::GenericParam<'tcx>) {

compiler/rustc_middle/src/lint.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -468,8 +468,7 @@ pub fn struct_lint_level(
468468
pub fn in_external_macro(sess: &Session, span: Span) -> bool {
469469
let expn_data = span.ctxt().outer_expn_data();
470470
match expn_data.kind {
471-
ExpnKind::Inlined
472-
| ExpnKind::Root
471+
ExpnKind::Root
473472
| ExpnKind::Desugaring(
474473
DesugaringKind::ForLoop | DesugaringKind::WhileLoop | DesugaringKind::OpaqueTy,
475474
) => false,

0 commit comments

Comments
 (0)