Skip to content

Commit e652d73

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 e652d73

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
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);

tests/ui/type-inference/has_sigdrop.rs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,7 @@
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-
165
fn main() {
17-
dropper();
6+
let mut state = 0;
7+
Box::new(move || state)
188
}

0 commit comments

Comments
 (0)