-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Use E0665 for missing #[default]
on enum and update doc
#134364
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This error code is no longer emitted by the compiler and I don't see the point in updating this entry if it no longer sees the light of day (ignoring the use of old rustc verions & subsequent exposure via the website).
The diagnostic which gets currently emitted on a #[derive(Default)] enum
without #[default]
doesn't have any error code associated with it. I don't know why it didn't take over E0665. If you make it use E0665 (I think that makes sense), then I'm fine with updating this entry.
ef5d730
to
bac7682
Compare
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this diagnostic and the error index entry is now so much better!
r=me after nits & CI failure addressed and title change
bac7682
to
4bf8948
Compare
|
||
Erroneous code example: | ||
|
||
```compile_fail | ||
```compile_fail,ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to do this to get over the stage0 test of this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't the following make this work?
```compile_fail,E0665
This comment has been minimized.
This comment has been minimized.
Use orphaned error code for the same error it belonged to before. ``` error[E0665]: `#[derive(Default)]` on enum with no `#[default]` --> $DIR/macros-nonfatal-errors.rs:42:10 | LL | #[derive(Default)] | ^^^^^^^ LL | / enum NoDeclaredDefault { LL | | Foo, LL | | Bar, LL | | } | |_- this enum needs a unit variant marked with `#[default]` | = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) help: make this unit variant default by placing `#[default]` on it | LL | #[default] Foo, | ~~~~~~~~~~~~~~ help: make this unit variant default by placing `#[default]` on it | LL | #[default] Bar, | ~~~~~~~~~~~~~~ ```
4bf8948
to
94812f1
Compare
#[default]
in E0655 code index#[default]
on enum and update doc
@bors r=fmease |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#134364 (Use E0665 for missing `#[default]` on enum and update doc) - rust-lang#134601 (Support pretty-printing `dyn*` trait objects) - rust-lang#134603 (Explain why a type is not eligible for `impl PointerLike`.) - rust-lang#134618 (coroutine_clone: add comments) - rust-lang#134630 (Use `&raw` for `ptr` primitive docs) - rust-lang#134637 (Flatten effects directory now that it doesn't really test anything specific) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#134364 - estebank:derive-docs, r=fmease Use E0665 for missing `#[default]` on enum and update doc The docs for E0665 when doing `#[derive(Default]` on an `enum` previously didn't mention `#[default]` at all, or made a distinction between unit variants, that can be annotated, and tuple or struct variants, which cannot. E0665 was not being emitted, we now use it for the same error it belonged to before. ``` error[E0665]: `#[derive(Default)]` on enum with no `#[default]` --> $DIR/macros-nonfatal-errors.rs:42:10 | LL | #[derive(Default)] | ^^^^^^^ LL | / enum NoDeclaredDefault { LL | | Foo, LL | | Bar, LL | | } | |_- this enum needs a unit variant marked with `#[default]` | = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) help: make this unit variant default by placing `#[default]` on it | LL | #[default] Foo, | ++++++++++ help: make this unit variant default by placing `#[default]` on it | LL | #[default] Bar, | ++++++++++ ```
The docs for E0665 when doing
#[derive(Default]
on anenum
previously didn't mention#[default]
at all, or made a distinction between unit variants, that can be annotated, and tuple or struct variants, which cannot.E0665 was not being emitted, we now use it for the same error it belonged to before.