File tree 2 files changed +53
-0
lines changed
tests/ui/traits/const-traits
2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ // This test demonstrates an ICE that may occur when we try to resolve the instance
2
+ // of a impl that has different generics than the trait it's implementing. This ensures
3
+ // we first check that the args are compatible before resolving the body, just like
4
+ // we do in projection before substituting a GAT.
5
+ //
6
+ // Regression test for issue #125877.
7
+
8
+ //@ compile-flags: -Znext-solver
9
+
10
+ #![ feature( const_trait_impl, effects) ]
11
+ //~^ ERROR feature has been removed
12
+
13
+ #[ const_trait]
14
+ trait Main {
15
+ fn compute < T : ~const Aux > ( ) -> u32 ;
16
+ }
17
+
18
+ impl const Main for ( ) {
19
+ fn compute < ' x > ( ) -> u32 {
20
+ //~^ ERROR associated function `compute` has 0 type parameters but its trait declaration has 1 type parameter
21
+ 0
22
+ }
23
+ }
24
+
25
+ #[ const_trait]
26
+ trait Aux { }
27
+
28
+ impl const Aux for ( ) { }
29
+
30
+ fn main ( ) {
31
+ const _: u32 = <( ) >:: compute :: < ( ) > ( ) ;
32
+ }
Original file line number Diff line number Diff line change
1
+ error[E0557]: feature has been removed
2
+ --> $DIR/const-trait-impl-parameter-mismatch.rs:10:30
3
+ |
4
+ LL | #![feature(const_trait_impl, effects)]
5
+ | ^^^^^^^ feature has been removed
6
+ |
7
+ = note: removed, redundant with `#![feature(const_trait_impl)]`
8
+
9
+ error[E0049]: associated function `compute` has 0 type parameters but its trait declaration has 1 type parameter
10
+ --> $DIR/const-trait-impl-parameter-mismatch.rs:19:16
11
+ |
12
+ LL | fn compute<T: ~const Aux>() -> u32;
13
+ | - expected 1 type parameter
14
+ ...
15
+ LL | fn compute<'x>() -> u32 {
16
+ | ^^ found 0 type parameters
17
+
18
+ error: aborting due to 2 previous errors
19
+
20
+ Some errors have detailed explanations: E0049, E0557.
21
+ For more information about an error, try `rustc --explain E0049`.
You can’t perform that action at this time.
0 commit comments