diff options
| author | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-05-31 08:58:56 +0000 |
|---|---|---|
| committer | Oli Scherer <git-spam-no-reply9815368754983@oli-obk.de> | 2024-05-31 08:58:56 +0000 |
| commit | befcdec7778bc901f47fa8ebd4d5e322a8bd187e (patch) | |
| tree | 50bb5b5ae29eb3a9fff15d865263c27644f6d129 /tests | |
| parent | 06c4cc44b61cab331d0db1f0592ec7d172abf881 (diff) | |
| download | rust-befcdec7778bc901f47fa8ebd4d5e322a8bd187e.tar.gz rust-befcdec7778bc901f47fa8ebd4d5e322a8bd187e.zip | |
Check that we can constrain the hidden tpye of a TAIT used in a const generic type
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr | 10 | ||||
| -rw-r--r-- | tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr (renamed from tests/ui/type-alias-impl-trait/const_generic_type.stderr) | 8 | ||||
| -rw-r--r-- | tests/ui/type-alias-impl-trait/const_generic_type.rs | 10 |
3 files changed, 21 insertions, 7 deletions
diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr new file mode 100644 index 00000000000..6a1a770228d --- /dev/null +++ b/tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr @@ -0,0 +1,10 @@ +error: `Bar` is forbidden as the type of a const generic parameter + --> $DIR/const_generic_type.rs:7:24 + | +LL | async fn test<const N: crate::Bar>() { + | ^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + +error: aborting due to 1 previous error + diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.stderr b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr index 5501f23c8bb..a1a69bfaca3 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.stderr +++ b/tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr @@ -1,15 +1,15 @@ error[E0283]: type annotations needed - --> $DIR/const_generic_type.rs:6:1 + --> $DIR/const_generic_type.rs:7:1 | -LL | async fn test<const N: crate::Bar>() {} +LL | async fn test<const N: crate::Bar>() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type | = note: cannot satisfy `_: std::fmt::Display` error: `Bar` is forbidden as the type of a const generic parameter - --> $DIR/const_generic_type.rs:6:24 + --> $DIR/const_generic_type.rs:7:24 | -LL | async fn test<const N: crate::Bar>() {} +LL | async fn test<const N: crate::Bar>() { | ^^^^^^^^^^ | = note: the only supported types are integers, `bool` and `char` diff --git a/tests/ui/type-alias-impl-trait/const_generic_type.rs b/tests/ui/type-alias-impl-trait/const_generic_type.rs index 3af122fc4e3..95a5e1c6286 100644 --- a/tests/ui/type-alias-impl-trait/const_generic_type.rs +++ b/tests/ui/type-alias-impl-trait/const_generic_type.rs @@ -1,10 +1,14 @@ //@edition: 2021 +//@revisions: infer no_infer #![feature(type_alias_impl_trait)] type Bar = impl std::fmt::Display; -async fn test<const N: crate::Bar>() {} -//~^ ERROR: type annotations needed -//~| ERROR: `Bar` is forbidden as the type of a const generic parameter +async fn test<const N: crate::Bar>() { + //[no_infer]~^ ERROR: type annotations needed + //~^^ ERROR: `Bar` is forbidden as the type of a const generic parameter + #[cfg(infer)] + let x: u32 = N; +} fn main() {} |
