-
Notifications
You must be signed in to change notification settings - Fork 13.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// aux-build:legacy-const-generics.rs | ||
|
||
extern crate legacy_const_generics; | ||
|
||
fn foo<const N: usize>() { | ||
let a = 1; | ||
legacy_const_generics::foo(0, a, 2); | ||
//~^ ERROR attempt to use a non-constant value in a constant | ||
|
||
legacy_const_generics::foo(0, N, 2); | ||
|
||
legacy_const_generics::foo(0, N + 1, 2); | ||
//~^ ERROR generic parameters may not be used in const operations | ||
} | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
error[E0435]: attempt to use a non-constant value in a constant | ||
--> $DIR/legacy-const-generics-bad.rs:7:35 | ||
| | ||
LL | let a = 1; | ||
| ----- help: consider using `const` instead of `let`: `const a` | ||
LL | legacy_const_generics::foo(0, a, 2); | ||
| ^ non-constant value | ||
|
||
error: generic parameters may not be used in const operations | ||
--> $DIR/legacy-const-generics-bad.rs:12:35 | ||
| | ||
LL | legacy_const_generics::foo(0, N + 1, 2); | ||
| ^ cannot perform const operation using `N` | ||
| | ||
= help: const parameters may only be used as standalone arguments, i.e. `N` | ||
= help: use `#![feature(const_generics)]` and `#![feature(const_evaluatable_checked)]` to allow generic const expressions | ||
|
||
error: aborting due to 2 previous errors | ||
|
||
For more information about this error, try `rustc --explain E0435`. |