@@ -38,13 +38,13 @@ use std::rc::Rc;
3838/// more or less conservative.
3939#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
4040pub enum ProjectionMode {
41+ /// FIXME (#32205)
4142 /// At coherence-checking time, we're still constructing the
4243 /// specialization graph, and thus we only project project
4344 /// non-`default` associated types that are defined directly in
4445 /// the applicable impl. (This behavior should be improved over
4546 /// time, to allow for successful projections modulo cycles
4647 /// between different impls).
47- // TODO: Add tracking issue to do better here.
4848 ///
4949 /// Here's an example that will fail due to the restriction:
5050 ///
@@ -66,7 +66,6 @@ pub enum ProjectionMode {
6666 ///
6767 /// The projection would succeed if `Output` had been defined
6868 /// directly in the impl for `u8`.
69- // TODO: Add test
7069 Topmost ,
7170
7271 /// At type-checking time, we refuse to project any associated
@@ -91,7 +90,6 @@ pub enum ProjectionMode {
9190 /// fn main() {
9291 /// let <() as Assoc>::Output = true;
9392 /// }
94- // TODO: Add test
9593 AnyFinal ,
9694
9795 /// At trans time, all projections will succeed.
@@ -695,7 +693,34 @@ fn project_type<'cx,'tcx>(
695693 // at the topmost impl (we don't even consider the trait
696694 // itself) for the definition -- so we can fail to find a
697695 // definition of the type even if it exists.
698- return None ;
696+
697+ // For now, we just unconditionally ICE, because otherwise,
698+ // examples like the following will succeed:
699+ //
700+ // ```
701+ // trait Assoc {
702+ // type Output;
703+ // }
704+ //
705+ // impl<T> Assoc for T {
706+ // default type Output = bool;
707+ // }
708+ //
709+ // impl Assoc for u8 {}
710+ // impl Assoc for u16 {}
711+ //
712+ // trait Foo {}
713+ // impl Foo for <u8 as Assoc>::Output {}
714+ // impl Foo for <u16 as Assoc>::Output {}
715+ // return None;
716+ // }
717+ // ```
718+ //
719+ // The essential problem here is that the projection fails,
720+ // leaving two unnormalized types, which appear not to unify
721+ // -- so the overlap check succeeds, when it should fail.
722+ selcx. tcx ( ) . sess . bug ( "Tried to project an inherited associated type during \
723+ coherence checking, which is currently not supported.") ;
699724 }
700725 }
701726 }
0 commit comments