Don't eagerly monomorphize drop for types that are impossible to instantiate

This commit is contained in:
Michael Goulet 2024-05-24 15:17:34 -04:00
parent 36153f1a4e
commit 045f448e26
2 changed files with 27 additions and 0 deletions

View file

@ -1434,6 +1434,15 @@ impl<'v> RootCollector<'_, 'v> {
{
debug!("RootCollector: ADT drop-glue for `{id:?}`",);
// This type is impossible to instantiate, so we should not try to
// generate a `drop_in_place` instance for it.
if self.tcx.instantiate_and_check_impossible_predicates((
id.owner_id.to_def_id(),
ty::List::empty(),
)) {
return;
}
let ty = self.tcx.type_of(id.owner_id.to_def_id()).no_bound_vars().unwrap();
visit_drop_use(self.tcx, ty, true, DUMMY_SP, self.output);
}