-
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
Miri/CTFE fails when const generic is used as value #62790
Comments
@eddyb asks what pub(super) fn monomorphize<T: TypeFoldable<'tcx> + Subst<'tcx>>(
&self,
t: T,
) -> InterpResult<'tcx, T> {
match self.stack.last() {
Some(frame) => Ok(self.monomorphize_with_substs(t, frame.instance.substs)?),
None => if t.needs_subst() {
err!(TooGeneric).into()
} else {
Ok(t)
},
}
}
fn monomorphize_with_substs<T: TypeFoldable<'tcx> + Subst<'tcx>>(
&self,
t: T,
substs: SubstsRef<'tcx>
) -> InterpResult<'tcx, T> {
// miri doesn't care about lifetimes, and will choke on some crazy ones
// let's simply get rid of them
let substituted = t.subst(*self.tcx, substs);
if substituted.needs_subst() {
return err!(TooGeneric);
}
Ok(self.tcx.normalize_erasing_regions(ty::ParamEnv::reveal_all(), substituted))
} Note that the ICE is somewhere in |
@oli-obk do you know why the |
But none of those call the By identity substs I mean the |
It looks like const-prop is doing that, though: rust/src/librustc_mir/transform/const_prop.rs Lines 168 to 176 in fe499a7
|
That's super weird then. It's possible the offending situation propagates from earlier or something. |
@eddyb last night came to the conclusion that this line is a problem:
Specifically, |
Fixed by #63497. |
test arrray try_from (interesting const generic usage) Currently fails, see rust-lang/rust#62435 (comment). Blocked on rust-lang/rust#62790.
Miri/CTFE fails to execute code where a const generic parameter is used as a value, such as what
try_from
for arrays does these days:yields
The "obvious" fix seems to be to call
monomorphize
on the const before evaluating it; i did that in RalfJung@a8754d4d33. However, that ICEs:ICE backtrace
The backtrace shows that it is the first
monomorphize
ineval_const_to_op
that fails. The backtrace also involves const-prop -- of course it does, there is hardly any ICE for the Miri engine that does not.@eddyb says
I am not sure what this means.^^ @oli-obk does this help to find the ICE that currently prevents supporting const-generics? It's something in const-prop again. :/
The text was updated successfully, but these errors were encountered: