-
Notifications
You must be signed in to change notification settings - Fork 13k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit introduces the following changes:
* Change error message for type param in a const expression when using min_const_generics * Change ParamInNonTrivialAnonConst to contain an extra bool used for distinguishing whether the passed-in symbol is a type or a value.
- Loading branch information
1 parent
356d8ad
commit 7d5db23
Showing
9 changed files
with
82 additions
and
14 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
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
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
18 changes: 18 additions & 0 deletions
18
src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.full.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,18 @@ | ||
error: constant expression depends on a generic parameter | ||
--> $DIR/issue-76701-ty-param-in-const.rs:6:21 | ||
| | ||
LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] { | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error: constant expression depends on a generic parameter | ||
--> $DIR/issue-76701-ty-param-in-const.rs:12:37 | ||
| | ||
LL | fn const_param<const N: usize>() -> [u8; N + 1] { | ||
| ^^^^^^^^^^^ | ||
| | ||
= note: this may fail depending on what value the parameter takes | ||
|
||
error: aborting due to 2 previous errors | ||
|
18 changes: 18 additions & 0 deletions
18
src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.min.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,18 @@ | ||
error: generic parameters must not be used inside of non trivial constant values | ||
--> $DIR/issue-76701-ty-param-in-const.rs:6:46 | ||
| | ||
LL | fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] { | ||
| ^ non-trivial anonymous constants must not depend on the parameter `T` | ||
| | ||
= note: type parameters are currently not permitted in anonymous constants | ||
|
||
error: generic parameters must not be used inside of non trivial constant values | ||
--> $DIR/issue-76701-ty-param-in-const.rs:12:42 | ||
| | ||
LL | fn const_param<const N: usize>() -> [u8; N + 1] { | ||
| ^ non-trivial anonymous constants must not depend on the parameter `N` | ||
| | ||
= help: it is currently only allowed to use either `N` or `{ N }` as generic constants | ||
|
||
error: aborting due to 2 previous errors | ||
|
18 changes: 18 additions & 0 deletions
18
src/test/ui/const-generics/issues/issue-76701-ty-param-in-const.rs
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,18 @@ | ||
// revisions: full min | ||
#![cfg_attr(full, feature(const_generics))] | ||
#![cfg_attr(full, allow(incomplete_features))] | ||
#![cfg_attr(min, feature(min_const_generics))] | ||
|
||
fn ty_param<T>() -> [u8; std::mem::size_of::<T>()] { | ||
//[full]~^ ERROR constant expression depends on a generic parameter | ||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values | ||
todo!() | ||
} | ||
|
||
fn const_param<const N: usize>() -> [u8; N + 1] { | ||
//[full]~^ ERROR constant expression depends on a generic parameter | ||
//[min]~^^ ERROR generic parameters must not be used inside of non trivial constant values | ||
todo!() | ||
} | ||
|
||
fn main() {} |
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