Skip to content

Commit 60b3563

Browse files
committed
revert change removing has_infer check. Commit conservatively patches for now, but more development proceeding. Also contains a more concise test
1 parent 6710835 commit 60b3563

File tree

4 files changed

+36
-1
lines changed

4 files changed

+36
-1
lines changed

compiler/rustc_middle/src/ty/util.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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);
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//@ should-fail
2+
//@ compile-flags: -Wrust-2021-incompatible-closure-captures
3+
// Inference, canonicalization, and significant drops should work nicely together.
4+
// Related issue: #86868
5+
6+
fn main() {
7+
let mut state = 0;
8+
Box::new(move || state)
9+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
error[E0308]: mismatched types
2+
--> $DIR/box_has_sigdrop.rs:8: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@box_has_sigdrop.rs:8:14}>`
11+
|
12+
= note: expected unit type `()`
13+
found struct `Box<{closure@$DIR/box_has_sigdrop.rs:8:14: 8:21}>`
14+
15+
error: aborting due to 1 previous error
16+
17+
For more information about this error, try `rustc --explain E0308`.
File renamed without changes.

0 commit comments

Comments
 (0)