File tree 3 files changed +55
-1
lines changed
compiler/rustc_trait_selection/src/solve
tests/ui/traits/new-solver
3 files changed +55
-1
lines changed Original file line number Diff line number Diff line change @@ -244,7 +244,21 @@ impl<'tcx> assembly::GoalKind<'tcx> for ProjectionPredicate<'tcx> {
244
244
// Finally we construct the actual value of the associated type.
245
245
let term = match assoc_def. item . kind {
246
246
ty:: AssocKind :: Type => tcx. type_of ( assoc_def. item . def_id ) . map_bound ( |ty| ty. into ( ) ) ,
247
- ty:: AssocKind :: Const => bug ! ( "associated const projection is not supported yet" ) ,
247
+ ty:: AssocKind :: Const => {
248
+ if tcx. features ( ) . associated_const_equality {
249
+ bug ! ( "associated const projection is not supported yet" )
250
+ } else {
251
+ ty:: EarlyBinder :: bind (
252
+ ty:: Const :: new_error_with_message (
253
+ tcx,
254
+ tcx. type_of ( assoc_def. item . def_id ) . instantiate_identity ( ) ,
255
+ DUMMY_SP ,
256
+ "associated const projection is not supported yet" ,
257
+ )
258
+ . into ( ) ,
259
+ )
260
+ }
261
+ }
248
262
ty:: AssocKind :: Fn => unreachable ! ( "we should never project to a fn" ) ,
249
263
} ;
250
264
Original file line number Diff line number Diff line change
1
+ // compile-flags: -Ztrait-solver=next-coherence
2
+
3
+ // Makes sure we don't ICE on associated const projection when the feature gate
4
+ // is not enabled, since we should avoid encountering ICEs on stable if possible.
5
+
6
+ trait Bar {
7
+ const ASSOC : usize ;
8
+ }
9
+ impl Bar for ( ) {
10
+ const ASSOC : usize = 1 ;
11
+ }
12
+
13
+ trait Foo { }
14
+ impl Foo for ( ) { }
15
+ impl < T > Foo for T where T : Bar < ASSOC = 0 > { }
16
+ //~^ ERROR associated const equality is incomplete
17
+ //~| ERROR conflicting implementations of trait `Foo` for type `()`
18
+
19
+ fn main ( ) { }
Original file line number Diff line number Diff line change
1
+ error[E0658]: associated const equality is incomplete
2
+ --> $DIR/dont-ice-on-assoc-projection.rs:15:32
3
+ |
4
+ LL | impl<T> Foo for T where T: Bar<ASSOC = 0> {}
5
+ | ^^^^^^^^^
6
+ |
7
+ = note: see issue #92827 <https://github.com/rust-lang/rust/issues/92827> for more information
8
+ = help: add `#![feature(associated_const_equality)]` to the crate attributes to enable
9
+
10
+ error[E0119]: conflicting implementations of trait `Foo` for type `()`
11
+ --> $DIR/dont-ice-on-assoc-projection.rs:15:1
12
+ |
13
+ LL | impl Foo for () {}
14
+ | --------------- first implementation here
15
+ LL | impl<T> Foo for T where T: Bar<ASSOC = 0> {}
16
+ | ^^^^^^^^^^^^^^^^^ conflicting implementation for `()`
17
+
18
+ error: aborting due to 2 previous errors
19
+
20
+ Some errors have detailed explanations: E0119, E0658.
21
+ For more information about an error, try `rustc --explain E0119`.
You can’t perform that action at this time.
0 commit comments