Repository navigation
ICE on stable in selection #89864
Description
Activity
syntacticsugarglider commented on Oct 13, 2021
If I had to guess, this is because in the non-codegen phase, we can't prove <<Dynamic<T> as WrapperTrait>::Assoc as Trait>::Assoc: fmt::Debug, because we're generic over T, but later on during codegen phase, we try to normalize that, see that there's only one applicable impl for WrapperTrait for Dynamic<T>, pick that, then find that ConcreteAssoc: Debug doesn't hold. But by this point we're "too late" and already doing codegen.
Seems like a very lazy-norm thing and this is all speculation.
#90891 changed the format_args expansion slightly so the example no longer ICEs, but it can still be reproduced by calling ArgumentV1::new manually
#![feature(fmt_internals)]
use core::{fmt, marker::PhantomData};
pub trait WrapperTrait {
type Assoc;
}
pub trait Trait {
type Assoc;
}
pub struct Ice<T>(<<Dynamic<T> as WrapperTrait>::Assoc as Trait>::Assoc);
fn ice<T>(i: Ice<T>)
where
<<Dynamic<T> as WrapperTrait>::Assoc as Trait>::Assoc: fmt::Debug,
{
fmt::ArgumentV1::new(&i.0, fmt::Debug::fmt);
}
pub struct TraitImplementor;
impl Trait for TraitImplementor {
type Assoc = ConcreteAssoc;
}
pub struct ConcreteAssoc;
impl<T> WrapperTrait for Dynamic<T> {
type Assoc = TraitImplementor;
}
pub struct Dynamic<T>(PhantomData<T>);Hmm... this is what I was worried about in the PR. This compiles now, but the trait bound ConcreteAssoc::Debug doesn't hold.
Is it an issue? The function ice is never called, so no code ever has to prove this bound.
oh 🤦 yea, I can't find a way to call it either. Thanks!
This is fixes and we have appropriate tests imo
Ran into an ICE on stable, threw together a quick minimization. There's probably a lot more room here for minimization but some other things I tried mostly wrt switching
Debug/format_args!out for something generic weren't immediately successful at reproducing it.Code
Meta
rustc --version --verbose:Error output
Backtrace