forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check that we can constrain the hidden tpye of a TAIT used in a const…
… generic type
- Loading branch information
Showing
3 changed files
with
21 additions
and
7 deletions.
There are no files selected for viewing
10 changes: 10 additions & 0 deletions
10
tests/ui/type-alias-impl-trait/const_generic_type.infer.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
|
8 changes: 4 additions & 4 deletions
8
...lias-impl-trait/const_generic_type.stderr → ...-trait/const_generic_type.no_infer.stderr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() {} |