Don't call mir_const_qualif on functions without const bodies#153900
Don't call mir_const_qualif on functions without const bodies#153900ViewWay wants to merge 1 commit intorust-lang:mainfrom
Conversation
|
r? @jackh726 rustbot has assigned @jackh726. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
For the love of god, please drop your cherry-pick of the commit I authored in open PR RUST-153738. It makes no sense whatsoever to take ownership of it & to include it here and in your ~5 other PRs. Your PRs can't proceed otherwise.
|
Reminder, once the PR becomes ready for a review, use |
The issue occurred when mir_promoted checked tcx.constness(def) for functions/closures, which returns Constness::Const for trait methods in const traits even when they don't have an actual const body. The fix uses tcx.hir_body_const_context(def).is_some() instead, which correctly returns None for functions that don't have a const body to check. This matches what mir_const_qualif itself uses internally (ConstCx::new calls hir_body_const_context), ensuring we only call mir_const_qualif when it won't ICE.
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
|
The job Click to see the possible cause of the failure (guessed by this bot) |
Fixes #153891.
When
mir_promotedcheckedtcx.constness(def)for functions/closures, it returnedConstness::Constfor trait methods in const traits even when they don't have an actual const body.The fix uses
tcx.hir_body_const_context(def).is_some()instead, which correctly returnsNonefor functions that don't have a const body to check. This matches whatmir_const_qualifitself uses internally (ConstCx::newcallshir_body_const_context), ensuring we only callmir_const_qualifwhen it won't ICE.