-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Don't walk the HIR tree when checking for a const context #13231
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
Conversation
…in `LateContext` to avoid walking the HIR tree.
r? @Alexendoo rustbot has assigned @Alexendoo. Use |
/// `check_pat` and a few other entry points will always have an enclosing body. Some entry points | ||
/// like `check_path` or `check_ty` may or may not have one. | ||
pub fn is_in_const_context(cx: &LateContext<'_>) -> bool { | ||
debug_assert!(cx.enclosing_body.is_some(), "`LateContext` has no enclosing body"); |
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.
Why panic here, is there some case where it would return false
incorrectly?
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.
No, but calling it from something like check_item
is almost certainly a bug. missing_panics_doc
, for example, checks for a const context from within a visitor started in check_*_item
. It would be easy to use the wrong function in this case and the ICE makes this easier to debug.
Thanks! @bors r+ |
☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test |
changelog: none