-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Fix ICE caused by parsed attributes applied to where bounds #143781
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
base: master
Are you sure you want to change the base?
Fix ICE caused by parsed attributes applied to where bounds #143781
Conversation
Signed-off-by: Jonathan Brouwer <[email protected]>
Signed-off-by: Jonathan Brouwer <[email protected]>
Some changes occurred in compiler/rustc_attr_data_structures Some changes occurred in compiler/rustc_attr_parsing Some changes occurred in compiler/rustc_passes/src/check_attr.rs |
@@ -232,7 +232,7 @@ pub enum AttributeKind { | |||
}, | |||
|
|||
/// Represents `#[rustc_const_stable_indirect]`. | |||
ConstStabilityIndirect, | |||
ConstStabilityIndirect(Span), |
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.
I fixed this issue by giving all AttributeKind
variants a span. I think this is the better way, the alternative would be removing the span from all variants and adding it to Attribute::Parsed
.
I went for this approach because:
- I think
Attribute::Unparsed
is probably going away in the future anyways? (not sure, cc @jdonszelmann) - Putting the span in
Attribute::Unparsed
means thefind_attr!
macro no longer has access to it. This could be fixed by giving the macro the span as a separate argument but that makes the macro calls quite a bit uglier
This comment has been minimized.
This comment has been minimized.
018cd73
to
8f5c235
Compare
This PR changes a file inside |
8f5c235
to
49e328c
Compare
does this also fix #143787? |
Yes it does fix the ICE, I've added it to the fixes list and added it to the tests |
Signed-off-by: Jonathan Brouwer <[email protected]>
49e328c
to
3d8d1e7
Compare
This exact pr has been proposed several times at this point by different people. However, I'm again blocking it since eventually I want to remove the .span() function from attributes. It's there just for the transition period. Many attributes don't have a single span to point to. Maybe, just maybe I'm in favor of merging this when the method is called "first_span" but even then I think people will use it in a way that makes diagnostics confusing. Diagnostics that care about the span of attributes should either be about a specific attribute (in which case the code knows what all the spans in the parsed attribute mean) or should happen before parsing. Finally there's the case of Unparsed, which will only stick around for tool attributes. My plan for those is to parse those into a kind of meta item syntax tree (remove the tokens) and expose that to whoever wants to deal with tool attrs. |
I know im blocking those ICEs from being fixed rn. But I strongly believe those ICEs should be fixed by not using .span(). Not by expanding the method. |
@jdonszelmann I understand completely, and I agree that this method should be avoided as much as possible However, I don't see a way to fix this specific ICE (http://github.com/rust-lang/rust/issues/138510) without such a method, even after all attributes are parsed. This specific check has an allowlist of allowed attributes, and needs to span to error on attributes that are not on that allowlist. And I think this is an ICE that I would like to see fixed, it can be triggered even without the feature flag and has been reported 3 times now. I propose to create a second method ( |
|
Fixes #143780
Fixes #138510
Fixes #143787
Fixes #143094 still needs a test
r? @oli-obk
cc @jdonszelmann