Add regression test

This commit is contained in:
Oli Scherer 2024-02-21 15:29:44 +00:00
parent 8e226e092e
commit 29fba9f994
2 changed files with 40 additions and 0 deletions

View 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>();
}

View File

@ -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`.