-
Notifications
You must be signed in to change notification settings - Fork 12.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of #125807 - oli-obk:resolve_const_types, r=compiler-errors Also resolve the type of constants, even if we already turned it into an error constant error constants can still have arbitrary types, and in this case it was turned into an error constant because there was an infer var in the *type* not the *const*. fixes #125760
- Loading branch information
Showing
4 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
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
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 | ||
|
19 changes: 19 additions & 0 deletions
19
tests/ui/type-alias-impl-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
error[E0283]: type annotations needed | ||
--> $DIR/const_generic_type.rs:7:1 | ||
| | ||
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:7:24 | ||
| | ||
LL | async fn test<const N: crate::Bar>() { | ||
| ^^^^^^^^^^ | ||
| | ||
= note: the only supported types are integers, `bool` and `char` | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0283`. |
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,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>() { | ||
//[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() {} |