File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed
src/test/ui/const-generics/defaults Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( const_generics_defaults) ]
2
+
3
+ // test that defaulted const params are not used to help type inference
4
+
5
+ struct Foo < const N : u32 = 2 > ;
6
+
7
+ impl < const N : u32 > Foo < N > {
8
+ fn foo ( ) -> Self { loop { } }
9
+ }
10
+
11
+ fn main ( ) {
12
+ let foo = Foo :: < 1 > :: foo ( ) ;
13
+ let foo = Foo :: foo ( ) ;
14
+ //~^ error: type annotations needed for `Foo<{_: u32}>`
15
+ }
Original file line number Diff line number Diff line change
1
+ error[E0282]: type annotations needed for `Foo<{_: u32}>`
2
+ --> $DIR/doesnt_infer.rs:13:15
3
+ |
4
+ LL | let foo = Foo::foo();
5
+ | --- ^^^^^^^^ cannot infer the value of const parameter `N`
6
+ | |
7
+ | consider giving `foo` the explicit type `Foo<{_: u32}>`, where the type parameter `N` is specified
8
+
9
+ error: aborting due to previous error
10
+
11
+ For more information about this error, try `rustc --explain E0282`.
You can’t perform that action at this time.
0 commit comments