-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Suggest #[derive(Default)]
to enums with #[default]
#98873
Suggest #[derive(Default)]
to enums with #[default]
#98873
Conversation
r? @fee1-dead (rust-highfive has picked a reviewer for you, use r? to override) |
compiler/rustc_resolve/src/macros.rs
Outdated
err.span_help( | ||
self.session.source_map().guess_head_span(span), | ||
"consider adding `#[derive(Default)]` to this enum" | ||
); |
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 should ideally be span_suggestion
using span_to_snippet
on the source map.
@@ -0,0 +1,7 @@ | |||
pub enum Test { |
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.
We should also suggest changing the attribute to derive(Default)
if they meant it by annotating a struct
or enum
with #[default]
, although this does not need to be in this PR. could be a followup.
464e4aa
to
eb80407
Compare
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.
LGTM, I will prepare a follow-up.
@bors r+ |
📌 Commit eb80407 has been approved by |
…num-with-default-attribute, r=fee1-dead Suggest `#[derive(Default)]` to enums with `#[default]` fixes rust-lang#95226
Rollup of 6 pull requests Successful merges: - rust-lang#97300 (Implement `FusedIterator` for `std::net::[Into]Incoming`) - rust-lang#98761 (more `need_type_info` improvements) - rust-lang#98811 (Interpret: AllocRange Debug impl, and use it more consistently) - rust-lang#98847 (fix interpreter validity check on Box) - rust-lang#98854 (clean up the borrowing in rustc_hir_pretty) - rust-lang#98873 (Suggest `#[derive(Default)]` to enums with `#[default]`) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
…chaelwoerister suggest adding a derive for #[default] applied to variants cc `@TaKO8Ki` as followup to rust-lang#98873.
…chaelwoerister suggest adding a derive for #[default] applied to variants cc ``@TaKO8Ki`` as followup to rust-lang#98873.
fixes #95226