Check that we can constrain the hidden tpye of a TAIT used in a const generic type

This commit is contained in:
Oli Scherer 2024-05-31 08:58:56 +00:00
parent 06c4cc44b6
commit befcdec777
3 changed files with 21 additions and 7 deletions

View File

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

View File

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

View File

@ -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() {}