Don't lint redundant_field_names across macro boundaries

This commit is contained in:
Alex Macleod 2024-03-07 12:19:33 +00:00
parent a79db2aa51
commit ac643a278b
4 changed files with 55 additions and 24 deletions

View file

@ -20,7 +20,7 @@ struct Person {
}
pub struct S {
v: String,
v: usize,
}
fn main() {
@ -59,11 +59,22 @@ fn main() {
let _ = RangeToInclusive { end };
external! {
let v = String::new();
let v = 1;
let _ = S {
v: v
};
}
let v = 2;
macro_rules! internal {
($i:ident) => {
let _ = S { v };
let _ = S { $i: v };
let _ = S { v: $i };
let _ = S { $i: $i };
};
}
internal!(v);
}
fn issue_3476() {

View file

@ -20,7 +20,7 @@ struct Person {
}
pub struct S {
v: String,
v: usize,
}
fn main() {
@ -59,11 +59,22 @@ fn main() {
let _ = RangeToInclusive { end: end };
external! {
let v = String::new();
let v = 1;
let _ = S {
v: v
};
}
let v = 2;
macro_rules! internal {
($i:ident) => {
let _ = S { v: v };
let _ = S { $i: v };
let _ = S { v: $i };
let _ = S { $i: $i };
};
}
internal!(v);
}
fn issue_3476() {

View file

@ -44,10 +44,21 @@ LL | let _ = RangeToInclusive { end: end };
| ^^^^^^^^ help: replace it with: `end`
error: redundant field names in struct initialization
--> tests/ui/redundant_field_names.rs:88:25
--> tests/ui/redundant_field_names.rs:71:25
|
LL | let _ = S { v: v };
| ^^^^ help: replace it with: `v`
...
LL | internal!(v);
| ------------ in this macro invocation
|
= note: this error originates in the macro `internal` (in Nightly builds, run with -Z macro-backtrace for more info)
error: redundant field names in struct initialization
--> tests/ui/redundant_field_names.rs:99:25
|
LL | let _ = RangeFrom { start: start };
| ^^^^^^^^^^^^ help: replace it with: `start`
error: aborting due to 8 previous errors
error: aborting due to 9 previous errors