-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
nightly ICE when building flexstr in release mode #127030
Comments
this is stable and doesn't use effects, so it's probably different |
@Nilstrieb I'm going from #126889 (comment) |
I cannot reproduce this locally edit: oh |
Assigning @compiler-errors since he said he'd take a look at this after I figured out that this is a mess to fix. The tl;dr here is that pre-monomorphization we wind up trying to instance drop glue. The logic for creating drop glue should be able to assume that it is in a post-monomorphization state where using an empty The... good ish? bad? news ? is that we've been getting this wrong for much longer than my PR, my PR only surfaced this due to the fact that it relies on us providing the correct edit: I suspect the principled solution here is to have two codepaths (that share logic) for generating mir shims. One for instancing stuff post mono that behaves how monomorphization should be behaving and can use an empty |
To avoid breaking stuff when beta gets bumped to stable we probably want to try the following:
And then when that's done try to land the principled refactoring before the next beta cutoff |
Stall dropaStall computing instance for drop shim until it has no unsubstituted const params Stall resolving the drop shim instance for types that still have unsubstituted const params. ## Why? rust-lang#127030 ICEs because it tries to inline the drop shim for a type with an unsubstituted const param. In order to generate this shim, this requires calling the drop shim builder, which invokes the trait solver to compute whether constituent types need drop (since we compute if a type is copy to disqualify any `Drop` behavior): https://github.com/rust-lang/rust/blob/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/compiler/rustc_mir_dataflow/src/elaborate_drops.rs#L378 However, since we don't keep the param-env of the instance we resolved the item for, we use the wrong param-env: https://github.com/rust-lang/rust/blob/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/compiler/rustc_mir_transform/src/shim.rs#L278 (which is the param-env of `std::ptr::drop_in_place`) This param-env is notably missing `ConstParamHasTy` predicates, and since we removed the type from consts in rust-lang#125958, we literally cannot prove these predicates in this (relatively) empty param-env. This currently happens in places like the MIR inliner, but may happen elsewhere such as in lints that resolve terminators. ## What? We delay the resolution (`Instance::resolve`) of calls for `drop_in_place` for types that have unsubstituted const params. This should be OK, since all cases that deal with polymorphic code should handle `Instance::resolve` returning `None` gracefully.
Stall computing instance for drop shim until it has no unsubstituted const params Do not inline the drop shim for types that still have unsubstituted const params. ## Why? rust-lang#127030 ICEs because it tries to inline the drop shim for a type with an unsubstituted const param. In order to generate this shim, this requires calling the drop shim builder, which invokes the trait solver to compute whether constituent types need drop (since we compute if a type is copy to disqualify any `Drop` behavior): https://github.com/rust-lang/rust/blob/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/compiler/rustc_mir_dataflow/src/elaborate_drops.rs#L378 However, since we don't keep the param-env of the instance we resolved the item for, we use the wrong param-env: https://github.com/rust-lang/rust/blob/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/compiler/rustc_mir_transform/src/shim.rs#L278 (which is the param-env of `std::ptr::drop_in_place`) This param-env is notably missing `ConstParamHasTy` predicates, and since we removed the type from consts in rust-lang#125958, we literally cannot prove these predicates in this (relatively) empty param-env. This currently happens in places like the MIR inliner, but may happen elsewhere such as in lints that resolve terminators. ## What? We force the inliner to not consider calls for `drop_in_place` for types that have unsubstituted const params. ## So what? This may negatively affect MIR inlining, but I doubt this matters in practice, and fixes a beta regression, so let's fix it. I will look into approaches for fixing this in a more maintainable way, perhaps delaying the creation of drop shim bodies until codegen (like how intrinsics work).
Rollup merge of rust-lang#127068 - compiler-errors:stall-drop, r=BoxyUwU Stall computing instance for drop shim until it has no unsubstituted const params Do not inline the drop shim for types that still have unsubstituted const params. ## Why? rust-lang#127030 ICEs because it tries to inline the drop shim for a type with an unsubstituted const param. In order to generate this shim, this requires calling the drop shim builder, which invokes the trait solver to compute whether constituent types need drop (since we compute if a type is copy to disqualify any `Drop` behavior): https://github.com/rust-lang/rust/blob/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/compiler/rustc_mir_dataflow/src/elaborate_drops.rs#L378 However, since we don't keep the param-env of the instance we resolved the item for, we use the wrong param-env: https://github.com/rust-lang/rust/blob/9c3bc805dd9cb84019c124b9a50fdff1e62a7ec9/compiler/rustc_mir_transform/src/shim.rs#L278 (which is the param-env of `std::ptr::drop_in_place`) This param-env is notably missing `ConstParamHasTy` predicates, and since we removed the type from consts in rust-lang#125958, we literally cannot prove these predicates in this (relatively) empty param-env. This currently happens in places like the MIR inliner, but may happen elsewhere such as in lints that resolve terminators. ## What? We force the inliner to not consider calls for `drop_in_place` for types that have unsubstituted const params. ## So what? This may negatively affect MIR inlining, but I doubt this matters in practice, and fixes a beta regression, so let's fix it. I will look into approaches for fixing this in a more maintainable way, perhaps delaying the creation of drop shim bodies until codegen (like how intrinsics work).
This should be fixed on nightly, awaiting a beta backport |
This has been beta-backported, should show up next time a beta build is released on rustup (next day or so?) |
Repro steps:
I did not bisect, but
nightly-2024-04-15
does work just fineThe text was updated successfully, but these errors were encountered: