File tree Expand file tree Collapse file tree 3 files changed +30
-14
lines changed
compiler/rustc_middle/src/ty Expand file tree Collapse file tree 3 files changed +30
-14
lines changed Original file line number Diff line number Diff line change @@ -1368,7 +1368,6 @@ impl<'tcx> Ty<'tcx> {
13681368 /// 2229 drop reorder migration analysis.
13691369 #[ inline]
13701370 pub fn has_significant_drop ( self , tcx : TyCtxt < ' tcx > , typing_env : ty:: TypingEnv < ' tcx > ) -> bool {
1371- assert ! ( !self . has_non_region_infer( ) ) ;
13721371 // Avoid querying in simple cases.
13731372 match needs_drop_components ( tcx, self ) {
13741373 Err ( AlwaysRequiresDrop ) => true ,
@@ -1381,6 +1380,16 @@ impl<'tcx> Ty<'tcx> {
13811380 _ => self ,
13821381 } ;
13831382
1383+ // FIXME
1384+ // We should be canonicalizing, or else moving this to a method of inference
1385+ // context, or *something* like that,
1386+ // but for now just avoid passing inference variables
1387+ // to queries that can't cope with them.
1388+ // Instead, conservatively return "true" (may change drop order).
1389+ if query_ty. has_infer ( ) {
1390+ return true ;
1391+ }
1392+
13841393 // This doesn't depend on regions, so try to minimize distinct
13851394 // query keys used.
13861395 let erased = tcx. normalize_erasing_regions ( typing_env, query_ty) ;
Original file line number Diff line number Diff line change 1- //@ run-pass
1+ //@ should-fail
22// Inference, canonicalization, and significant drops should work nicely together.
33// Related issue: #86868
44
5- #[ clippy:: has_significant_drop]
6- struct DropGuy { }
7-
8- fn creator ( ) -> DropGuy {
9- DropGuy { }
10- }
11-
12- fn dropper ( ) {
13- let _ = creator ( ) ;
14- }
15-
165fn main ( ) {
17- dropper ( ) ;
6+ let mut state = 0 ;
7+ Box :: new ( move || state)
188}
Original file line number Diff line number Diff line change 1+ error[E0308]: mismatched types
2+ --> $DIR/has_sigdrop.rs:7:5
3+ |
4+ LL | fn main() {
5+ | - expected `()` because of default return type
6+ LL | let mut state = 0;
7+ LL | Box::new(move || state)
8+ | ^^^^^^^^^^^^^^^^^^^^^^^- help: consider using a semicolon here: `;`
9+ | |
10+ | expected `()`, found `Box<{closure@has_sigdrop.rs:7:14}>`
11+ |
12+ = note: expected unit type `()`
13+ found struct `Box<{closure@$DIR/has_sigdrop.rs:7:14: 7:21}>`
14+
15+ error: aborting due to 1 previous error
16+
17+ For more information about this error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments