diff options
| author | Caio <c410.f3r@gmail.com> | 2023-04-20 15:06:17 -0300 |
|---|---|---|
| committer | Caio <c410.f3r@gmail.com> | 2023-04-20 15:06:17 -0300 |
| commit | 4adc5f9281e683935f1ea360367b9287d0fb3799 (patch) | |
| tree | 6b93f2f1711a05a7f08387e92ca84834765a95bf /tests/ui/macros | |
| parent | 39c6804b92aa202369e402525cee329556bc1db0 (diff) | |
| download | rust-4adc5f9281e683935f1ea360367b9287d0fb3799.tar.gz rust-4adc5f9281e683935f1ea360367b9287d0fb3799.zip | |
Move test files
Diffstat (limited to 'tests/ui/macros')
| -rw-r--r-- | tests/ui/macros/issue-26094.rs | 12 | ||||
| -rw-r--r-- | tests/ui/macros/issue-26094.stderr | 18 | ||||
| -rw-r--r-- | tests/ui/macros/issue-69396-const-no-type-in-macro.rs | 17 | ||||
| -rw-r--r-- | tests/ui/macros/issue-69396-const-no-type-in-macro.stderr | 50 |
4 files changed, 97 insertions, 0 deletions
diff --git a/tests/ui/macros/issue-26094.rs b/tests/ui/macros/issue-26094.rs new file mode 100644 index 00000000000..2742529edd3 --- /dev/null +++ b/tests/ui/macros/issue-26094.rs @@ -0,0 +1,12 @@ +macro_rules! some_macro { + ($other: expr) => {{ + $other(None) //~ NOTE unexpected argument of type `Option<_>` + }}; +} + +fn some_function() {} //~ NOTE defined here + +fn main() { + some_macro!(some_function); + //~^ ERROR function takes 0 arguments but 1 argument was supplied +} diff --git a/tests/ui/macros/issue-26094.stderr b/tests/ui/macros/issue-26094.stderr new file mode 100644 index 00000000000..ecdf48470f7 --- /dev/null +++ b/tests/ui/macros/issue-26094.stderr @@ -0,0 +1,18 @@ +error[E0061]: this function takes 0 arguments but 1 argument was supplied + --> $DIR/issue-26094.rs:10:17 + | +LL | $other(None) + | ---- unexpected argument of type `Option<_>` +... +LL | some_macro!(some_function); + | ^^^^^^^^^^^^^ + | +note: function defined here + --> $DIR/issue-26094.rs:7:4 + | +LL | fn some_function() {} + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/macros/issue-69396-const-no-type-in-macro.rs b/tests/ui/macros/issue-69396-const-no-type-in-macro.rs new file mode 100644 index 00000000000..45a30857413 --- /dev/null +++ b/tests/ui/macros/issue-69396-const-no-type-in-macro.rs @@ -0,0 +1,17 @@ +macro_rules! suite { + ( $( $fn:ident; )* ) => { + $( + const A = "A".$fn(); + //~^ ERROR the name `A` is defined multiple times + //~| ERROR missing type for `const` item + //~| ERROR the placeholder `_` is not allowed within types on item signatures for constants + )* + } +} + +suite! { + len; + is_empty; +} + +fn main() {} diff --git a/tests/ui/macros/issue-69396-const-no-type-in-macro.stderr b/tests/ui/macros/issue-69396-const-no-type-in-macro.stderr new file mode 100644 index 00000000000..89aeafebac4 --- /dev/null +++ b/tests/ui/macros/issue-69396-const-no-type-in-macro.stderr @@ -0,0 +1,50 @@ +error[E0428]: the name `A` is defined multiple times + --> $DIR/issue-69396-const-no-type-in-macro.rs:4:13 + | +LL | const A = "A".$fn(); + | ^^^^^^^^^^^^^^^^^^^^ `A` redefined here +... +LL | / suite! { +LL | | len; +LL | | is_empty; +LL | | } + | |_- in this macro invocation + | + = note: `A` must be defined only once in the value namespace of this module + = note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: missing type for `const` item + --> $DIR/issue-69396-const-no-type-in-macro.rs:4:20 + | +LL | const A = "A".$fn(); + | ^ help: provide a type for the constant: `: usize` +... +LL | / suite! { +LL | | len; +LL | | is_empty; +LL | | } + | |_- in this macro invocation + | + = note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/issue-69396-const-no-type-in-macro.rs:4:20 + | +LL | const A = "A".$fn(); + | ^ + | | + | not allowed in type signatures + | help: replace with the correct type: `bool` +... +LL | / suite! { +LL | | len; +LL | | is_empty; +LL | | } + | |_- in this macro invocation + | + = note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0121, E0428. +For more information about an error, try `rustc --explain E0121`. |
