diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-02-21 15:29:44 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-04-04 15:15:21 +0000 |
| commit | 29fba9f994d5c32448cb6937aaae9b319ddcf392 (patch) | |
| tree | 0f72c6cf6c6ae26f3a3123e3c273f9b197fe2e4a | |
| parent | 8e226e092eba650ce0e71d1336519e4045a8ba0e (diff) | |
| download | rust-29fba9f994d5c32448cb6937aaae9b319ddcf392.tar.gz rust-29fba9f994d5c32448cb6937aaae9b319ddcf392.zip | |
Add regression test
| -rw-r--r-- | tests/ui/const-generics/generic_const_exprs/opaque_type.rs | 18 | ||||
| -rw-r--r-- | tests/ui/const-generics/generic_const_exprs/opaque_type.stderr | 22 |
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/ui/const-generics/generic_const_exprs/opaque_type.rs b/tests/ui/const-generics/generic_const_exprs/opaque_type.rs new file mode 100644 index 00000000000..1d4ef15fecf --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/opaque_type.rs @@ -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>(); +} diff --git a/tests/ui/const-generics/generic_const_exprs/opaque_type.stderr b/tests/ui/const-generics/generic_const_exprs/opaque_type.stderr new file mode 100644 index 00000000000..9f48a8563c8 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/opaque_type.stderr @@ -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`. |
