TyCtxt::get_attr should check that no duplicates are allowed#100658
TyCtxt::get_attr should check that no duplicates are allowed#100658bors merged 1 commit intorust-lang:masterfrom
Conversation
|
(rust-highfive has picked a reviewer for you, use r? to override) |
|
r? @lcnr |
|
r? @lcnr |
compiler/rustc_middle/src/ty/mod.rs
Outdated
There was a problem hiding this comment.
we can't check whether there are multiple attributes, but instead have to check that we only use get_attr in cases where the compiler can reasonably deal with multiple attributes.
e.g. the following would ICE with your change (please add that as a test)
#[repr(C)]
#[repr(C)]
enum Foo {}
fn main() {}instead check - similar to is_builtin_only_local - whether the feature definition in rustc_feature either warns or errors on duplicate attributes. This might not be enough as there could be some attributes where duplicates are allowed, but useless, but that's a bridge we can burn when we get to it.
There was a problem hiding this comment.
got it, I will dig more and ping you if I need help.
There was a problem hiding this comment.
We should check:
pub enum AttributeDuplicates {
#[default]
DuplicatesOk
...
}If the attribute is marked as DuplicatesOk WarnFollowing, or WarnFollowingWordOnly, then we allow multiple attributes, otherwise raise an error?
There was a problem hiding this comment.
We have a check for proper diagnostics,
rust/compiler/rustc_passes/src/check_attr.rs
Line 2223 in e1b28cd
There was a problem hiding this comment.
If the attribute is marked as
DuplicatesOkWarnFollowing, orWarnFollowingWordOnly, then we allow multiple attributes, otherwise raise an error?
The other way around. We should only use get_attr for attributes which are either WarnFollowing, ErrorFollowing, ErrorPreceding, FutureWarnFollowing and FutureWarnPreceding. For all other attributes using get_attr is a compiler bug so we should ICE there. We should not emit errors for users in get_attr.
1364dcb to
7ec7edd
Compare
lcnr
left a comment
There was a problem hiding this comment.
some nits, then r=me
thanks 👍
7ec7edd to
5e8b356
Compare
|
r=@lcnr |
|
@bors r=lcnr |
|
📌 Commit 5e8b356775549c66eec8cd31dcde60576268d766 has been approved by It is now in the queue for this repository. |
This comment has been minimized.
This comment has been minimized.
5e8b356 to
7d45a75
Compare
|
@chenyukang: 🔑 Insufficient privileges: Not in reviewers |
|
r? @lcnr |
|
@bors r+ rollup |
…r=lcnr TyCtxt::get_attr should check that no duplicates are allowed Fixes rust-lang#100631
…r=lcnr TyCtxt::get_attr should check that no duplicates are allowed Fixes rust-lang#100631
|
Failed on rollup: #101463 (comment) @bors r- |
7d45a75 to
575e9b6
Compare
Rebase and updated. |
because large directories are difficult to navigate, both in editors and in the github view. E.g. https://github.com/rust-lang/rust/tree/master/src/test/ui/issues currently does not show 1146 entries, which is a annoying for people manually searching for a file @bors delegate+ (after fixing the nit you can run |
|
✌️ @chenyukang can now approve this pull request |
|
📌 Commit 575e9b6414f9986f5dcdfbfc06356d554636aa86 has been approved by It is now in the queue for this repository. |
|
woops |
575e9b6 to
00b10a5
Compare
|
@bors r=lcnr |
|
(side-note @chenyukang it's usually best to wait until CI is green until approving a PR, just in case it fails!) |
Rollup of 5 pull requests Successful merges: - rust-lang#100658 (TyCtxt::get_attr should check that no duplicates are allowed) - rust-lang#101021 (Migrate ``rustc_middle`` diagnostic) - rust-lang#101287 (Document eager evaluation of `bool::then_some` argument) - rust-lang#101412 (Some more cleanup in `core`) - rust-lang#101427 (Fix ICE, generalize 'move generics to trait' suggestion for >0 non-rcvr arguments) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #100631