Conversation
|
r? @oli-obk rustbot has assigned @oli-obk. Use Why was this reviewer chosen?The reviewer was selected based on:
|
| /// | ||
| /// We already emit errors for the case where the impossible bound exists only on the self ty, or | ||
| /// only on the impl(s). | ||
| pub(crate) fn is_impossible_self_ty(tcx: TyCtxt<'_>, adt_did: LocalDefId) -> bool { |
There was a problem hiding this comment.
I basically lifted this logic wholesale from the is_impossible_associated_item query, though I couldn't really find a nice way to make them into a single shared thing, since is_impossible_associated_item filters the obligations to those that only mention the parent item's generics before registering them with the ocx.
This comment has been minimized.
This comment has been minimized.
a624c3c to
cd2a97d
Compare
|
This PR changes a file inside |
|
#150387 may keep existing. Can it be reproed with just specialization and no impossible bounds? |
If we have multiple drop impls and a self ty that all have the same impossible bounds, we end up with duplicate
drops with differentDefIds, which causes us to ICE with a delayed bug incalculate_dtor. Coherence accepts these impls since they have impossible bounds, and nothing else incheck_drop_implchecks this, leading to us accepting the code and subsequently ICEing from the delayed bug.We now skip considering the current drop impl as a dtor candidate if the self ty and impl(s) have the same impossible bounds, since if the self ty is unnameable, it's impossible to construct an instance in the first place. Checking only the self ty is sufficient here, as
check_drop_implchecks the case where the impossible bounds exist only on the drop impl, and we're not allowed in general to have a struct whose bounds are more restrictive than its impl's, so the only case we're currently missing is the case where the self ty and theDropimpls have the exact same impossible bounds.My reasoning for accepting such code instead of emitting an error is that, in general, we allow users to write code with impossible or trivial bounds, so long as they never try to actually name or run that code. This PR makes
Dropbehave the same way.This results in overlapping impossible drop impls behaving like other traits: for instance, the following compiles on nightly today:
Although this ICE only seems to be reachable for sync drop, not making the same change for async drop makes the following program, which currently compiles on nightly, stop compiling:
which feels like something we don't want.
cc #159118 (comment)
fixes #153947
fixes #150387