Clean up AttributeLintKind and refactor diagnostic attribute linting#155215
Clean up AttributeLintKind and refactor diagnostic attribute linting#155215rust-bors[bot] merged 8 commits intorust-lang:mainfrom
AttributeLintKind and refactor diagnostic attribute linting#155215Conversation
|
Some changes occurred in compiler/rustc_attr_parsing |
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
0dd591a to
a4e8640
Compare
|
The Miri subtree was changed cc @rust-lang/miri |
This comment has been minimized.
This comment has been minimized.
a4e8640 to
0dd591a
Compare
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
@rustbot label -WG-trait-system-refactor |
| span, | ||
| ); | ||
| } | ||
| if matches!(mode, Mode::RustcOnUnimplemented) { |
There was a problem hiding this comment.
I don't really like matches! here because if we ever add another rustc diagnostic attribute, we could forget to check it. How about a method mode.should_error(), that has an exhaustive match in it?
There was a problem hiding this comment.
It doesn't actually matter, assuming we don't ship a std that compiles with warnings?
So far my decisions on whether rustc_on_unimplemented errors or issues a diagnostic namespace lint have been largely focused on keeping the implementation simple:
- erroring is easier than adding AttributeLintKind variants
- so hard error in rustc_on_unimplemented-only paths to simplify there
- issue lints in shared paths so you don't have to care about which attr it is
In fact, maybe this should just be a warning regardless?
There was a problem hiding this comment.
That mentality also sounds reasonable to me, lets make this a warning to keep the implementation simple
There was a problem hiding this comment.
I think I remember why it is this way, I applied the suggestion and then I got annoyed because
LL | #[rustc_on_unimplemented(lorem = "")]
| ^^^^^^^^^^ invalid option found here
|
= help: only `message`, `note` and `label` are allowed as options
is not quite right.
The last commit fixes that by letting you customize the "allowed options" list per attribute. Note that I'm inclined to have an attribute with only "note" allowed, (#155200 (comment)) so we will need some kind of customization (or more lint variants) anyway.
Let me know what you think about the last few commits, idm backing it out if you prefer.
There was a problem hiding this comment.
Seems reasonable, especially since we need this in the future :)
|
✌️ @mejrs, you can now approve this pull request! If @JonathanBrouwer told you to " |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
79d2d9a to
103adaa
Compare
This comment has been minimized.
This comment has been minimized.
103adaa to
d6bccac
Compare
|
@bors r+ rollup |
…hanBrouwer Clean up `AttributeLintKind` and refactor diagnostic attribute linting There was a fair amount of duplication here, and thanks to the proliferation of new diagnostic attributes these days, it was threatening to grow bigger.
Rollup of 18 pull requests Successful merges: - #154595 (Emit fatal on invalid const args with nested defs) - #154599 (report the `varargs_without_pattern` lint in deps) - #154699 (`core::unicode`: Replace `Cased` table with `Lt`) - #155353 (resolve: Remove `inaccessible_ctor_reexport` resolver field) - #155357 (Add `--remap-path-scope` as unstable in rustdoc) - #150649 (clippy fix: non_canonical_clone_impl) - #154604 (abort in core) - #154616 (Add `--quiet` flag to x.py and bootstrap to suppress output) - #154970 (rustdoc: preserve `doc(cfg)` on locally re-exported type aliases) - #155215 (Clean up `AttributeLintKind` and refactor diagnostic attribute linting) - #155228 (Check diagnostic output in incremental `cpass` and `rpass` revisions) - #155266 (Adjust release notes for post-merge feedback) - #155326 (Disallow ZST allocations with `TypedArena`.) - #155334 (docs: Use `0b1` instead of `NonZero::MIN` in `NonZero::bit_width` doctests) - #155340 (Handle nonnull pattern types in size skeleton) - #155347 (Add push_mut and new Layout methods to release notes) - #155356 (remove calls to AliasTyKind::def_id) - #155364 (Reduce diagnostic type visibilities.)
Rollup of 18 pull requests Successful merges: - #154451 (Require that a `<_ as Try>::Residual` implement the `Residual` trait) - #154595 (Emit fatal on invalid const args with nested defs) - #154599 (report the `varargs_without_pattern` lint in deps) - #154699 (`core::unicode`: Replace `Cased` table with `Lt`) - #155353 (resolve: Remove `inaccessible_ctor_reexport` resolver field) - #155357 (Add `--remap-path-scope` as unstable in rustdoc) - #150649 (clippy fix: non_canonical_clone_impl) - #154604 (abort in core) - #154616 (Add `--quiet` flag to x.py and bootstrap to suppress output) - #155215 (Clean up `AttributeLintKind` and refactor diagnostic attribute linting) - #155228 (Check diagnostic output in incremental `cpass` and `rpass` revisions) - #155266 (Adjust release notes for post-merge feedback) - #155326 (Disallow ZST allocations with `TypedArena`.) - #155334 (docs: Use `0b1` instead of `NonZero::MIN` in `NonZero::bit_width` doctests) - #155340 (Handle nonnull pattern types in size skeleton) - #155347 (Add push_mut and new Layout methods to release notes) - #155356 (remove calls to AliasTyKind::def_id) - #155364 (Reduce diagnostic type visibilities.)
Rollup merge of #155215 - mejrs:condense_diag_lints, r=JonathanBrouwer Clean up `AttributeLintKind` and refactor diagnostic attribute linting There was a fair amount of duplication here, and thanks to the proliferation of new diagnostic attributes these days, it was threatening to grow bigger.
There was a fair amount of duplication here, and thanks to the proliferation of new diagnostic attributes these days, it was threatening to grow bigger.