Skip to content

Convert notes to helps in the compiler #18126

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

Closed
brson opened this issue Oct 17, 2014 · 2 comments · Fixed by #18132
Closed

Convert notes to helps in the compiler #18126

brson opened this issue Oct 17, 2014 · 2 comments · Fixed by #18132
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.

Comments

@brson
Copy link
Contributor

brson commented Oct 17, 2014

#16855 adds span_help and help diagnostic types, distinct from note. A significant number of notes are actually helpful suggestions and need to be converted.

@brson
Copy link
Contributor Author

brson commented Oct 17, 2014

My notes from the PR:

I scanned the source for notes that might be candidates for help and found these:

  • "having upstream crates all available in one format will likely make this go away"
  • "consider removing this semicolon:"
  • "consider changing this closure to take self by mutable reference"
  • "closures behind references must be called via &mut"
  • "type aliases cannot be used for traits"
  • "call the method using the . syntax"
  • "Did you mean to write: {} {{ /* fields */ }}?"
  • "consider using an explicit lifetime parameter as shown: {}"
  • "use "#[unsafe_destructor]" on the implementation to force the compiler to allow this"
  • "add #![feature(default_type_params)] to the crate attributes to enable"
  • "the trait {} must be implemented because it is required by {}"
  • "the trait {} must be implemented for the cast to the object type {}"
  • "the Copy trait is required because the repeated element will be copied"
  • "all local variables must have a statically known size"
  • "the left-hand-side of an assignment must have a statically known size"
  • "structs must have a statically known size to be initialized"
  • "cannot implement a destructor on a structure or enumeration that does not satisfy Send"
  • "use "#[unsafe_destructor]" on the implementation to force the compiler to allow this"
  • "the closure that captures {} requires that all captured variables implement the trait {}"
  • "only the last field of a struct or enum variant may have a dynamically sized type"
  • "did you mean &{}{}?"

... well, there are a lot.

Some notes combine both contextual info and suggestions and might be separated:

  • "{} moved here{} because it has type {}, which is moved by default (use ref to override)"
  • "{} moved here{} because it has type {}, which is moved by default (use ref to override)"

@brson brson added E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. C-enhancement Category: An issue proposing an enhancement or a PR with one. A-diagnostics Area: Messages for errors, warnings, and lints labels Oct 17, 2014
@ftxqxd
Copy link
Contributor

ftxqxd commented Oct 17, 2014

I’m working on this, but I think we still need to further clarify what counts as a help message rather than a note. If something directly suggests the user to do something (e.g., use ref to override), I think that definitely qualifies as a help message. If something just adds information to an error (e.g., reference must be valid for the block at 1:10), it should clearly be a note. But sometimes it’s not so easy to tell. Messages like type` aliases cannot be used for traits` _explain_ an error, but they don’t suggest what to do. So should they be notes or help messages? On one hand, it makes sense for them to be help messages, as they _help_ the user understand the main error message, but on the other hand, they are in a way part of the error. In a message like `expected `;`, found `{, it would be strange to separate the expected ;`` part into a help message, but it does only provide extra helpful information to explain the error.

gamazeps added a commit to gamazeps/rust that referenced this issue Oct 29, 2014
Closes rust-lang#15273 (I did not find how to get the identifier in the message
:/)

Also creates the span_help! macro associated with rust-lang#18126
ftxqxd added a commit to ftxqxd/rust that referenced this issue Nov 2, 2014
bors added a commit that referenced this issue Nov 4, 2014
Closes #18126.

At the moment this mostly only changes notes that are particularly help-oriented or directly suggest the user to do something to help messages, and does not change messages that simply explain an error message further. If it is decided that those messages should also be help messages, I can add them to this PR, but for now I’m excluding them as I believe that changing those messages might leave very few places where notes would be appropriate.
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 C-enhancement Category: An issue proposing an enhancement or a PR with one. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants