-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Do not ICE when interpreting a cast between non-monomorphic types #108790
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. |
@@ -67,12 +67,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { | |||
} | |||
|
|||
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we just have a single one of these at the top of fn cast
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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