-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Incorrect help message for type declared on struct using raw identifier #69053
Comments
I wonder whether cases like this need to be "fixed" at all. I'm not sure whether #68963 alone has the right cost/benefit ratio for merging, let alone changing this everywhere. |
Suggestion №1: Forget about raw identifier after the original tokens are lost (~lexing/parsing/expansion) and never report them. Suggestion №2: Use an approximate identifier printing routine that may print edition-specific keywords inaccurately, but at least doesn't require keeping precise spans. |
@petrochenkov I didn't get the problem - why we can't format all identifiers according to the edition used by current project? It's the only thing which matters, we don't need to know from and how we got this identifier. Even if we import something from, let's say old |
We can, that would be a very good approximation for the suggestion №2, since we are mostly reporting error for identifiers coming directly from the current crate. That would be |
The PR looked trivial enough by using The reason I feel these in particular are important is because normally we suggest using raw idents when the parser can identify them, but in these cases of |
@petrochenkov what is the best place to define this function if we assume to use it not only for resolve diagnostics but also for any kind of help messages and notes, which include identifiers? |
Hmm, |
…acrum rustc_span: Add `Symbol::to_ident_string` for use in diagnostic messages Covers the same error reporting use case (rust-lang#69387 (comment)) as the `Display` impl for `Ident`. cc rust-lang#69053 Follow-up to rust-lang#69387. r? @Mark-Simulacrum
…acrum rustc_span: Add `Symbol::to_ident_string` for use in diagnostic messages Covers the same error reporting use case (rust-lang#69387 (comment)) as the `Display` impl for `Ident`. cc rust-lang#69053 Follow-up to rust-lang#69387. r? @Mark-Simulacrum
@petrochenkov I was going to have a go at fixing this since #68963 became inactive, but I think you were right before when you said
and one can expect the user to understand that they need the raw identifiers when copying the compiler's suggestions (they just tried to build with one). In any case, if the user copies the example from the diagnostic that omits the |
This code
(Playground)
Produces incorrect help message:
The text was updated successfully, but these errors were encountered: