Use E0665 for missing #[default] on enum and update doc#134364
Merged
bors merged 2 commits intorust-lang:masterfrom Dec 22, 2024
Merged
Use E0665 for missing #[default] on enum and update doc#134364bors merged 2 commits intorust-lang:masterfrom
#[default] on enum and update doc#134364bors merged 2 commits intorust-lang:masterfrom
Conversation
Collaborator
fmease
reviewed
Dec 16, 2024
Member
There was a problem hiding this comment.
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.
fmease
approved these changes
Dec 21, 2024
bac7682 to
4bf8948
Compare
estebank
commented
Dec 21, 2024
| Erroneous code example: | ||
|
|
||
| ```compile_fail | ||
| ```compile_fail,ignore |
Contributor
Author
There was a problem hiding this comment.
I had to do this to get over the stage0 test of this page.
Member
There was a problem hiding this comment.
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
Contributor
Author
|
@bors r=fmease |
Collaborator
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Dec 22, 2024
…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
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Dec 22, 2024
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, | ++++++++++ ```
github-actions bot
pushed a commit
to tautschnig/verify-rust-std
that referenced
this pull request
Mar 11, 2025
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The docs for E0665 when doing
#[derive(Default]on anenumpreviously 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.