-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
ICE: An unexpected panic occurs when const function containing panic!("")
drops a value with const_precise_live_drops
.
#89938
Comments
🤦 ok yea, I can totally see how we got here. Const checking used to happen before promotion, but const_precise_live_drops is happening after, but re-uses const checking machinery. I think we can safely change https://github.com/rust-lang/rust/blob/master/compiler/rustc_const_eval/src/transform/check_consts/qualifs.rs#L292-L294 to return My reasoning for that is that in order for a promoted to have been created, it must already be
and it can't be part of a pattern either, so we don't care about non-derived PartialEq impls. cc @rust-lang/wg-const-eval |
Is this also true for promoteds inside const/static bodies, which can call arbitrary const fn? |
hmm good point, there may be a non-const drop value in a promoted there. But... using |
The promoted is a |
Vec::new is const fn and not const drop |
But AFAIK it is also not promoted even in const/static bodies? |
Sorry, I misread your comment. You were saying this specific issue is for a promoted in a We need to check whether, with precise drops, we can end up with promoteds that are problematic, as we delayed some of the drop checks. I don't think we delay the drop checks for promotion, so we should be good on that end. All other const checks are guaranteed to happen before promotion, so we can ignore them here. If we want to make this all explicit, we could add an in_promoted function to Qualif and have all other qualifs keep panicking. |
Wait, we are promoting things and then checking if that was a good idea? That doesn't work, as it could lead to compile errors in code that would have been fine had we not promoted. |
We aren't. Or... we shouldn't. But we need to make sure before we can enable precise drops |
That sounds good to me. We can also fallback to type-based reasoning, after all promoted are references, so they don't need drop. |
Ralf is right, we should never have to look into promoteds, they must be correctly constructed or not at all. So we don't need an |
FWIW, that's how I understood your earlier proposal, with |
Yea, either const or fn is fine, it just seems like a function sends the wrong message, as it could mean you could actually add logic in it |
…i-obk Fix const qualification when executed after promotion The const qualification was so far performed before the promotion and the implementation assumed that it will never encounter a promoted. With `const_precise_live_drops` feature, checking for live drops is delayed until after drop elaboration, which in turn runs after promotion. so the assumption is no longer true. When evaluating `NeedsNonConstDrop` it is now possible to encounter promoteds. Use type base qualification for the promoted. It is a sound approximation in general, and in the specific case of promoteds and `NeedsNonConstDrop` it is precise. Fixes rust-lang#89938.
…i-obk Fix const qualification when executed after promotion The const qualification was so far performed before the promotion and the implementation assumed that it will never encounter a promoted. With `const_precise_live_drops` feature, checking for live drops is delayed until after drop elaboration, which in turn runs after promotion. so the assumption is no longer true. When evaluating `NeedsNonConstDrop` it is now possible to encounter promoteds. Use type base qualification for the promoted. It is a sound approximation in general, and in the specific case of promoteds and `NeedsNonConstDrop` it is precise. Fixes rust-lang#89938.
…i-obk Fix const qualification when executed after promotion The const qualification was so far performed before the promotion and the implementation assumed that it will never encounter a promoted. With `const_precise_live_drops` feature, checking for live drops is delayed until after drop elaboration, which in turn runs after promotion. so the assumption is no longer true. When evaluating `NeedsNonConstDrop` it is now possible to encounter promoteds. Use type base qualification for the promoted. It is a sound approximation in general, and in the specific case of promoteds and `NeedsNonConstDrop` it is precise. Fixes rust-lang#89938.
…i-obk Fix const qualification when executed after promotion The const qualification was so far performed before the promotion and the implementation assumed that it will never encounter a promoted. With `const_precise_live_drops` feature, checking for live drops is delayed until after drop elaboration, which in turn runs after promotion. so the assumption is no longer true. When evaluating `NeedsNonConstDrop` it is now possible to encounter promoteds. Use type base qualification for the promoted. It is a sound approximation in general, and in the specific case of promoteds and `NeedsNonConstDrop` it is precise. Fixes rust-lang#89938.
This only occur in
--edition=2021
.Code
playground
Meta
rustc --version --verbose
:Error output
Backtrace
The text was updated successfully, but these errors were encountered: