Skip to content

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

Merged
merged 1 commit into from
Aug 8, 2024

Conversation

Jarcho
Copy link
Contributor

@Jarcho Jarcho commented Aug 7, 2024

changelog: none

…in `LateContext` to avoid walking the HIR tree.
@rustbot
Copy link
Collaborator

rustbot commented Aug 7, 2024

r? @Alexendoo

rustbot has assigned @Alexendoo.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Aug 7, 2024
/// `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");
Copy link
Member

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?

Copy link
Contributor Author

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.

@Alexendoo
Copy link
Member

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Aug 8, 2024

📌 Commit 16633a2 has been approved by Alexendoo

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Aug 8, 2024

⌛ Testing commit 16633a2 with merge ffc391c...

@bors
Copy link
Contributor

bors commented Aug 8, 2024

☀️ Test successful - checks-action_dev_test, checks-action_remark_test, checks-action_test
Approved by: Alexendoo
Pushing ffc391c to master...

@bors bors merged commit ffc391c into rust-lang:master Aug 8, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants