-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Always check ConstArgHasType even when otherwise ignoring
#152931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rust-bors
merged 1 commit into
rust-lang:main
from
khyperia:always-check-constarghastype
Mar 23, 2026
+524
−5
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
133 changes: 133 additions & 0 deletions
133
tests/ui/const-generics/check_const_arg_type_in_free_alias.eager.stderr
This file contains hidden or 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,133 @@ | ||
| error: the constant `B` is not of type `usize` | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:15:1 | ||
| | | ||
| LL | type ArrLen<const B: bool> = [(); B]; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `bool` | ||
| | | ||
| = note: the length of array `[(); B]` must be type `usize` | ||
|
|
||
| error: the constant `B` is not of type `usize` | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:19:1 | ||
| | | ||
| LL | type ConstArg<const B: bool> = Foo<B>; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `bool` | ||
| | | ||
| note: required by a const generic parameter in `Foo` | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:13:12 | ||
| | | ||
| LL | struct Foo<const N: usize>; | ||
| | ^^^^^^^^^^^^^^ required by this const generic parameter in `Foo` | ||
|
|
||
| error: the constant `B` is not of type `usize` | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:32:1 | ||
| | | ||
| LL | type Alias<const B: bool> = <() as IdentityWithUnused<B>>::This; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `bool` | ||
| | | ||
| note: required by a const generic parameter in `IdentityWithUnused` | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:24:26 | ||
| | | ||
| LL | trait IdentityWithUnused<const N: usize> { | ||
| | ^^^^^^^^^^^^^^ required by this const generic parameter in `IdentityWithUnused` | ||
|
|
||
| error: the constant `B` is not of type `usize` | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:38:1 | ||
| | | ||
| LL | type UseFree<const B: bool> = Free<B>; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `bool` | ||
| | | ||
| = note: the length of array `[(); B]` must be type `usize` | ||
|
|
||
| error: the constant `B` is not of type `usize` | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:58:1 | ||
| | | ||
| LL | type IndirectArr<const B: bool> = Wrap<Wrap<[(); B]>>; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `bool` | ||
| | | ||
| = note: the length of array `[(); B]` must be type `usize` | ||
|
|
||
| error: the constant `B` is not of type `usize` | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:62:1 | ||
| | | ||
| LL | type IndirectConstArg<const B: bool> = Wrap<Wrap<Foo<B>>>; | ||
| | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `bool` | ||
| | | ||
| note: required by a const generic parameter in `Foo` | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:13:12 | ||
| | | ||
| LL | struct Foo<const N: usize>; | ||
| | ^^^^^^^^^^^^^^ required by this const generic parameter in `Foo` | ||
|
|
||
| error[E0308]: mismatched types | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:17:24 | ||
| | | ||
| LL | type AnonArrLen = [(); true]; | ||
| | ^^^^ expected `usize`, found `bool` | ||
| | | ||
| = note: array length can only be `usize` | ||
|
|
||
| error[E0308]: mismatched types | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:21:25 | ||
| | | ||
| LL | type AnonConstArg = Foo<true>; | ||
| | ^^^^ expected `usize`, found `bool` | ||
| | | ||
| note: expected because of the type of the const parameter | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:13:12 | ||
| | | ||
| LL | struct Foo<const N: usize>; | ||
| | ^^^^^^^^^^^^^^ | ||
|
|
||
| error[E0308]: mismatched types | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:34:44 | ||
| | | ||
| LL | type AnonAlias = <() as IdentityWithUnused<true>>::This; | ||
| | ^^^^ expected `usize`, found `bool` | ||
|
|
||
| error[E0308]: mismatched types | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:40:25 | ||
| | | ||
| LL | type AnonUseFree = Free<true>; | ||
| | ^^^^ expected `usize`, found `bool` | ||
| | | ||
| note: expected because of the type of the const parameter | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:37:11 | ||
| | | ||
| LL | type Free<const N: usize> = [(); N]; | ||
| | ^^^^^^^^^^^^^^ | ||
|
|
||
| error[E0308]: mismatched types | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:53:45 | ||
| | | ||
| LL | type AnonUseFreeIndirectlyCorrect = UseFree<1_usize>; | ||
| | ^^^^^^^ expected `bool`, found `usize` | ||
| | | ||
| note: expected because of the type of the const parameter | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:38:14 | ||
| | | ||
| LL | type UseFree<const B: bool> = Free<B>; | ||
| | ^^^^^^^^^^^^^ | ||
|
|
||
| error[E0308]: mismatched types | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:60:39 | ||
| | | ||
| LL | type AnonIndirectArr = Wrap<Wrap<[(); true]>>; | ||
| | ^^^^ expected `usize`, found `bool` | ||
| | | ||
| = note: array length can only be `usize` | ||
|
|
||
| error[E0308]: mismatched types | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:64:43 | ||
| | | ||
| LL | type AnonIndirectConstArg = Wrap<Wrap<Foo<true>>>; | ||
| | ^^^^ expected `usize`, found `bool` | ||
| | | ||
| note: expected because of the type of the const parameter | ||
| --> $DIR/check_const_arg_type_in_free_alias.rs:13:12 | ||
| | | ||
| LL | struct Foo<const N: usize>; | ||
| | ^^^^^^^^^^^^^^ | ||
|
|
||
| error: aborting due to 13 previous errors | ||
|
|
||
| For more information about this error, try `rustc --explain E0308`. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.