Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions compiler/rustc_middle/src/ty/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1359,6 +1359,7 @@ impl<'tcx> Ty<'tcx> {
/// 2229 drop reorder migration analysis.
#[inline]
pub fn has_significant_drop(self, tcx: TyCtxt<'tcx>, typing_env: ty::TypingEnv<'tcx>) -> bool {
assert!(!self.has_non_region_infer());
// Avoid querying in simple cases.
match needs_drop_components(tcx, self) {
Err(AlwaysRequiresDrop) => true,
Expand All @@ -1371,14 +1372,6 @@ impl<'tcx> Ty<'tcx> {
_ => self,
};

// FIXME(#86868): We should be canonicalizing, or else moving this to a method of inference
// context, or *something* like that, but for now just avoid passing inference
// variables to queries that can't cope with them. Instead, conservatively
// return "true" (may change drop order).
if query_ty.has_infer() {
return true;
}

// This doesn't depend on regions, so try to minimize distinct
// query keys used.
let erased = tcx.normalize_erasing_regions(typing_env, query_ty);
Expand Down
18 changes: 18 additions & 0 deletions tests/ui/type-inference/has_sigdrop.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//@ run-pass
// Inference, canonicalization, and significant drops should work nicely together.
// Related issue: #86868

#[clippy::has_significant_drop]
struct DropGuy {}

fn creator() -> DropGuy {
DropGuy {}
}

fn dropper() {
let _ = creator();
}

fn main() {
dropper();
}
Loading