mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
Check that we can constrain the hidden tpye of a TAIT used in a const generic type
This commit is contained in:
parent
06c4cc44b6
commit
befcdec777
@ -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
|
||||
|
@ -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`
|
@ -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() {}
|
||||
|
Loading…
Reference in New Issue
Block a user