about summary refs log tree commit diff
path: root/compiler
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-04-04 08:02:09 +0200
committerGitHub <noreply@github.com>2025-04-04 08:02:09 +0200
commit0a9eae161b1aa6097a0f02b6ad8dea48ae534e30 (patch)
tree8264a55affa9c6b2ac95a3df54f8200bd11051f6 /compiler
parent0c4ac89760894dea1db9e76c26abfd1c68b57e27 (diff)
parenta14e8f687c2f274548a20e01231b706d3c88790c (diff)
downloadrust-0a9eae161b1aa6097a0f02b6ad8dea48ae534e30.tar.gz
rust-0a9eae161b1aa6097a0f02b6ad8dea48ae534e30.zip
Rollup merge of #139349 - meithecatte:destructor-constness, r=compiler-errors
adt_destructor: sanity-check returned item

Fixes #139278
Diffstat (limited to 'compiler')
-rw-r--r--compiler/rustc_middle/src/ty/util.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs
index 7743e202aae..bebbe17d518 100644
--- a/compiler/rustc_middle/src/ty/util.rs
+++ b/compiler/rustc_middle/src/ty/util.rs
@@ -414,6 +414,11 @@ impl<'tcx> TyCtxt<'tcx> {
                 continue;
             };
 
+            if self.def_kind(item_id) != DefKind::AssocFn {
+                self.dcx().span_delayed_bug(self.def_span(item_id), "drop is not a function");
+                continue;
+            }
+
             if let Some(old_item_id) = dtor_candidate {
                 self.dcx()
                     .struct_span_err(self.def_span(item_id), "multiple drop impls found")