-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix ICE on invalid const param types #124394
Conversation
r? @Nadrieril rustbot has assigned @Nadrieril. Use |
I need help with this fix. It currently does not cater to the case when the feature rust/compiler/rustc_hir_analysis/src/check/wfcheck.rs Lines 938 to 954 in cb3752d
But we can't call WF from the location in this fix because that will lead to cycles (typeck -> type_of -> fix location -> wf -> typeck). @Nadrieril Can you please suggest a solution to this conundrum? |
I'm afraid I know very little about typeck. Let's see if someone else can help r? compiler |
please add the affected test to you PR |
i think the correct fix is to change rust/compiler/rustc_hir_analysis/src/collect.rs Lines 389 to 392 in 9adafa7
'static as is and not bug! there. Please try thatr
|
b5ef239
to
c62bc31
Compare
Thanks @lcnr. I've implemented your suggestion and it has fixed the ICE. |
@bors r+ rollup |
…iaskrgr Rollup of 7 pull requests Successful merges: - rust-lang#124370 (Fix substitution parts having a shifted underline in some cases) - rust-lang#124394 (Fix ICE on invalid const param types) - rust-lang#124425 (Do not ICE on invalid consts when walking mono-reachable blocks) - rust-lang#124434 (Remove lazycell and once_cell from compiletest dependencies) - rust-lang#124437 (doc: Make the `mod.rs` in the comment point to the correct location) - rust-lang#124443 (Elaborate in comment about `statx` probe) - rust-lang#124445 (bootstrap: Change `global(true)` to `global = true` for flags for consistency) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#124394 - gurry:123863-ice-unexpected-region, r=lcnr Fix ICE on invalid const param types Fixes ICE rust-lang#123863 which occurs because the const param has a type which is not a `bool`, `char` or an integral type. The ICEing code path begins here in `typeck_with_fallback`: https://github.com/rust-lang/rust/blob/cb3752d20e0f5d24348062211102a08d46fbecff/compiler/rustc_hir_typeck/src/lib.rs#L167 The `fallback` invokes the `type_of` query and that eventually ends up calling `ct_infer` from the lowering code over here: https://github.com/rust-lang/rust/blob/cb3752d20e0f5d24348062211102a08d46fbecff/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs#L561 and `ct_infer` ICEs at this location: https://github.com/rust-lang/rust/blob/cb3752d20e0f5d24348062211102a08d46fbecff/compiler/rustc_hir_analysis/src/collect.rs#L392 To fix the ICE it I'm triggering a `span_delayed_bug` before we hit `ct_infer` if the type of the const param is not one of the supported types ### Edit On `@lcnr's` suggestion I've changed the approach to not let `ReStatic` region hit the `bug!` in `ct_infer` instead of triggering a `span_delayed_bug`.
Fixes ICE #123863 which occurs because the const param has a type which is not a
bool
,char
or an integral type.The ICEing code path begins here in
typeck_with_fallback
:rust/compiler/rustc_hir_typeck/src/lib.rs
Line 167 in cb3752d
The
fallback
invokes thetype_of
query and that eventually ends up callingct_infer
from the lowering code over here:rust/compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Line 561 in cb3752d
ct_infer
ICEs at this location:rust/compiler/rustc_hir_analysis/src/collect.rs
Line 392 in cb3752d
To fix the ICE it I'm triggering a
span_delayed_bug
before we hitct_infer
if the type of the const param is not one of the supported typesEdit
On @lcnr's suggestion I've changed the approach to not let
ReStatic
region hit thebug!
inct_infer
instead of triggering aspan_delayed_bug
.