Do not ICE when interpreting a cast between non-monomorphic types#108790
Do not ICE when interpreting a cast between non-monomorphic types#108790bors merged 2 commits intorust-lang:masterfrom
Conversation
|
(rustbot has picked a reviewer for you, use r? to override) |
|
Some changes occurred to the CTFE / Miri engine cc @rust-lang/miri |
|
Thank you so much for fixing this. It's been around for what feels like forever. |
|
|
||
| Pointer(PointerCast::ReifyFnPointer) => { | ||
| // All reifications must be monomorphic, bail out otherwise. | ||
| ensure_monomorphic_enough(*self.tcx, src.layout.ty)?; |
There was a problem hiding this comment.
Should we just have a single one of these at the top of fn cast?
There was a problem hiding this comment.
It's not necessarily wrong to cast partially polymorphic values, as long as the type parameters don't change the behaviour (layout / choice of unsize branch...). The checks up to this point are enough to make sure of this, without requiring monomorphic types.
There was a problem hiding this comment.
But the match on src.layout.ty.kind will ignore such leeway, so requires the type to be "monomorphic enough".
There was a problem hiding this comment.
The interpreter has no interest in supporting generic code. So IMO it'd make sense, and significantly simplify things, if we could do the check once at the top and then not think about the generic case any more -- rather than having to chase ICEs each time this code gets refactored.
Do not ICE when interpreting a cast between non-monomorphic types Fixes rust-lang#101596
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#107801 (const_eval: `implies_by` in `rustc_const_unstable`) - rust-lang#108750 (Fix `ObligationCtxt::sub`) - rust-lang#108780 (Add regression tests for issue 70919) - rust-lang#108786 (Check for free regions in MIR validation) - rust-lang#108790 (Do not ICE when interpreting a cast between non-monomorphic types) - rust-lang#108803 (Do not ICE when failing to normalize in ConstProp.) - rust-lang#108807 (Emit the suspicious_auto_trait_impls for negative impls as well) - rust-lang#108812 (Add regression test for rust-lang#98444) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Fixes #101596