rust icon indicating copy to clipboard operation
rust copied to clipboard

Fix ICE while casting a type with error

Open gurry opened this issue 1 month ago • 3 comments

Fixes #124848

The ICE originates here: https://github.com/rust-lang/rust/blob/f9a3fd966162b3c7386d90fe4626471f66ba3b8f/compiler/rustc_hir_typeck/src/cast.rs#L143 The underlying cause is that a type with error, MyType was involved in a cast. During cast checks the below method pointer_kind was called: https://github.com/rust-lang/rust/blob/f9a3fd966162b3c7386d90fe4626471f66ba3b8f/compiler/rustc_hir_typeck/src/cast.rs#L87-L91 Thanks to the changes in PR #123491, type_is_sized_modulo_regions in pointer_kind returned false which caused control to reach the span_bug here: https://github.com/rust-lang/rust/blob/f9a3fd966162b3c7386d90fe4626471f66ba3b8f/compiler/rustc_hir_typeck/src/cast.rs#L143 resulting in an ICE.

This PR fixes the issue by changing the span_bug to a span_delayed_bug.

gurry avatar May 11 '24 03:05 gurry

r? @Nadrieril

rustbot has assigned @Nadrieril. They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

rustbot avatar May 11 '24 03:05 rustbot

@bors r+

Nadrieril avatar May 13 '24 22:05 Nadrieril

:pushpin: Commit fb619ec208b898bad1505c97ee79408b2c60926b has been approved by Nadrieril

It is now in the queue for this repository.

bors avatar May 13 '24 22:05 bors