Skip to content

redundant_field_names with ranges #2491

Closed
@ordovicia

Description

@ordovicia

Playground

Clippy suggests replacing variable start with start and end with end used in range syntax.
I guess that is because the syntax is syntactic sugar and structs resulting from desugaring have fields with these names.
IMHO we should make an exception to treat these range syntax.

warning: redundant field names in struct initialization
 --> src/main.rs:3:13
  |
3 |     let _ = start..;
  |             ^^^^^ help: replace it with: `start`
  |
  = note: #[warn(redundant_field_names)] on by default
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.187/index.html#redundant_field_names

warning: redundant field names in struct initialization
 --> src/main.rs:6:15
  |
6 |     let _ = ..end;
  |               ^^^ help: replace it with: `end`
  |
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.187/index.html#redundant_field_names

warning: redundant field names in struct initialization
 --> src/main.rs:8:13
  |
8 |     let _ = start..end;
  |             ^^^^^ help: replace it with: `start`
  |
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.187/index.html#redundant_field_names

warning: redundant field names in struct initialization
 --> src/main.rs:8:20
  |
8 |     let _ = start..end;
  |                    ^^^ help: replace it with: `end`
  |
  = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.187/index.html#redundant_field_names

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions