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

More path suggestions for when a struct field doesn't exist #2472

Closed
Nokel81 opened this issue Jun 12, 2018 · 1 comment
Closed

More path suggestions for when a struct field doesn't exist #2472

Nokel81 opened this issue Jun 12, 2018 · 1 comment
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.

Comments

@Nokel81
Copy link
Contributor

Nokel81 commented Jun 12, 2018

See this playground:

Currently, if someone tries to reference a field that doesn't exist in the current struct an error is produced and recommendations are provided, this is wonderful.

However, I think that it could be made even better by adding some addition suggestions. What would these be?

Referring back to my first example I would say that having 'state.tokens' in addition to the other names would be beneficial. To do this, if this error comes up then the the tree which is the name paths of the fields of each of the structs is traversed in order to find these additional suggestions.

Caveats:

  1. Structs that are not 'pub' should not be traversed through. I say this so that such things which cannot be recommended if they cannot be actually accessed.
  2. There should be a default depth, say 5, which is configurable either on the command line or when using cargo
@Nokel81 Nokel81 changed the title More path options for struct fields don't exist More path suggestions for when a struct field doesn't exist Jun 12, 2018
@Centril Centril added the T-lang Relevant to the language team, which will review and decide on the RFC. label Jun 12, 2018
@Centril
Copy link
Contributor

Centril commented Jun 12, 2018

I highly recommend taking this to the internals forum instead if you want more eyes on it :)

@Centril Centril closed this as completed Jun 13, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-lang Relevant to the language team, which will review and decide on the RFC.
Projects
None yet
Development

No branches or pull requests

2 participants