2023-04-20 09:37:15 -05:00
|
|
|
//@run-rustfix
|
2023-04-20 10:19:36 -05:00
|
|
|
//@aux-build:proc_macros.rs:proc-macro
|
2023-03-07 08:40:55 -06:00
|
|
|
|
2021-02-20 07:52:56 -06:00
|
|
|
#![warn(clippy::inconsistent_struct_constructor)]
|
|
|
|
#![allow(clippy::redundant_field_names)]
|
|
|
|
#![allow(clippy::unnecessary_operation)]
|
|
|
|
#![allow(clippy::no_effect)]
|
|
|
|
#![allow(dead_code)]
|
|
|
|
|
2023-03-07 08:40:55 -06:00
|
|
|
extern crate proc_macros;
|
|
|
|
|
2021-02-20 07:52:56 -06:00
|
|
|
#[derive(Default)]
|
|
|
|
struct Foo {
|
|
|
|
x: i32,
|
|
|
|
y: i32,
|
|
|
|
z: i32,
|
|
|
|
}
|
|
|
|
|
|
|
|
mod without_base {
|
|
|
|
use super::Foo;
|
|
|
|
|
2023-03-07 08:40:55 -06:00
|
|
|
#[proc_macros::inline_macros]
|
2021-02-20 07:52:56 -06:00
|
|
|
fn test() {
|
|
|
|
let x = 1;
|
|
|
|
let y = 1;
|
|
|
|
let z = 1;
|
|
|
|
|
|
|
|
// Should lint.
|
|
|
|
Foo { y, x, z };
|
|
|
|
|
2021-04-19 23:33:39 -05:00
|
|
|
// Should NOT lint.
|
|
|
|
// issue #7069.
|
2023-03-07 08:40:55 -06:00
|
|
|
inline!({
|
|
|
|
let x = 1;
|
|
|
|
let y = 1;
|
|
|
|
let z = 1;
|
|
|
|
Foo { y, x, z }
|
|
|
|
});
|
2021-04-19 23:33:39 -05:00
|
|
|
|
2022-07-13 09:48:32 -05:00
|
|
|
// Should NOT lint because the order is the same as in the definition.
|
2021-02-20 07:52:56 -06:00
|
|
|
Foo { x, y, z };
|
|
|
|
|
|
|
|
// Should NOT lint because z is not a shorthand init.
|
|
|
|
Foo { y, x, z: z };
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
mod with_base {
|
|
|
|
use super::Foo;
|
|
|
|
|
|
|
|
fn test() {
|
|
|
|
let x = 1;
|
|
|
|
let z = 1;
|
|
|
|
|
|
|
|
// Should lint.
|
|
|
|
Foo {
|
|
|
|
z,
|
|
|
|
x,
|
|
|
|
..Default::default()
|
|
|
|
};
|
|
|
|
|
|
|
|
// Should NOT lint because the order is consistent with the definition.
|
|
|
|
Foo {
|
|
|
|
x,
|
|
|
|
z,
|
|
|
|
..Default::default()
|
|
|
|
};
|
|
|
|
|
|
|
|
// Should NOT lint because z is not a shorthand init.
|
|
|
|
Foo {
|
|
|
|
z: z,
|
|
|
|
x,
|
|
|
|
..Default::default()
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {}
|