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

Comments

Projects
None yet
@michaelsproul
Contributor

michaelsproul commented Apr 14, 2015

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

This comment has been minimized.

Show comment
Hide comment
@michaelsproul

michaelsproul Apr 14, 2015

Contributor

Thanks! I wasn't aware of those!

Contributor

michaelsproul commented Apr 14, 2015

Thanks! I wasn't aware of those!

@lfairy

This comment has been minimized.

Show comment
Hide comment
@lfairy

lfairy Apr 14, 2015

Contributor

I'll take E0152 through E0170, thanks!

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

Contributor

lfairy commented Apr 14, 2015

I'll take E0152 through E0170, thanks!

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

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Apr 14, 2015

Member

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

Member

GuillaumeGomez commented Apr 14, 2015

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

@michaelsproul

This comment has been minimized.

Show comment
Hide comment
@michaelsproul

michaelsproul Apr 14, 2015

Contributor

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

@GuillaumeGomez: Sounds good 😄

Contributor

michaelsproul commented Apr 14, 2015

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

@GuillaumeGomez: Sounds good 😄

@michaelsproul

This comment has been minimized.

Show comment
Hide comment
@michaelsproul

michaelsproul Apr 14, 2015

Contributor

Thanks!

Contributor

michaelsproul commented Apr 14, 2015

Thanks!

@ruuda

This comment has been minimized.

Show comment
Hide comment
@ruuda

ruuda Apr 14, 2015

Contributor

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?)

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?)

@lfairy

This comment has been minimized.

Show comment
Hide comment
@lfairy

lfairy Apr 15, 2015

Contributor

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

Contributor

lfairy commented Apr 15, 2015

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

@michaelsproul

This comment has been minimized.

Show comment
Hide comment
@michaelsproul

michaelsproul Apr 15, 2015

Contributor

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.

Contributor

michaelsproul commented Apr 15, 2015

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

This comment has been minimized.

Show comment
Hide comment
@michaelsproul

michaelsproul Apr 15, 2015

Contributor

I just did E0296.

Contributor

michaelsproul commented Apr 15, 2015

I just did E0296.

@michaelsproul

This comment has been minimized.

Show comment
Hide comment
@michaelsproul

michaelsproul Apr 15, 2015

Contributor

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

Contributor

michaelsproul commented Apr 15, 2015

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

@lfairy

This comment has been minimized.

Show comment
Hide comment
@lfairy

lfairy Apr 15, 2015

Contributor

@michaelsproul No worries :)

I'll take E0306 and E0307.

Contributor

lfairy commented Apr 15, 2015

@michaelsproul No worries :)

I'll take E0306 and E0307.

@cactorium

This comment has been minimized.

Show comment
Hide comment
@cactorium

cactorium Apr 15, 2015

Contributor

Could I try E0308-E0311?

Contributor

cactorium commented Apr 15, 2015

Could I try E0308-E0311?

@michaelsproul

This comment has been minimized.

Show comment
Hide comment
@michaelsproul

michaelsproul Apr 15, 2015

Contributor

@cactorium: Go for it! 😄

Contributor

michaelsproul commented Apr 15, 2015

@cactorium: Go for it! 😄

@ruuda

This comment has been minimized.

Show comment
Hide comment
@ruuda

ruuda Apr 15, 2015

Contributor

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

Contributor

ruuda commented Apr 15, 2015

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

@nham

This comment has been minimized.

Show comment
Hide comment
@nham

nham Apr 16, 2015

Contributor

I've tried my hand at E0015 and E0020

Contributor

nham commented Apr 16, 2015

I've tried my hand at E0015 and E0020

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Apr 16, 2015

Member

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

Member

GuillaumeGomez commented Apr 16, 2015

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

steveklabnik added a commit to steveklabnik/rust that referenced this issue Apr 16, 2015

@michaelsproul

This comment has been minimized.

Show comment
Hide comment
@michaelsproul

michaelsproul Apr 17, 2015

Contributor

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

Contributor

michaelsproul commented Apr 17, 2015

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

@GuillaumeGomez

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Apr 17, 2015

Member

@michaelsproul: Yes, I just saw that.

Member

GuillaumeGomez commented Apr 17, 2015

@michaelsproul: Yes, I just saw that.

Manishearth added a commit to Manishearth/rust that referenced this issue Apr 17, 2015

Rollup merge of #24458 - michaelsproul:extended-errors, r=huonw
 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 #24143.

cc #24407

Manishearth added a commit to Manishearth/rust that referenced this issue Apr 17, 2015

Manishearth added a commit to Manishearth/rust that referenced this issue Apr 17, 2015

Rollup merge of #24458 - michaelsproul:extended-errors, r=huonw
 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 #24143.

cc #24407
@AlisdairO

This comment has been minimized.

Show comment
Hide comment
@AlisdairO

AlisdairO Aug 28, 2015

Contributor

thanks :)

Contributor

AlisdairO commented Aug 28, 2015

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 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

This comment has been minimized.

Show comment
Hide comment
@joelmccracken

joelmccracken Sep 10, 2015

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?

joelmccracken commented Sep 10, 2015

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

This comment has been minimized.

Show comment
Hide comment
@Manishearth

Manishearth Sep 10, 2015

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
Member

Manishearth commented Sep 10, 2015

@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

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Sep 10, 2015

Member

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

Member

GuillaumeGomez commented Sep 10, 2015

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

Auto merge of #28825 - iwillspeak:master, r=alexcrichton
`--explain` support for E0163 and E0164.

Part of rust-lang/rust#24407
@AlisdairO

This comment has been minimized.

Show comment
Hide comment
@AlisdairO

AlisdairO Nov 6, 2015

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.

Contributor

AlisdairO commented Nov 6, 2015

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

This comment has been minimized.

Show comment
Hide comment
@GuillaumeGomez

GuillaumeGomez Nov 6, 2015

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))
}
};

Member

GuillaumeGomez commented Nov 6, 2015

@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