Skip to content

unused-qualifications causes syntax error #121999

Closed
@matthiaskrgr

Description

@matthiaskrgr

Code

fn main() {
    println!("{}", <bool as ::std::default::Default>::default());
}

Current output

warning: unnecessary qualification
 --> ./src/tools/rustfmt/tests/target/associated-items.rs:2:29
  |
2 |     println!("{}", <bool as ::std::default::Default>::default());
  |                             ^^^^^^^^^^^^^^^^^^^^^^^
  |
  = note: requested on the command line with `--force-warn unused-qualifications`
help: remove the unnecessary path segments
  |
2 -     println!("{}", <bool as ::std::default::Default>::default());
2 +     println!("{}", <bool as Default>::default());
  |

warning: unnecessary qualification
 --> ./src/tools/rustfmt/tests/target/associated-items.rs:2:20
  |
2 |     println!("{}", <bool as ::std::default::Default>::default());
  |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  |
help: remove the unnecessary path segments
  |
2 -     println!("{}", <bool as ::std::default::Default>::default());
2 +     println!("{}", Default>::default());
  |

warning: 2 warnings emitted

Desired output

The second suggestion has a syntax error since we only remove `<` but leave `>` in.

Rationale and extra context

No response

Other cases

No response

Rust Version

rustc 1.78.0-nightly (7606c1396 2024-03-04)
binary: rustc
commit-hash: 7606c13961ddc1174b70638e934df0439b7dc515
commit-date: 2024-03-04
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 18.1.0

Anything else?

rustc ./src/tools/rustfmt/tests/target/associated-items.rs --force-warn unused-qualifications

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions