add macro_rules test regarding braces
This commit is contained in:
parent
359031e1d3
commit
dd78188185
61
src/test/ui/const-generics/macro_rules-braces.full.stderr
Normal file
61
src/test/ui/const-generics/macro_rules-braces.full.stderr
Normal file
@ -0,0 +1,61 @@
|
||||
error: expressions must be enclosed in braces to be used as const generic arguments
|
||||
--> $DIR/macro_rules-braces.rs:34:17
|
||||
|
|
||||
LL | let _: baz!(N);
|
||||
| ^
|
||||
|
|
||||
help: enclose the `const` expression in braces
|
||||
|
|
||||
LL | let _: baz!({ N });
|
||||
| ^ ^
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/macro_rules-braces.rs:10:13
|
||||
|
|
||||
LL | [u8; $x]
|
||||
| ^^^^^^^^
|
||||
...
|
||||
LL | let _: foo!({{ N }});
|
||||
| ------------- in this macro invocation
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/macro_rules-braces.rs:15:13
|
||||
|
|
||||
LL | [u8; { $x }]
|
||||
| ^^^^^^^^^^^^
|
||||
...
|
||||
LL | let _: bar!({ N });
|
||||
| ----------- in this macro invocation
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/macro_rules-braces.rs:20:13
|
||||
|
|
||||
LL | Foo<$x>
|
||||
| ^^^^^^^
|
||||
...
|
||||
LL | let _: baz!({{ N }});
|
||||
| ------------- in this macro invocation
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: constant expression depends on a generic parameter
|
||||
--> $DIR/macro_rules-braces.rs:25:13
|
||||
|
|
||||
LL | Foo<{ $x }>
|
||||
| ^^^^^^^^^^^
|
||||
...
|
||||
LL | let _: biz!({ N });
|
||||
| ----------- in this macro invocation
|
||||
|
|
||||
= note: this may fail depending on what value the parameter takes
|
||||
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
45
src/test/ui/const-generics/macro_rules-braces.min.stderr
Normal file
45
src/test/ui/const-generics/macro_rules-braces.min.stderr
Normal file
@ -0,0 +1,45 @@
|
||||
error: expressions must be enclosed in braces to be used as const generic arguments
|
||||
--> $DIR/macro_rules-braces.rs:34:17
|
||||
|
|
||||
LL | let _: baz!(N);
|
||||
| ^
|
||||
|
|
||||
help: enclose the `const` expression in braces
|
||||
|
|
||||
LL | let _: baz!({ N });
|
||||
| ^ ^
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/macro_rules-braces.rs:31:20
|
||||
|
|
||||
LL | let _: foo!({{ N }});
|
||||
| ^ cannot perform const operation using `N`
|
||||
|
|
||||
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/macro_rules-braces.rs:33:19
|
||||
|
|
||||
LL | let _: bar!({ N });
|
||||
| ^ cannot perform const operation using `N`
|
||||
|
|
||||
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/macro_rules-braces.rs:36:20
|
||||
|
|
||||
LL | let _: baz!({{ N }});
|
||||
| ^ cannot perform const operation using `N`
|
||||
|
|
||||
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||
|
||||
error: generic parameters may not be used in const operations
|
||||
--> $DIR/macro_rules-braces.rs:38:19
|
||||
|
|
||||
LL | let _: biz!({ N });
|
||||
| ^ cannot perform const operation using `N`
|
||||
|
|
||||
= help: const parameters may only be used as standalone arguments, i.e. `N`
|
||||
|
||||
error: aborting due to 5 previous errors
|
||||
|
43
src/test/ui/const-generics/macro_rules-braces.rs
Normal file
43
src/test/ui/const-generics/macro_rules-braces.rs
Normal file
@ -0,0 +1,43 @@
|
||||
// revisions: full min
|
||||
#![cfg_attr(full, allow(incomplete_features))]
|
||||
#![cfg_attr(full, feature(const_generics))]
|
||||
#![cfg_attr(min, feature(min_const_generics))]
|
||||
|
||||
fn test<const N: usize>() {
|
||||
struct Foo<const M: usize>;
|
||||
macro_rules! foo {
|
||||
($x:expr) => {
|
||||
[u8; $x] //[full]~ ERROR constant expression depends
|
||||
}
|
||||
}
|
||||
macro_rules! bar {
|
||||
($x:expr) => {
|
||||
[u8; { $x }] //[full]~ ERROR constant expression depends
|
||||
}
|
||||
}
|
||||
macro_rules! baz {
|
||||
( $x:expr) => {
|
||||
Foo<$x> //[full]~ ERROR constant expression depends
|
||||
}
|
||||
}
|
||||
macro_rules! biz {
|
||||
($x:expr) => {
|
||||
Foo<{ $x }> //[full]~ ERROR constant expression depends
|
||||
};
|
||||
}
|
||||
|
||||
let _: foo!(N);
|
||||
let _: foo!({ N });
|
||||
let _: foo!({{ N }}); //[min]~ ERROR generic parameters may not
|
||||
let _: bar!(N);
|
||||
let _: bar!({ N }); //[min]~ ERROR generic parameters may not
|
||||
let _: baz!(N); //~ ERROR expressions must be enclosed in braces
|
||||
let _: baz!({ N });
|
||||
let _: baz!({{ N }}); //[min]~ ERROR generic parameters may not
|
||||
let _: biz!(N);
|
||||
let _: biz!({ N }); //[min]~ ERROR generic parameters may not
|
||||
}
|
||||
|
||||
fn main() {
|
||||
test::<3>();
|
||||
}
|
Loading…
Reference in New Issue
Block a user