-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Fix ICE on undocumented_unsafe_blocks
#7988
Fix ICE on undocumented_unsafe_blocks
#7988
Conversation
r? @camsteffen (rust-highfive has picked a reviewer for you, use r? to override) |
@bors r+ Thanks! And another one from this lint... |
📌 Commit 3f3d7c2 has been approved by |
} else { | ||
self.macro_expansion = false; | ||
enclosing_scope_span.to(block_span) | ||
enclosing_scope_span.to(block_span).source_callsite() |
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.
This fixes the case in question but I think there are more cases unaccounted for. In general I think two spans should be ensured to have the same span.ctxt()
before combining them with to
, with_hi
, etc, otherwise the operation is unpredictable. There can be any combination of contexts between the two spans.
A general fix might be...
if enclosing_scope_span.ctxt() != block_span.ctxt() {
// get the span of the macro call
// mac! { unsafe {} }
enclosing_scope_span = hygiene::walk_chain(enclosing_scope_span, block_span.ctxt());
if enclosing_scope_span.ctxt() != block_span.ctxt() {
// if the contexts are still not equal after walk_chain,
// the unsafe block span context is a descendant of the enclosing scope span context
// { macro_with_unsafe!() }
// return since I don't know what span to use
return;
}
}
But then I don't know if this lint is designed to work with the span of a macro call, where there can be an arbitrary amount of code between the start of the macro call and the unsafe block.
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.
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
fix #7979
changelog: Fix ICE on
undocumented_unsafe_blocks