@@ -38,13 +38,13 @@ use std::rc::Rc;
38
38
/// more or less conservative.
39
39
#[ derive( Debug , Copy , Clone , PartialEq , Eq ) ]
40
40
pub enum ProjectionMode {
41
+ /// FIXME (#32205)
41
42
/// At coherence-checking time, we're still constructing the
42
43
/// specialization graph, and thus we only project project
43
44
/// non-`default` associated types that are defined directly in
44
45
/// the applicable impl. (This behavior should be improved over
45
46
/// time, to allow for successful projections modulo cycles
46
47
/// between different impls).
47
- // TODO: Add tracking issue to do better here.
48
48
///
49
49
/// Here's an example that will fail due to the restriction:
50
50
///
@@ -66,7 +66,6 @@ pub enum ProjectionMode {
66
66
///
67
67
/// The projection would succeed if `Output` had been defined
68
68
/// directly in the impl for `u8`.
69
- // TODO: Add test
70
69
Topmost ,
71
70
72
71
/// At type-checking time, we refuse to project any associated
@@ -91,7 +90,6 @@ pub enum ProjectionMode {
91
90
/// fn main() {
92
91
/// let <() as Assoc>::Output = true;
93
92
/// }
94
- // TODO: Add test
95
93
AnyFinal ,
96
94
97
95
/// At trans time, all projections will succeed.
@@ -695,7 +693,34 @@ fn project_type<'cx,'tcx>(
695
693
// at the topmost impl (we don't even consider the trait
696
694
// itself) for the definition -- so we can fail to find a
697
695
// 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.") ;
699
724
}
700
725
}
701
726
}
0 commit comments