mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 15:01:51 +00:00
Add regression test
This commit is contained in:
parent
8e226e092e
commit
29fba9f994
18
tests/ui/const-generics/generic_const_exprs/opaque_type.rs
Normal file
18
tests/ui/const-generics/generic_const_exprs/opaque_type.rs
Normal file
@ -0,0 +1,18 @@
|
||||
#![feature(generic_const_exprs, type_alias_impl_trait)]
|
||||
#![allow(incomplete_features)]
|
||||
|
||||
type Foo = impl Sized;
|
||||
//~^ ERROR: cycle detected
|
||||
|
||||
fn with_bound<const N: usize>() -> Foo
|
||||
where
|
||||
[u8; (N / 2) as usize]: Sized,
|
||||
{
|
||||
let _: [u8; (N / 2) as Foo] = [0; (N / 2) as usize];
|
||||
//~^ ERROR: mismatched types
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn main() {
|
||||
with_bound::<4>();
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/opaque_type.rs:11:17
|
||||
|
|
||||
LL | type Foo = impl Sized;
|
||||
| ---------- the found opaque type
|
||||
...
|
||||
LL | let _: [u8; (N / 2) as Foo] = [0; (N / 2) as usize];
|
||||
| ^^^^^^^^^^^^^^ expected `usize`, found opaque type
|
||||
|
|
||||
= note: expected type `usize`
|
||||
found opaque type `Foo`
|
||||
|
||||
error[E0605]: non-primitive cast: `usize` as `Foo`
|
||||
--> $DIR/opaque_type.rs:11:17
|
||||
|
|
||||
LL | let _: [u8; (N / 2) as Foo] = [0; (N / 2) as usize];
|
||||
| ^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
Some errors have detailed explanations: E0308, E0605.
|
||||
For more information about an error, try `rustc --explain E0308`.
|
Loading…
Reference in New Issue
Block a user