Skip to content

diagnostics: rust forgets needed raw identifier in item paths in suggestion #106841

Closed
@matthiaskrgr

Description

@matthiaskrgr

Given the following code:
tests/ui/issues/issue-65634-raw-ident-suggestion.rs

#![allow(non_camel_case_types)]

trait r#async {
    fn r#struct(&self) {
        println!("async");
    }
}

trait r#await {
    fn r#struct(&self) {
        println!("await");
    }
}

struct r#fn {}

impl r#async for r#fn {}
impl r#await for r#fn {}

fn main() {
    r#fn {}.r#struct(); //~ ERROR multiple applicable items in scope
}

The current output is:

error[E0034]: multiple applicable items in scope
  --> src/main.rs:21:13
   |
21 |     r#fn {}.r#struct(); //~ ERROR multiple applicable items in scope
   |             ^^^^^^^^ multiple `r#struct` found
   |
note: candidate #1 is defined in an impl of the trait `async` for the type `fn`
  --> src/main.rs:4:5
   |
4  |     fn r#struct(&self) {
   |     ^^^^^^^^^^^^^^^^^^
note: candidate #2 is defined in an impl of the trait `await` for the type `fn`
  --> src/main.rs:10:5
   |
10 |     fn r#struct(&self) {
   |     ^^^^^^^^^^^^^^^^^^
help: disambiguate the associated function for candidate #1
   |
21 |     async::r#struct(&r#fn {}); //~ ERROR multiple applicable items in scope
   |     ~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
21 |     await::r#struct(&r#fn {}); //~ ERROR multiple applicable items in scope
   |     ~~~~~~~~~~~~~~~~~~~~~~~~~

For more information about this error, try `rustc --explain E0034`.

This will not compile because we need to suggest r#await instead of await

Ideally the output should look like:

   |
21 |     r#async::r#struct(&r#fn {}); //~ ERROR multiple applicable items in scope
   |     ~~~~~~~~~~~~~~~~~~~~~~~~~
help: disambiguate the associated function for candidate #2
   |
21 |     r#await::r#struct(&r#fn {}); //~ ERROR multiple applicable items in scope
   |     ~~~~~~~~~~~~~~~~~~~~~~~~~

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsD-invalid-suggestionDiagnostics: A structured suggestion resulting in incorrect code.D-papercutDiagnostics: An error or lint that needs small tweaks.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