-
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.
Handle macro calls in anon const def creation take 2
- Loading branch information
Showing
13 changed files
with
178 additions
and
28 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
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
14 changes: 14 additions & 0 deletions
14
tests/ui/const-generics/early/trivial-const-arg-macro-braced-expansion.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,14 @@ | ||
macro_rules! y { | ||
() => { | ||
N | ||
}; | ||
} | ||
|
||
struct A<const N: usize>; | ||
|
||
fn foo<const N: usize>() -> A<{ y!() }> { | ||
A::<1> | ||
//~^ ERROR: mismatched types | ||
} | ||
|
||
fn main() {} |
14 changes: 14 additions & 0 deletions
14
tests/ui/const-generics/early/trivial-const-arg-macro-braced-expansion.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,14 @@ | ||
error[E0308]: mismatched types | ||
--> $DIR/trivial-const-arg-macro-braced-expansion.rs:10:5 | ||
| | ||
LL | fn foo<const N: usize>() -> A<{ y!() }> { | ||
| ----------- expected `A<N>` because of return type | ||
LL | A::<1> | ||
| ^^^^^^ expected `N`, found `1` | ||
| | ||
= note: expected struct `A<N>` | ||
found struct `A<1>` | ||
|
||
error: aborting due to 1 previous error | ||
|
||
For more information about this error, try `rustc --explain E0308`. |
15 changes: 15 additions & 0 deletions
15
tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces.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,15 @@ | ||
#[rustfmt::skip] | ||
macro_rules! y { | ||
() => { | ||
{ N } | ||
//~^ ERROR: generic parameters may not be used in const operations | ||
}; | ||
} | ||
|
||
struct A<const N: usize>; | ||
|
||
fn foo<const N: usize>() -> A<{ y!() }> { | ||
A::<1> | ||
} | ||
|
||
fn main() {} |
15 changes: 15 additions & 0 deletions
15
tests/ui/const-generics/early/trivial-const-arg-macro-nested-braces.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,15 @@ | ||
error: generic parameters may not be used in const operations | ||
--> $DIR/trivial-const-arg-macro-nested-braces.rs:4:11 | ||
| | ||
LL | { N } | ||
| ^ cannot perform const operation using `N` | ||
... | ||
LL | fn foo<const N: usize>() -> A<{ y!() }> { | ||
| ---- in this macro invocation | ||
| | ||
= help: const parameters may only be used as standalone arguments, i.e. `N` | ||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions | ||
= note: this error originates in the macro `y` (in Nightly builds, run with -Z macro-backtrace for more info) | ||
|
||
error: aborting due to 1 previous error | ||
|
9 changes: 9 additions & 0 deletions
9
tests/ui/const-generics/early/trivial-const-arg-nested-braces.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,9 @@ | ||
struct A<const N: usize>; | ||
|
||
#[rustfmt::skip] | ||
fn foo<const N: usize>() -> A<{ { N } }> { | ||
//~^ ERROR: generic parameters may not be used in const operations | ||
A::<1> | ||
} | ||
|
||
fn main() {} |
11 changes: 11 additions & 0 deletions
11
tests/ui/const-generics/early/trivial-const-arg-nested-braces.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,11 @@ | ||
error: generic parameters may not be used in const operations | ||
--> $DIR/trivial-const-arg-nested-braces.rs:4:35 | ||
| | ||
LL | fn foo<const N: usize>() -> A<{ { N } }> { | ||
| ^ cannot perform const operation using `N` | ||
| | ||
= help: const parameters may only be used as standalone arguments, i.e. `N` | ||
= help: add `#![feature(generic_const_exprs)]` to allow generic const expressions | ||
|
||
error: aborting due to 1 previous error | ||
|