Conversation
|
Some changes occurred in compiler/rustc_attr_parsing cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_hir/src/attrs |
3eb0c39 to
e3e5e61
Compare
There was a problem hiding this comment.
Thanks, great idea. I love this.
A few points
- you need more tests, for invalid args, on invalid items, cross crate use, format parameters etc.
- format parameters; do these make sense? Currently they are not handled at all, just silently ignored. In
check_attr.rsyou can calldirective_visit_paramsand issue diagnostics for them. Would it be useful to have indexed parameters like{1},{2}to reference arguments? Something to think about, perhaps. - 2c on the naming; I don't have a problem with the name perse, I just intensely dislike names that are really long. Also you don't have to use the exact name estebank suggested :) Something shorter would be lovely. Also consider whether this is something we could extend to functions etc?
- Can you please add some docs about this in the unstable book: https://doc.rust-lang.org/nightly/unstable-book/
|
for naming, maybe |
e3e5e61 to
75df17e
Compare
This comment has been minimized.
This comment has been minimized.
75df17e to
2fed49b
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
595180d to
4898501
Compare
This comment has been minimized.
This comment has been minimized.
dc940ba to
dde50f5
Compare
This comment has been minimized.
This comment has been minimized.
dde50f5 to
2e0c595
Compare
…JonathanBrouwer Stabilize check-cfg suggestions for symbol When I was working on rust-lang#154794, I found a weird CI fail rust-lang#154794 (comment), I finally found this caused by unstable cfg suggestions by using `FxHashSet`(from PR rust-lang#154777). Because my PR by luck insert a new symbol, which makes the final diagnostic order changed. It's a standalone issue, so it's better to fix in a separate PR.
…JonathanBrouwer Stabilize check-cfg suggestions for symbol When I was working on rust-lang#154794, I found a weird CI fail rust-lang#154794 (comment), I finally found this caused by unstable cfg suggestions by using `FxHashSet`(from PR rust-lang#154777). Because my PR by luck insert a new symbol, which makes the final diagnostic order changed. It's a standalone issue, so it's better to fix in a separate PR.
…JonathanBrouwer Stabilize check-cfg suggestions for symbol When I was working on rust-lang#154794, I found a weird CI fail rust-lang#154794 (comment), I finally found this caused by unstable cfg suggestions by using `FxHashSet`(from PR rust-lang#154777). Because my PR by luck insert a new symbol, which makes the final diagnostic order changed. It's a standalone issue, so it's better to fix in a separate PR.
Rollup merge of #154886 - chenyukang:yukang-fix-cfg-sugg, r=JonathanBrouwer Stabilize check-cfg suggestions for symbol When I was working on #154794, I found a weird CI fail #154794 (comment), I finally found this caused by unstable cfg suggestions by using `FxHashSet`(from PR #154777). Because my PR by luck insert a new symbol, which makes the final diagnostic order changed. It's a standalone issue, so it's better to fix in a separate PR.
|
Some changes occurred to diagnostic attributes. cc @mejrs |
|
@rustbot ready |
There was a problem hiding this comment.
I'm happy with the implementation, just a couple of nits - see comments.
We also need more tests documenting the current behavior (if any) when applied to macro_rules! derive and attribute macros, as well as all the procedural macro types. It's up to you if you do that in this PR or add it as todos on the tracking issue. I think I prefer the latter though.
@estebank do you have any comments? If not, r=me with nits fixed.
| message = "pair! is missing its second argument", | ||
| label = "add the missing value here", | ||
| note = "this macro expects a type and a value, like `pair!(u8, 0)`", |
There was a problem hiding this comment.
The message and label were written with the "on missing args" semantics; they feel a little off now.
My suggestion:
#[diagnostic::on_unmatch_args(
message = "invalid arguments to {This} macro invocation",
label = "expected a type and value here",
note = "this macro expects a type and a value, like `pair!(u8, 0)`",
note = "see <link/to/docs>"
)]Thoughts?
The same is true for many tests, but those don't really matter I suppose.
| } | ||
|
|
||
| pair!(u8); | ||
| ``` |
There was a problem hiding this comment.
Please also show the compiler output below the example.
| /// [`offset_of_slice`]: https://doc.rust-lang.org/nightly/unstable-book/language-features/offset-of-slice.html | ||
| #[stable(feature = "offset_of", since = "1.77.0")] | ||
| #[diagnostic::on_unmatch_args( | ||
| note = "this macro expects a container type and a dot-separated field or variant path, like `offset_of!(Type, field)`" |
There was a problem hiding this comment.
| note = "this macro expects a container type and a dot-separated field or variant path, like `offset_of!(Type, field)`" | |
| note = "this macro expects a container type and a (nested) field path, like `offset_of!(Type, field)`" |
offset_of! for enums is unstable, we shouldn't suggest it.
9518bba to
60f40d1
Compare
This comment has been minimized.
This comment has been minimized.
60f40d1 to
e675ac9
Compare
This comment has been minimized.
This comment has been minimized.
|
r? me Sorry, one more thing I just noticed. In rustc_feature and the unstable book you reference #152494 as the tracking issue, but that is estebank's suggestion issue, not a tracking issue. Please create and link a proper tracking issue. r=me with tracking issue |
ok, I placed it as a placeholder link and forget it 😅 |
e675ac9 to
1f6541b
Compare
1f6541b to
8d75f0c
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. |
|
Thanks for working on this :) @bors r+ |
…uwer Rollup of 10 pull requests Successful merges: - #154794 (Add on_unmatch_args) - #155133 (Document precision considerations of `Duration`-float methods) - #154283 (Remove `nodes_in_current_session` field and related assertions) - #155374 (rustdoc: fix a few spots where emit isn't respected) - #155587 (Immediately feed visibility on DefId creation) - #155622 (c-variadic: `va_arg` fixes ) - #155629 (rustc_public: Add `constness` & `asyncness` in `FnDef`) - #155632 (Some metadata cleanups) - #155639 (BinOpAssign always returns unit) - #155647 (rustc-dev-guide subtree update)
…uwer Rollup of 10 pull requests Successful merges: - rust-lang/rust#154794 (Add on_unmatch_args) - rust-lang/rust#155133 (Document precision considerations of `Duration`-float methods) - rust-lang/rust#154283 (Remove `nodes_in_current_session` field and related assertions) - rust-lang/rust#155374 (rustdoc: fix a few spots where emit isn't respected) - rust-lang/rust#155587 (Immediately feed visibility on DefId creation) - rust-lang/rust#155622 (c-variadic: `va_arg` fixes ) - rust-lang/rust#155629 (rustc_public: Add `constness` & `asyncness` in `FnDef`) - rust-lang/rust#155632 (Some metadata cleanups) - rust-lang/rust#155639 (BinOpAssign always returns unit) - rust-lang/rust#155647 (rustc-dev-guide subtree update)
View all comments
Fixes #152494
r? @estebank