Auto merge of #7097 - yawara:fix/7069, r=llogiq

Fixed inconsistent_struct_constructor triggers in macro-generated code

fixes #7069

changelog: `inconsistent_struct_constructor`: Fix FP in macro expansion.
This commit is contained in:
bors 2021-04-20 08:26:21 +00:00
commit ec38ea1ac1
4 changed files with 30 additions and 2 deletions

View file

@ -13,6 +13,15 @@ struct Foo {
z: i32,
}
macro_rules! new_foo {
() => {
let x = 1;
let y = 1;
let z = 1;
Foo { y, x, z }
};
}
mod without_base {
use super::Foo;
@ -24,6 +33,10 @@ mod without_base {
// Should lint.
Foo { x, y, z };
// Should NOT lint.
// issue #7069.
new_foo!();
// Shoule NOT lint because the order is the same as in the definition.
Foo { x, y, z };

View file

@ -13,6 +13,15 @@ struct Foo {
z: i32,
}
macro_rules! new_foo {
() => {
let x = 1;
let y = 1;
let z = 1;
Foo { y, x, z }
};
}
mod without_base {
use super::Foo;
@ -24,6 +33,10 @@ mod without_base {
// Should lint.
Foo { y, x, z };
// Should NOT lint.
// issue #7069.
new_foo!();
// Shoule NOT lint because the order is the same as in the definition.
Foo { x, y, z };

View file

@ -1,5 +1,5 @@
error: struct constructor field order is inconsistent with struct definition field order
--> $DIR/inconsistent_struct_constructor.rs:25:9
--> $DIR/inconsistent_struct_constructor.rs:34:9
|
LL | Foo { y, x, z };
| ^^^^^^^^^^^^^^^ help: try: `Foo { x, y, z }`
@ -7,7 +7,7 @@ LL | Foo { y, x, z };
= note: `-D clippy::inconsistent-struct-constructor` implied by `-D warnings`
error: struct constructor field order is inconsistent with struct definition field order
--> $DIR/inconsistent_struct_constructor.rs:43:9
--> $DIR/inconsistent_struct_constructor.rs:56:9
|
LL | / Foo {
LL | | z,