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

When field isn't found, see if any of the available fields has it #81220

Closed
estebank opened this issue Jan 20, 2021 · 6 comments · Fixed by #81480
Closed

When field isn't found, see if any of the available fields has it #81220

estebank opened this issue Jan 20, 2021 · 6 comments · Fixed by #81480
Labels
A-diagnostics Area: Messages for errors, warnings, and lints A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` 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

@estebank
Copy link
Contributor

estebank commented Jan 20, 2021

I just encountered this output:

error[E0609]: no field `span` on type `Label`
   --> compiler/rustc_passes/src/loops.rs:127:43
    |
127 | ...                   label.span,
    |                             ^^^^ unknown field
    |
    = note: available fields are: `ident`

We currently mention available fields when the field used isn't found. It would be nice if we peeked at the types for the available fields to see if any of them has any fields (including through deref) of the name we originally wanted. In this case, I would love to see the following output:

error[E0609]: no field `span` on type `Label`
   --> compiler/rustc_passes/src/loops.rs:127:43
    |
127 | ...                   label.span,
    |                             ^^^^ unknown field
    |
help: the field `span` is available on field `ident` of type `Ident`:
    |
127 | ...                   label.ident.span,
    |                             ^^^^^^
    |
@estebank estebank 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. A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` D-papercut Diagnostics: An error or lint that needs small tweaks. labels Jan 20, 2021
@hkmatsumoto
Copy link
Member

I'll work on this.
@rustbot claim

@b-naber
Copy link
Contributor

b-naber commented Jan 28, 2021

@matsujika I was just about to open a PR when I saw that you claimed the issue. It's my fault for not claiming this issue myself obviously, so if you've already been investing time into this the issue its still yours, but if you haven't can I open a PR for this?

@hkmatsumoto
Copy link
Member

hkmatsumoto commented Jan 28, 2021

@b-naber I've done nothing yet as I planned to work on this tomorrow morning, so this is yours :)

@hkmatsumoto
Copy link
Member

@rustbot release-assignment

@estebank
Copy link
Contributor Author

@matsujika if you're still interested in contributing, it seems to me that #81222 might be similar in scope and section of the codebase you could work in.

@b-naber
Copy link
Contributor

b-naber commented Jan 28, 2021

@matsujika Thank you.

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 A-suggestion-diagnostics Area: Suggestions generated by the compiler applied by `cargo fix` 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.

3 participants