File tree 5 files changed +49
-2
lines changed
5 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -144,8 +144,14 @@ impl RustcSpan {
144
144
/// Returns the most expanded line number *in the given file*, if possible.
145
145
fn line ( & self , file : & Path , primary : bool ) -> Option < spanned:: Span > {
146
146
if let Some ( exp) = & self . expansion {
147
- if let Some ( line) = exp. span . line ( file, primary && ! self . is_primary ) {
147
+ if let Some ( line) = exp. span . line ( file, ! primary || self . is_primary ) {
148
148
return Some ( line) ;
149
+ } else if self . file_name != file {
150
+ return if !primary && self . is_primary {
151
+ exp. span . line ( file, false )
152
+ } else {
153
+ None
154
+ } ;
149
155
}
150
156
}
151
157
( ( !primary || self . is_primary ) && self . file_name == file) . then_some ( spanned:: Span {
Original file line number Diff line number Diff line change @@ -20,14 +20,15 @@ tests/actual_tests/foomp.rs ... ok
20
20
tests/actual_tests/joined_above.rs ... ok
21
21
tests/actual_tests/joined_below.rs ... ok
22
22
tests/actual_tests/joined_mixed.rs ... ok
23
+ tests/actual_tests/mac_span.rs ... ok
23
24
tests/actual_tests/match_diagnostic_code.rs ... ok
24
25
tests/actual_tests/no_rustfix.rs ... ok
25
26
tests/actual_tests/stdin.rs ... ok
26
27
tests/actual_tests/unicode.rs ... ok
27
28
tests/actual_tests/windows_paths.rs ... ok
28
29
tests/actual_tests/subdir/aux_proc_macro.rs ... ok
29
30
30
- test result: ok. 15 passed;
31
+ test result: ok. 16 passed;
31
32
32
33
33
34
running 0 tests
Original file line number Diff line number Diff line change
1
+ #![deny(unused_variables)]
2
+
3
+ macro_rules! m {
4
+ () => {{
5
+ let _x = 0; //~ unused_variables
6
+ }};
7
+ }
8
+
9
+ fn main() {
10
+ m!();
11
+ }
Original file line number Diff line number Diff line change
1
+ #![ deny( unused_variables) ]
2
+
3
+ macro_rules! m {
4
+ ( ) => { {
5
+ let x = 0 ; //~ unused_variables
6
+ } } ;
7
+ }
8
+
9
+ fn main ( ) {
10
+ m ! ( ) ;
11
+ }
Original file line number Diff line number Diff line change
1
+ error: unused variable: `x`
2
+ --> tests/actual_tests/mac_span.rs:5:13
3
+ |
4
+ 5 | let x = 0;
5
+ | ^ help: if this is intentional, prefix it with an underscore: `_x`
6
+ ...
7
+ 10 | m!();
8
+ | ---- in this macro invocation
9
+ |
10
+ note: the lint level is defined here
11
+ --> tests/actual_tests/mac_span.rs:1:9
12
+ |
13
+ 1 | #![deny(unused_variables)]
14
+ | ^^^^^^^^^^^^^^^^
15
+ = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info)
16
+
17
+ error: aborting due to 1 previous error
18
+
You can’t perform that action at this time.
0 commit comments