Use attribute parser for #[non_exhaustive] attribute check - #161482
Conversation
|
Some changes occurred in compiler/rustc_attr_ir cc @jdonszelmann, @JonathanBrouwer Some changes occurred in compiler/rustc_passes/src/check_attr.rs cc @jdonszelmann, @JonathanBrouwer Some changes occurred to diagnostic attributes. cc @mejrs Some changes occurred in compiler/rustc_attr_parsing |
This comment has been minimized.
This comment has been minimized.
|
I'm not sure about this change. We'd like to have more of these checks in attribute parsing but we also don't want to make |
|
Indeed, this information also feels too specific to add to the |
|
@rustbot author |
|
Reminder, once the PR becomes ready for a review, use |
This comment has been minimized.
This comment has been minimized.
7074c3b to
895661b
Compare
This comment has been minimized.
This comment has been minimized.
895661b to
2c7e6b6
Compare
There was a problem hiding this comment.
I like this path of making the target ast::Item available a lot more. I need some time to think about whether this is the right way forwards, so this PR might linger for a few weeks until I have the time to do so. Sorry in advance, I appreciate your work!
This comment has been minimized.
This comment has been minimized.
| if cx.target != Target::Struct { | ||
| return; | ||
| } | ||
| let Some(item) = cx.target_item else { |
There was a problem hiding this comment.
Could we panic if target_item is not present rather than silently ignoring it?
If we silently ignore this, it risks an attribute parsing call not passing the target_item and accidentally skipping the checks.
There was a problem hiding this comment.
I have addressed this.
| rustc_ast::ast::VariantData::Struct { fields, .. }, | ||
| ) = &item.kind | ||
| else { | ||
| return; |
There was a problem hiding this comment.
I think same thing here, something has gone very wrong if this branch is reached, we should panic, not silently ignore it
There was a problem hiding this comment.
This is sort of like check_attr in that there's ~2 ways to check the target, and some checks use a bit of both so you end up with all these unreachable! and panic! branches that are rather visually noisy. It would nice to not have that here.
I don't like this aspect of what this PR does.
There was a problem hiding this comment.
Yeah I also don't like this, but I'm not sure there is an alternative.
I can think of the following solutiions:
- Don't check
targetand only checkitem.kind, but I'd like to panic if we don't passitemand target isstruct, which you then sacrifice - Make a helper function that does this, not sure if this is worth it either
There was a problem hiding this comment.
I agree. This is not the best, but I have no better way to do it.
There was a problem hiding this comment.
Given that the old code has the same problem, so this PR is not worsening the situation, and I see no way around this, let's just accept this
|
@rustbot author |
2c7e6b6 to
5f0a64e
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. |
…thanBrouwer Use attribute parser for `#[non_exhaustive]` attribute check Updates rust-lang#153101 r? @JonathanBrouwer
…thanBrouwer Use attribute parser for `#[non_exhaustive]` attribute check Updates rust-lang#153101 r? @JonathanBrouwer
…uwer Rollup of 10 pull requests Successful merges: - #162126 (Rename various resolving functions for consistency, and document them) - #162520 (Refactor `HygieneEncodeContext`) - #154373 (Skip linting unused braces for FunctionArg and MethodArg context for 2024 later ) - #160023 (Refactor the way cg_ssa handles indirect returns (returns via `sret`) — Take 2) - #161482 (Use attribute parser for `#[non_exhaustive]` attribute check) - #161867 (deeper `rustc_builtin_macros` cleanups) - #162099 (small refactor of doc attribute arguments warnings) - #162541 (split `macroless_generic_const_args` in two) - #162549 (The fuchsia team maintains `riscv64gc-unknown-fuchsia`) - #162577 (Fix `i686-pc-windows-msvc` platform support docs and target spec metadata)
…thanBrouwer Use attribute parser for `#[non_exhaustive]` attribute check Updates rust-lang#153101 r? @JonathanBrouwer
…uwer Rollup of 11 pull requests Successful merges: - #162520 (Refactor `HygieneEncodeContext`) - #154373 (Skip linting unused braces for FunctionArg and MethodArg context for 2024 later ) - #160023 (Refactor the way cg_ssa handles indirect returns (returns via `sret`) — Take 2) - #160860 (Implement arbitrary casts in custom mir) - #161482 (Use attribute parser for `#[non_exhaustive]` attribute check) - #161867 (deeper `rustc_builtin_macros` cleanups) - #162099 (small refactor of doc attribute arguments warnings) - #162541 (split `macroless_generic_const_args` in two) - #162549 (The fuchsia team maintains `riscv64gc-unknown-fuchsia`) - #162577 (Fix `i686-pc-windows-msvc` platform support docs and target spec metadata) - #162624 (regression test for opaque field projection in closure capture)
Rollup merge of #161482 - obeis:check-non-exhaustive, r=JonathanBrouwer Use attribute parser for `#[non_exhaustive]` attribute check Updates #153101 r? @JonathanBrouwer
|
Note This PR was benchmarked as part of triage of its containing rollup: triage URL. Finished benchmarking commit (e705029): comparison URL. Overall result: no relevant changes - no action needed@rustbot label: -perf-regression Instruction countThis perf run didn't have relevant results for this metric. Max RSS (memory usage)This perf run didn't have relevant results for this metric. CyclesResults (secondary 2.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeThis perf run didn't have relevant results for this metric. Bootstrap: missing data |
View all comments
Updates #153101
r? @JonathanBrouwer