Skip to content

Conversation

@dkcumming
Copy link
Collaborator

@dkcumming dkcumming commented Nov 18, 2025

The assert_inhabited intrinsic will (possibly) panic if a type in uninhabited (cannot be instantiated). E.g.

assert_inhabited<!>(); // panics (probably)
assert_inhabited<u8>(); // does nothing

Despite being an assert, panicking is not guaranteed and is dependent on the target and code generation - it is sound to perform a NO OP. Since calling the intrinsic comes from a TerminatorKind::Call, there must be a BasicBlock to go to after the call. However we observe that for assert_inhabited<!>() the execution continues to noBasicBlockIdx (which would get stuck). The semantics looks for this case and converts to #AssertInhabitedFailure, and otherwise performs a NO OP.

Copy link
Member

@jberthold jberthold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.
Too bad the iter() invocation still does not go through....

@automergerpr-permission-manager automergerpr-permission-manager bot merged commit 57345df into master Nov 18, 2025
12 of 14 checks passed
@automergerpr-permission-manager automergerpr-permission-manager bot deleted the dc/assert-inhabited branch November 18, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants