Skip to content

Commit befcdec

Browse files
committed
Check that we can constrain the hidden tpye of a TAIT used in a const generic type
1 parent 06c4cc4 commit befcdec

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
error: `Bar` is forbidden as the type of a const generic parameter
2+
--> $DIR/const_generic_type.rs:7:24
3+
|
4+
LL | async fn test<const N: crate::Bar>() {
5+
| ^^^^^^^^^^
6+
|
7+
= note: the only supported types are integers, `bool` and `char`
8+
9+
error: aborting due to 1 previous error
10+

tests/ui/type-alias-impl-trait/const_generic_type.stderr tests/ui/type-alias-impl-trait/const_generic_type.no_infer.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
error[E0283]: type annotations needed
2-
--> $DIR/const_generic_type.rs:6:1
2+
--> $DIR/const_generic_type.rs:7:1
33
|
4-
LL | async fn test<const N: crate::Bar>() {}
4+
LL | async fn test<const N: crate::Bar>() {
55
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type
66
|
77
= note: cannot satisfy `_: std::fmt::Display`
88

99
error: `Bar` is forbidden as the type of a const generic parameter
10-
--> $DIR/const_generic_type.rs:6:24
10+
--> $DIR/const_generic_type.rs:7:24
1111
|
12-
LL | async fn test<const N: crate::Bar>() {}
12+
LL | async fn test<const N: crate::Bar>() {
1313
| ^^^^^^^^^^
1414
|
1515
= note: the only supported types are integers, `bool` and `char`
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
//@edition: 2021
2+
//@revisions: infer no_infer
23

34
#![feature(type_alias_impl_trait)]
45
type Bar = impl std::fmt::Display;
56

6-
async fn test<const N: crate::Bar>() {}
7-
//~^ ERROR: type annotations needed
8-
//~| ERROR: `Bar` is forbidden as the type of a const generic parameter
7+
async fn test<const N: crate::Bar>() {
8+
//[no_infer]~^ ERROR: type annotations needed
9+
//~^^ ERROR: `Bar` is forbidden as the type of a const generic parameter
10+
#[cfg(infer)]
11+
let x: u32 = N;
12+
}
913

1014
fn main() {}

0 commit comments

Comments
 (0)