rust-lang / rust-clippy

A bunch of lints to catch common mistakes and improve your Rust code. Book: https://doc.rust-lang.org/clippy/
https://rust-lang.github.io/rust-clippy/
Other
11.39k stars 1.54k forks source link

redundant_field_names: spans messed up inside macro #6516

Open matthiaskrgr opened 3 years ago

matthiaskrgr commented 3 years ago

In Rustc we have this code

macro_rules! late_lint_mod_passes {
    ($macro:path, $args:tt) => {
        $macro!(
            $args,
            [
                HardwiredLints: HardwiredLints,
                ImproperCTypesDeclarations: ImproperCTypesDeclarations,
                ImproperCTypesDefinitions: ImproperCTypesDefinitions,
                VariantSizeDifferences: VariantSizeDifferences,
                BoxPointers: BoxPointers,
                PathStatements: PathStatements,
                // Depends on referenced function signatures in expressions
                UnusedResults: UnusedResults,
                NonUpperCaseGlobals: NonUpperCaseGlobals,
                NonShorthandFieldPatterns: NonShorthandFieldPatterns,
                UnusedAllocation: UnusedAllocation,
                // Depends on types used in type definitions
                MissingCopyImplementations: MissingCopyImplementations,
                // Depends on referenced function signatures in expressions
                MutableTransmutes: MutableTransmutes,
                TypeAliasBounds: TypeAliasBounds,
                TrivialConstraints: TrivialConstraints,
                TypeLimits: TypeLimits::new(),
                NonSnakeCase: NonSnakeCase,
                InvalidNoMangleItems: InvalidNoMangleItems,
                // Depends on access levels
                UnreachablePub: UnreachablePub,
                ExplicitOutlivesRequirements: ExplicitOutlivesRequirements,
                InvalidValue: InvalidValue,
            ]
        );
    };
}

which triggers clippy::redundant_field_names, but a the spans seems kinda messed up

..,
warning: redundant field names in struct initialization
   --> compiler/rustc_lint/src/lib.rs:198:37
    |
131 | |                 RedundantSemicolons: RedundantSemicolons,
    | |_____________________________^ help: replace it with: `TrivialConstraints`
...
198 |                   TrivialConstraints: TrivialConstraints,
    |  _____________________________________^
...
220 |   late_lint_mod_passes!(declare_combined_late_pass, [BuiltinCombinedModuleLateLintPass]);
    |   --------------------------------------------------------------------------------------- in this macro invocation
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: redundant field names in struct initialization
   --> compiler/rustc_lint/src/lib.rs:200:31
    |
131 | |                 RedundantSemicolons: RedundantSemicolons,
    | |_____________________________^ help: replace it with: `NonSnakeCase`
...
200 |                   NonSnakeCase: NonSnakeCase,
    |  _______________________________^
...
220 |   late_lint_mod_passes!(declare_combined_late_pass, [BuiltinCombinedModuleLateLintPass]);
    |   --------------------------------------------------------------------------------------- in this macro invocation
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: redundant field names in struct initialization
   --> compiler/rustc_lint/src/lib.rs:201:39
    |
131 | |                 RedundantSemicolons: RedundantSemicolons,
    | |_____________________________^ help: replace it with: `InvalidNoMangleItems`
...
201 |                   InvalidNoMangleItems: InvalidNoMangleItems,
    |  _______________________________________^
...
220 |   late_lint_mod_passes!(declare_combined_late_pass, [BuiltinCombinedModuleLateLintPass]);
    |   --------------------------------------------------------------------------------------- in this macro invocation
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: redundant field names in struct initialization
   --> compiler/rustc_lint/src/lib.rs:203:33
    |
131 | |                 RedundantSemicolons: RedundantSemicolons,
    | |_____________________________^ help: replace it with: `UnreachablePub`
...
203 |                   UnreachablePub: UnreachablePub,
    |  _________________________________^
...
220 |   late_lint_mod_passes!(declare_combined_late_pass, [BuiltinCombinedModuleLateLintPass]);
    |   --------------------------------------------------------------------------------------- in this macro invocation
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: redundant field names in struct initialization
   --> compiler/rustc_lint/src/lib.rs:204:47
    |
131 | |                 RedundantSemicolons: RedundantSemicolons,
    | |_____________________________^ help: replace it with: `ExplicitOutlivesRequirements`
...
204 |                   ExplicitOutlivesRequirements: ExplicitOutlivesRequirements,
    |  _______________________________________________^
...
220 |   late_lint_mod_passes!(declare_combined_late_pass, [BuiltinCombinedModuleLateLintPass]);
    |   --------------------------------------------------------------------------------------- in this macro invocation
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

warning: redundant field names in struct initialization
   --> compiler/rustc_lint/src/lib.rs:205:31
    |
131 | |                 RedundantSemicolons: RedundantSemicolons,
    | |_____________________________^ help: replace it with: `InvalidValue`
...
205 |                   InvalidValue: InvalidValue,
    |  _______________________________^
...
220 |   late_lint_mod_passes!(declare_combined_late_pass, [BuiltinCombinedModuleLateLintPass]);
    |   --------------------------------------------------------------------------------------- in this macro invocation
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_field_names
    = note: this warning originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

spans

matthiaskrgr commented 3 years ago

spans