Rollup merge of #89988 - tmiasko:unpromote-const-drop, r=oli-obk
Do not promote values with const drop that need to be dropped Changes from #88558 allowed using `~const Drop` in constants by introducing a new `NeedsNonConstDrop` qualif. The new qualif was also used for promotion purposes, and allowed promotion to happen for values that needs to be dropped but which do have a const drop impl. Since for promoted the drop implementation is never executed, this lead to observable change in behaviour. For example: ```rust struct Panic(); impl const Drop for Panic { fn drop(&mut self) { panic!(); } } fn main() { let _ = &Panic(); } ``` Restore the use of `NeedsDrop` qualif during promotion to avoid the issue.
This commit is contained in:
commit
a0724d72b0
7 changed files with 108 additions and 16 deletions
|
@ -225,6 +225,7 @@ pub struct BorrowCheckResult<'tcx> {
|
|||
pub struct ConstQualifs {
|
||||
pub has_mut_interior: bool,
|
||||
pub needs_drop: bool,
|
||||
pub needs_non_const_drop: bool,
|
||||
pub custom_eq: bool,
|
||||
pub error_occured: Option<ErrorReported>,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue