Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matthiaskrgr opened this issue Jan 14, 2023 · 0 comments · Fixed by #106928
Closed

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

matthiaskrgr opened this issue Jan 14, 2023 · 0 comments · Fixed by #106928
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthiaskrgr
Copy link
Member

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
   |     ~~~~~~~~~~~~~~~~~~~~~~~~~
@matthiaskrgr matthiaskrgr added A-diagnostics Area: Messages for errors, warnings, and lints T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-papercut Diagnostics: An error or lint that needs small tweaks. D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. labels Jan 14, 2023
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jan 20, 2023
…er, r=petrochenkov

add raw identifier for keyword in suggestion

fix rust-lang#106841
@bors bors closed this as completed in da7a0c0 Jan 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints D-invalid-suggestion Diagnostics: A structured suggestion resulting in incorrect code. D-papercut Diagnostics: An error or lint that needs small tweaks. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant