Skip to content

Commit 855f1ba

Browse files
authored
Unrolled build for #148717
Rollup merge of #148717 - estebank:macro-spans-2, r=petrochenkov Point at span within local macros even when error happens in nested external macro Address issue noticed at https://users.rust-lang.org/t/error-message-does-not-specify-where-in-macro/135157/1. On errors occurring within a macro expansion, point at the innermost local macro expansion point. ``` error[E0308]: mismatched types --> $DIR/macro-span-caller-replacement.rs:5:17 | LL | s = format!("{arg}"); | ^^^^^^^^^^^^^^^^ expected `&str`, found `String` ... LL | macro_with_format!(); | -------------------- in this macro invocation | = note: this error originates in the macro `format` which comes from the expansion of the macro `macro_with_format` (in Nightly builds, run with -Z macro-backtrace for more info) ```
2 parents 5b150d2 + 1bd7934 commit 855f1ba

File tree

52 files changed

+599
-147
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+599
-147
lines changed

compiler/rustc_errors/src/emitter.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -474,9 +474,12 @@ pub trait Emitter {
474474
.chain(span.span_labels().iter().map(|sp_label| sp_label.span))
475475
.filter_map(|sp| {
476476
if !sp.is_dummy() && source_map.is_imported(sp) {
477-
let maybe_callsite = sp.source_callsite();
478-
if sp != maybe_callsite {
479-
return Some((sp, maybe_callsite));
477+
let mut span = sp;
478+
while let Some(callsite) = span.parent_callsite() {
479+
span = callsite;
480+
if !source_map.is_imported(span) {
481+
return Some((sp, span));
482+
}
480483
}
481484
}
482485
None

src/tools/miri/tests/fail/panic/tls_macro_drop_panic.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//@error-in-other-file: aborted execution
22
// Backtraces vary wildly between platforms, we have to normalize away almost the entire thing
33
//@normalize-stderr-test: "'main'|'<unnamed>'" -> "$$NAME"
4-
//@normalize-stderr-test: ".*(note|-->|\|).*\n" -> ""
4+
//@normalize-stderr-test: ".*(note|-->|:::|\|).*\n" -> ""
55

66
pub struct NoisyDrop {}
77

tests/ui-fulldeps/rustc-dev-remap.only-remap.stderr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ help: the following other types implement trait `VisitorResult`
1818
= note: `ControlFlow<T>`
1919
note: required by a bound in `rustc_ast::visit::Visitor::Result`
2020
--> /rustc-dev/xyz/compiler/rustc_ast/src/visit.rs:LL:COL
21+
::: /rustc-dev/xyz/compiler/rustc_ast/src/visit.rs:LL:COL
22+
|
23+
= note: in this macro invocation
2124
= note: this error originates in the macro `common_visitor_and_walkers` (in Nightly builds, run with -Z macro-backtrace for more info)
2225

2326
error: aborting due to 1 previous error

tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,11 @@ LL | impl<T> VisitorResult for ControlFlow<T> {
2020
note: required by a bound in `rustc_ast::visit::Visitor::Result`
2121
--> $COMPILER_DIR_REAL/rustc_ast/src/visit.rs:LL:COL
2222
|
23+
LL | type Result: VisitorResult = ();
24+
| ^^^^^^^^^^^^^ required by this bound in `Visitor::Result`
25+
...
2326
LL | common_visitor_and_walkers!(Visitor<'a>);
24-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Visitor::Result`
27+
| ---------------------------------------- in this macro invocation
2528
= note: this error originates in the macro `common_visitor_and_walkers` (in Nightly builds, run with -Z macro-backtrace for more info)
2629

2730
error: aborting due to 1 previous error

tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ LL | struct NotIntoDiagArg;
1515
= help: normalized in stderr
1616
note: required by a bound in `Diag::<'a, G>::arg`
1717
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
18+
::: $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
19+
|
20+
= note: in this macro invocation
1821
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
1922

2023
error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied
@@ -34,6 +37,9 @@ LL | struct NotIntoDiagArg;
3437
= help: normalized in stderr
3538
note: required by a bound in `Diag::<'a, G>::arg`
3639
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
40+
::: $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
41+
|
42+
= note: in this macro invocation
3743
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
3844

3945
error: aborting due to 2 previous errors

tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,9 @@ LL | struct Hello {}
665665
= help: normalized in stderr
666666
note: required by a bound in `Diag::<'a, G>::arg`
667667
--> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
668+
::: $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC
669+
|
670+
= note: in this macro invocation
668671
= note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info)
669672

670673
error: aborting due to 85 previous errors

tests/ui/binop/binary-op-suggest-deref.stderr

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -305,13 +305,19 @@ LL | let _ = FOO & (*"Sized".to_string().into_boxed_str());
305305
help: the following other types implement trait `BitAnd<Rhs>`
306306
--> $SRC_DIR/core/src/ops/bit.rs:LL:COL
307307
|
308-
= note: `&i32` implements `BitAnd<i32>`
308+
= note: `i32` implements `BitAnd`
309+
::: $SRC_DIR/core/src/ops/bit.rs:LL:COL
309310
|
310-
= note: `&i32` implements `BitAnd`
311+
= note: in this macro invocation
312+
--> $SRC_DIR/core/src/internal_macros.rs:LL:COL
313+
|
314+
= note: `&i32` implements `BitAnd<i32>`
315+
::: $SRC_DIR/core/src/internal_macros.rs:LL:COL
311316
|
312317
= note: `i32` implements `BitAnd<&i32>`
318+
::: $SRC_DIR/core/src/internal_macros.rs:LL:COL
313319
|
314-
= note: `i32` implements `BitAnd`
320+
= note: `&i32` implements `BitAnd`
315321
= note: this error originates in the macro `bitand_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
316322

317323
error[E0277]: the size for values of type `str` cannot be known at compilation time

tests/ui/binop/binop-mul-i32-f32.stderr

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,19 @@ LL | x * y
88
help: the following other types implement trait `Mul<Rhs>`
99
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
1010
|
11-
= note: `&i32` implements `Mul<i32>`
11+
= note: `i32` implements `Mul`
12+
::: $SRC_DIR/core/src/ops/arith.rs:LL:COL
1213
|
13-
= note: `&i32` implements `Mul`
14+
= note: in this macro invocation
15+
--> $SRC_DIR/core/src/internal_macros.rs:LL:COL
16+
|
17+
= note: `&i32` implements `Mul<i32>`
18+
::: $SRC_DIR/core/src/internal_macros.rs:LL:COL
1419
|
1520
= note: `i32` implements `Mul<&i32>`
21+
::: $SRC_DIR/core/src/internal_macros.rs:LL:COL
1622
|
17-
= note: `i32` implements `Mul`
23+
= note: `&i32` implements `Mul`
1824
= note: this error originates in the macro `mul_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
1925

2026
error: aborting due to 1 previous error

tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ LL | check(&mut () as *mut ());
8484
|
8585
help: the trait `ConstParamTy_` is implemented for `()`
8686
--> $SRC_DIR/core/src/marker.rs:LL:COL
87+
::: $SRC_DIR/core/src/marker.rs:LL:COL
88+
|
89+
= note: in this macro invocation
8790
note: required by a bound in `check`
8891
--> $DIR/const_param_ty_bad.rs:4:18
8992
|
@@ -101,6 +104,9 @@ LL | check(&() as *const ());
101104
|
102105
help: the trait `ConstParamTy_` is implemented for `()`
103106
--> $SRC_DIR/core/src/marker.rs:LL:COL
107+
::: $SRC_DIR/core/src/marker.rs:LL:COL
108+
|
109+
= note: in this macro invocation
104110
note: required by a bound in `check`
105111
--> $DIR/const_param_ty_bad.rs:4:18
106112
|

tests/ui/consts/const-eval/const-eval-overflow-3b.stderr

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,19 @@ LL | = [0; (i8::MAX + 1u8) as usize];
1414
help: the following other types implement trait `Add<Rhs>`
1515
--> $SRC_DIR/core/src/ops/arith.rs:LL:COL
1616
|
17-
= note: `&i8` implements `Add<i8>`
17+
= note: `i8` implements `Add`
18+
::: $SRC_DIR/core/src/ops/arith.rs:LL:COL
1819
|
19-
= note: `&i8` implements `Add`
20+
= note: in this macro invocation
21+
--> $SRC_DIR/core/src/internal_macros.rs:LL:COL
22+
|
23+
= note: `&i8` implements `Add<i8>`
24+
::: $SRC_DIR/core/src/internal_macros.rs:LL:COL
2025
|
2126
= note: `i8` implements `Add<&i8>`
27+
::: $SRC_DIR/core/src/internal_macros.rs:LL:COL
2228
|
23-
= note: `i8` implements `Add`
29+
= note: `&i8` implements `Add`
2430
= note: this error originates in the macro `add_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
2531

2632
error: aborting due to 2 previous errors

0 commit comments

Comments
 (0)