File tree 2 files changed +40
-0
lines changed
tests/ui/const-generics/generic_const_exprs
2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ #![ feature( generic_const_exprs, type_alias_impl_trait) ]
2
+ #![ allow( incomplete_features) ]
3
+
4
+ type Foo = impl Sized ;
5
+ //~^ ERROR: cycle detected
6
+
7
+ fn with_bound < const N : usize > ( ) -> Foo
8
+ where
9
+ [ u8 ; ( N / 2 ) as usize ] : Sized ,
10
+ {
11
+ let _: [ u8 ; ( N / 2 ) as Foo ] = [ 0 ; ( N / 2 ) as usize ] ;
12
+ //~^ ERROR: mismatched types
13
+ todo ! ( )
14
+ }
15
+
16
+ fn main ( ) {
17
+ with_bound :: < 4 > ( ) ;
18
+ }
Original file line number Diff line number Diff line change
1
+ error[E0308]: mismatched types
2
+ --> $DIR/opaque_type.rs:11:17
3
+ |
4
+ LL | type Foo = impl Sized;
5
+ | ---------- the found opaque type
6
+ ...
7
+ LL | let _: [u8; (N / 2) as Foo] = [0; (N / 2) as usize];
8
+ | ^^^^^^^^^^^^^^ expected `usize`, found opaque type
9
+ |
10
+ = note: expected type `usize`
11
+ found opaque type `Foo`
12
+
13
+ error[E0605]: non-primitive cast: `usize` as `Foo`
14
+ --> $DIR/opaque_type.rs:11:17
15
+ |
16
+ LL | let _: [u8; (N / 2) as Foo] = [0; (N / 2) as usize];
17
+ | ^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
18
+
19
+ error: aborting due to 2 previous errors
20
+
21
+ Some errors have detailed explanations: E0308, E0605.
22
+ For more information about an error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments