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

Add error explanations for all error codes (tracking issue). #24407

Closed
michaelsproul opened this issue Apr 14, 2015 · 122 comments
Closed

Add error explanations for all error codes (tracking issue). #24407

michaelsproul opened this issue Apr 14, 2015 · 122 comments
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. metabug Issues about issues themselves ("bugs about bugs")

Comments

@michaelsproul
Copy link
Contributor

This is a metabug for rustc --explain error descriptions.

All the errors in need of descriptions are listed in this spreadsheet. If you'd like to help out, comment with the bunch of errors you'd like to tackle, and list yourself as assigned on the spreadsheet!

Choosing a few errors in the same file is probably a good way to start.

How to add an error explanation

Error explanations live in src/librustc*/diagnostics.rs. To add a new explanation you have to delete the error from the register_diagnostics! invocation and add it to the register_long_diagnostics! invocation, along with the explanation. The format for the explanation is 80 characters per line, with a newline at the very start and end of the string. Including code examples is encouraged, with full markdown formatting (single-tick for inline, triple for blocks). Copy the format of the existing errors and you should be good!

Once you've added an explanation you can test it out by compiling and running stage1 as follows:

$ make rustc-stage1
$ export PATH=x86_64-unknown-linux-gnu/stage1/bin:$PATH
$ export LD_LIBRARY_PATH=x86_64-unknown-linux-gnu/stage1/lib:$LD_LIBRARY_PATH
$ rustc --explain EXXXX

If you want to see how it renders as HTML you'll have to build the error index, which requires stage2:

$ make doc/error-index.html

You can add -j 4 to use 4 parallel make processes.

Once you're happy with the result, submit a pull request and we'll review it.

Progress

We're tracking progress with a shared spreadsheet. If you'd like to write an error message, put your name down for one of the unassigned errors.

Rust Error Diagnostic Spreadsheet (click me!)

As you complete error descriptions it would also be great if you could mark the errors as "merged" on the spreadsheet 😄

@michaelsproul
Copy link
Contributor Author

Thanks! I wasn't aware of those!

@lambda-fairy
Copy link
Contributor

I'll take E0152 through E0170, thanks!

Question: Should I squash all the additions into a single commit, or keep them separate?

@GuillaumeGomez
Copy link
Member

I'll take E0009 (a little start to begin).

@michaelsproul
Copy link
Contributor Author

@lfairy: Either is fine. If there are logical slabs of messages that could also work well.

@GuillaumeGomez: Sounds good 😄

@michaelsproul
Copy link
Contributor Author

Thanks!

@ruuda
Copy link
Contributor

ruuda commented Apr 14, 2015

I’ll take E0297 through E0302 (the ones in check_match). Edit: I’ll take E0162 and E0165 as well. I have not been able to come up with an example that causes 298, 299 or 300. Does anybody have a snippet that causes these? Anything I try fails with a type mismatch. Similarly, I have not been able to produce 158 yet, but there is an unnumbered error with a similar message. (Maybe those should be reconciled?)

@lambda-fairy
Copy link
Contributor

@ruud-v-a I'm already working on 158/162/165 (see my comment above)

@michaelsproul
Copy link
Contributor Author

Sorry Chris, I only just noticed this now... If you have anything to add to Ruud's descriptions go ahead!

I was hoping I could transform the list into a more complete one, but my script is somewhat broken so I'm looking into better ways to extract error information (uniqueness checking, finding errors without descriptions, HTML output). For now I've marked who's working on what in the current list.

@michaelsproul
Copy link
Contributor Author

I just did E0296.

@michaelsproul
Copy link
Contributor Author

I'll also take the loop ones, E0267 and E0268.

@lambda-fairy
Copy link
Contributor

@michaelsproul No worries :)

I'll take E0306 and E0307.

@cactorium
Copy link
Contributor

Could I try E0308-E0311?

@michaelsproul
Copy link
Contributor Author

@cactorium: Go for it! 😄

@ruuda
Copy link
Contributor

ruuda commented Apr 15, 2015

@lfairy: oops, my apologies. I hope you don’t mind.

@nham
Copy link
Contributor

nham commented Apr 16, 2015

I've tried my hand at E0015 and E0020

@GuillaumeGomez
Copy link
Member

I now take E0018 (should I open a new PR for it or not ?).

@michaelsproul
Copy link
Contributor Author

@GuillaumeGomez: You'll need a new PR as your previous one was just approved

@GuillaumeGomez
Copy link
Member

@michaelsproul: Yes, I just saw that.

Manishearth added a commit to Manishearth/rust that referenced this issue Apr 17, 2015
 I've updated the diagnostic registration plugin so that it validates error descriptions. An error description is only valid if it starts and ends with a newline, and contains no more than 80 characters per line.

The plugin forced me to fix E0005 and E0006 which had escaped manual attention!

I've also added errors for E0267, E0268, E0296, whilst updating E0303 as per discussion in rust-lang#24143.

cc rust-lang#24407
@AlisdairO
Copy link
Contributor

thanks :)

bors added a commit that referenced this issue Aug 30, 2015
bors added a commit that referenced this issue Aug 30, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 3, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 3, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 3, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 3, 2015
Manishearth added a commit to Manishearth/rust that referenced this issue Sep 5, 2015
@joelmccracken
Copy link

I'd like to see some description added to a specific error message:

https://github.com/rust-lang/rust/blob/master/src/librustc_borrowck/borrowck/gather_loans/move_error.rs#L123

I notice that this is not in the spreadsheet/no EXXXX designation is associated with it. Is there any specific reason there is no error code associated with it?

@Manishearth
Copy link
Member

@joelmccracken No reason, we should fix that. @GuillaumeGomez has been working on these

That's basically the "next step" of this issue.

  • Step 1: Explain existing error codes
  • Step 2: Add more error codes and explain them
  • Step 3: Add inline notes to errors whenever there are one or two very common, non-obvious solutions or causes

@GuillaumeGomez
Copy link
Member

I will take a more global look when I have time. Thanks for reporting this @joelmccracken.

bors added a commit that referenced this issue Oct 4, 2015
`--explain` support for E0163 and E0164.

Part of #24407
@AlisdairO
Copy link
Contributor

OK, it's clearly time for me to admit that I'm not going to find time to get 321 done - apologies! Reproduction below:

aux321.rs:

#![feature(optin_builtin_traits)]
pub trait DefaultedTrait { } 
impl DefaultedTrait for .. { }

321.rs:

extern crate aux321;

use aux321::DefaultedTrait;
struct C;

impl DefaultedTrait for C { } 
impl <'a> DefaultedTrait for &'a C { } 
impl DefaultedTrait for Box<C> { }

rustc --crate-type=lib aux321.rs
rustc --crate-type=lib -L . 321.rs

Should yield E0321.

@GuillaumeGomez
Copy link
Member

@AlisdairO: Thanks! I'll write in the next days then.

PS: I post the RFC here: https://github.com/rust-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md#default-and-negative-impls
And more information here:

// We only want to permit structs/enums, but not *all* structs/enums.
// They must be local to the current crate, so that people
// can't do `unsafe impl Send for Rc<SomethingLocal>` or
// `impl !Send for Box<SomethingLocalAndSend>`.
Some(self_def_id) => {
if self_def_id.is_local() {
None
} else {
Some(format!(
"cross-crate traits with a default impl, like `{}`, \
can only be implemented for a struct/enum type \
defined in the current crate",
self.tcx.item_path_str(trait_def_id)))
}
}
_ => {
Some(format!(
"cross-crate traits with a default impl, like `{}`, \
can only be implemented for a struct/enum type, \
not `{}`",
self.tcx.item_path_str(trait_def_id),
self_ty))
}
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. metabug Issues about issues themselves ("bugs about bugs")
Projects
None yet
Development

No branches or pull requests