@@ -22,7 +22,7 @@ use std::mem;
22
22
use std:: ops:: { ControlFlow , Deref } ;
23
23
24
24
use super :: ops:: { self , NonConstOp , Status } ;
25
- use super :: qualifs:: { self , CustomEq , HasMutInterior , NeedsDrop } ;
25
+ use super :: qualifs:: { self , CustomEq , HasMutInterior , NeedsDrop , NeedsNonConstDrop } ;
26
26
use super :: resolver:: FlowSensitiveAnalysis ;
27
27
use super :: { ConstCx , Qualif } ;
28
28
use crate :: const_eval:: is_unstable_const_fn;
@@ -35,7 +35,7 @@ type QualifResults<'mir, 'tcx, Q> =
35
35
pub struct Qualifs < ' mir , ' tcx > {
36
36
has_mut_interior : Option < QualifResults < ' mir , ' tcx , HasMutInterior > > ,
37
37
needs_drop : Option < QualifResults < ' mir , ' tcx , NeedsDrop > > ,
38
- // needs_non_const_drop: Option<QualifResults<'mir, 'tcx, NeedsNonConstDrop>>,
38
+ needs_non_const_drop : Option < QualifResults < ' mir , ' tcx , NeedsNonConstDrop > > ,
39
39
}
40
40
41
41
impl < ' mir , ' tcx > Qualifs < ' mir , ' tcx > {
@@ -78,27 +78,25 @@ impl<'mir, 'tcx> Qualifs<'mir, 'tcx> {
78
78
local : Local ,
79
79
location : Location ,
80
80
) -> bool {
81
- // FIXME(effects) replace with `NeedsNonconstDrop` after const traits work again
82
- /*
83
81
let ty = ccx. body . local_decls [ local] . ty ;
84
- if !NeedsDrop::in_any_value_of_ty(ccx, ty) {
82
+ // Peeking into opaque types causes cycles if the current function declares said opaque
83
+ // type. Thus we avoid short circuiting on the type and instead run the more expensive
84
+ // analysis that looks at the actual usage within this function
85
+ if !ty. has_opaque_types ( ) && !NeedsNonConstDrop :: in_any_value_of_ty ( ccx, ty) {
85
86
return false ;
86
87
}
87
88
88
89
let needs_non_const_drop = self . needs_non_const_drop . get_or_insert_with ( || {
89
90
let ConstCx { tcx, body, .. } = * ccx;
90
91
91
- FlowSensitiveAnalysis::new(NeedsDrop , ccx)
92
- .into_engine(tcx, & body)
92
+ FlowSensitiveAnalysis :: new ( NeedsNonConstDrop , ccx)
93
+ . into_engine ( tcx, body)
93
94
. iterate_to_fixpoint ( )
94
- .into_results_cursor(& body)
95
+ . into_results_cursor ( body)
95
96
} ) ;
96
97
97
98
needs_non_const_drop. seek_before_primary_effect ( location) ;
98
99
needs_non_const_drop. get ( ) . contains ( local)
99
- */
100
-
101
- self . needs_drop ( ccx, local, location)
102
100
}
103
101
104
102
/// Returns `true` if `local` is `HasMutInterior` at the given `Location`.
@@ -1013,9 +1011,8 @@ impl<'tcx> Visitor<'tcx> for Checker<'_, 'tcx> {
1013
1011
let mut err_span = self . span ;
1014
1012
let ty_of_dropped_place = dropped_place. ty ( self . body , self . tcx ) . ty ;
1015
1013
1016
- // FIXME(effects) replace with `NeedsNonConstDrop` once we fix const traits
1017
1014
let ty_needs_non_const_drop =
1018
- qualifs:: NeedsDrop :: in_any_value_of_ty ( self . ccx , ty_of_dropped_place) ;
1015
+ qualifs:: NeedsNonConstDrop :: in_any_value_of_ty ( self . ccx , ty_of_dropped_place) ;
1019
1016
1020
1017
debug ! ( ?ty_of_dropped_place, ?ty_needs_non_const_drop) ;
1021
1018
0 commit comments