Only look at trait impls in the current crate when looking for Drop impls

This commit is contained in:
Oli Scherer 2025-03-27 14:11:44 +00:00
parent 51184c70c8
commit ca32447c0c
3 changed files with 30 additions and 18 deletions

View file

@ -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),
}
}