diff options
| author | Oli Scherer <github333195615777966@oli-obk.de> | 2025-03-27 14:11:44 +0000 |
|---|---|---|
| committer | Oli Scherer <github333195615777966@oli-obk.de> | 2025-04-02 07:30:11 +0000 |
| commit | ca32447c0ccd38367ad1ff98c784f17f21d0e80e (patch) | |
| tree | 748f943e4cb104f7594193b1d6fc1f6c8a42fce0 /compiler/rustc_mir_transform/src | |
| parent | 51184c70c897619f6a2883538f8a85292306a0c8 (diff) | |
Only look at trait impls in the current crate when looking for `Drop` impls
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/check_const_item_mutation.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_mir_transform/src/check_const_item_mutation.rs b/compiler/rustc_mir_transform/src/check_const_item_mutation.rs index 76d1e671c5d..375db17fb73 100644 --- a/compiler/rustc_mir_transform/src/check_const_item_mutation.rs +++ b/compiler/rustc_mir_transform/src/check_const_item_mutation.rs @@ -53,9 +53,13 @@ impl<'tcx> ConstMutationChecker<'_, 'tcx> { // // #[const_mutation_allowed] // pub const LOG: Log = Log { msg: "" }; - match self.tcx.adt_destructor(def_id) { - Some(_) => None, - None => Some(def_id), + // FIXME: this should not be checking for `Drop` impls, + // but whether it or any field has a Drop impl (`needs_drop`) + // as fields' Drop impls may make this observable, too. + match self.tcx.type_of(def_id).skip_binder().ty_adt_def().map(|adt| adt.has_dtor(self.tcx)) + { + Some(true) => None, + Some(false) | None => Some(def_id), } } |
