about summary refs log tree commit diff
diff options
context:
space:
mode:
authorash <ashkernel02@gmail.com>2025-09-15 13:55:20 -0600
committerash <ashkernel02@gmail.com>2025-09-15 13:55:20 -0600
commitfa7e474f9ca755ac102debcf6cd0ce77313ee0bf (patch)
treebffdf4e8bb76094627ccdffc0d60d4cc660abf9c
parentf3fd3efe4f698ad9dc2ccd6b46a3b07e1bc911da (diff)
downloadrust-fa7e474f9ca755ac102debcf6cd0ce77313ee0bf.tar.gz
rust-fa7e474f9ca755ac102debcf6cd0ce77313ee0bf.zip
remove FIXME from `has_significant_drop`, replaced with checking non_region_infer
-rw-r--r--compiler/rustc_middle/src/ty/util.rs9
-rw-r--r--tests/ui/type-inference/has_sigdrop.rs18
2 files changed, 19 insertions, 8 deletions
diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs
index 029586a9c55..b79b67c5927 100644
--- a/compiler/rustc_middle/src/ty/util.rs
+++ b/compiler/rustc_middle/src/ty/util.rs
@@ -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,
@@ -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);
diff --git a/tests/ui/type-inference/has_sigdrop.rs b/tests/ui/type-inference/has_sigdrop.rs
new file mode 100644
index 00000000000..c3d835cfe16
--- /dev/null
+++ b/tests/ui/type-inference/has_sigdrop.rs
@@ -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();
+}