rust/tests/ui/macros/trace_faulty_macros.stderr

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

115 lines
4 KiB
Plaintext
Raw Normal View History

2017-09-02 15:21:13 +00:00
error: no rules expected the token `bcd`
2018-12-25 15:56:47 +00:00
--> $DIR/trace_faulty_macros.rs:7:26
2017-09-02 15:21:13 +00:00
|
LL | macro_rules! my_faulty_macro {
| ---------------------------- when calling this macro
LL | () => {
2019-03-09 12:03:44 +00:00
LL | my_faulty_macro!(bcd);
| ^^^ no rules expected this token in macro call
2017-09-02 15:21:13 +00:00
...
LL | my_faulty_macro!();
2021-10-14 18:28:28 +00:00
| ------------------ in this macro invocation
|
= note: while trying to match end of macro
= note: this error originates in the macro `my_faulty_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
2017-09-02 15:21:13 +00:00
note: trace_macro
2020-03-21 21:12:24 +00:00
--> $DIR/trace_faulty_macros.rs:31:5
2017-09-02 15:21:13 +00:00
|
2018-02-23 00:42:32 +00:00
LL | my_faulty_macro!();
2021-10-14 18:28:28 +00:00
| ^^^^^^^^^^^^^^^^^^
2017-09-02 15:21:13 +00:00
|
= note: expanding `my_faulty_macro! { }`
= note: to `my_faulty_macro! (bcd);`
2017-09-02 15:21:13 +00:00
= note: expanding `my_faulty_macro! { bcd }`
error: recursion limit reached while expanding `my_recursive_macro!`
2018-12-25 15:56:47 +00:00
--> $DIR/trace_faulty_macros.rs:22:9
2017-09-02 15:21:13 +00:00
|
2019-03-09 12:03:44 +00:00
LL | my_recursive_macro!();
2021-10-14 18:28:28 +00:00
| ^^^^^^^^^^^^^^^^^^^^^
2017-09-02 15:21:13 +00:00
...
2018-02-23 00:42:32 +00:00
LL | my_recursive_macro!();
2021-10-14 18:28:28 +00:00
| --------------------- in this macro invocation
2017-09-02 15:21:13 +00:00
|
= help: consider increasing the recursion limit by adding a `#![recursion_limit = "8"]` attribute to your crate (`trace_faulty_macros`)
= note: this error originates in the macro `my_recursive_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
2017-09-02 15:21:13 +00:00
note: trace_macro
2020-03-21 21:12:24 +00:00
--> $DIR/trace_faulty_macros.rs:32:5
2017-09-02 15:21:13 +00:00
|
2018-02-23 00:42:32 +00:00
LL | my_recursive_macro!();
2021-10-14 18:28:28 +00:00
| ^^^^^^^^^^^^^^^^^^^^^
2017-09-02 15:21:13 +00:00
|
= note: expanding `my_recursive_macro! { }`
= note: to `my_recursive_macro! ();`
2017-09-02 15:21:13 +00:00
= note: expanding `my_recursive_macro! { }`
= note: to `my_recursive_macro! ();`
2017-09-02 15:21:13 +00:00
= note: expanding `my_recursive_macro! { }`
= note: to `my_recursive_macro! ();`
2017-09-02 15:21:13 +00:00
= note: expanding `my_recursive_macro! { }`
= note: to `my_recursive_macro! ();`
2017-09-02 15:21:13 +00:00
error: expected expression, found pattern `A { a : a, b : 0, c : _, .. }`
2020-02-29 03:23:58 +00:00
--> $DIR/trace_faulty_macros.rs:16:9
|
LL | $a
| ^^ expected expression
...
LL | let a = pat_macro!();
| ------------ in this macro invocation
|
= note: this error originates in the macro `pat_macro` (in Nightly builds, run with -Z macro-backtrace for more info)
2020-02-29 03:23:58 +00:00
error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s
2020-03-21 21:12:24 +00:00
--> $DIR/trace_faulty_macros.rs:42:1
|
LL | #[derive(Debug)]
| ^^^^^^^^^^^^^^^^ not applicable here
LL | fn use_derive_macro_as_attr() {}
| -------------------------------- not a `struct`, `enum` or `union`
2020-03-21 21:12:24 +00:00
error: expected expression, found pattern `1+1`
--> $DIR/trace_faulty_macros.rs:49:37
|
LL | (let $p:pat = $e:expr) => {test!(($p,$e))};
| -- this is interpreted as expression, but it is expected to be pattern
...
LL | (($p:pat, $e:pat)) => {let $p = $e;};
| ^^ expected expression
...
LL | test!(let x = 1+1);
| ------------------
| | |
| | this is expected to be expression
| in this macro invocation
|
= note: when forwarding a matched fragment to another macro-by-example, matchers in the second macro will see an opaque AST of the fragment type, not the underlying tokens
= note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
2020-03-21 21:12:24 +00:00
note: trace_macro
--> $DIR/trace_faulty_macros.rs:36:13
|
LL | let a = pat_macro!();
| ^^^^^^^^^^^^
|
= note: expanding `pat_macro! { }`
= note: to `pat_macro! (A { a : a, b : 0, c : _, .. });`
2020-03-21 21:12:24 +00:00
= note: expanding `pat_macro! { A { a : a, b : 0, c : _, .. } }`
= note: to `A { a : a, b : 0, c : _, .. }`
2020-03-21 21:12:24 +00:00
note: trace_macro
--> $DIR/trace_faulty_macros.rs:53:5
|
LL | test!(let x = 1+1);
| ^^^^^^^^^^^^^^^^^^
|
Improve `print_tts` by changing `tokenstream::Spacing`. `tokenstream::Spacing` appears on all `TokenTree::Token` instances, both punct and non-punct. Its current usage: - `Joint` means "can join with the next token *and* that token is a punct". - `Alone` means "cannot join with the next token *or* can join with the next token but that token is not a punct". The fact that `Alone` is used for two different cases is awkward. This commit augments `tokenstream::Spacing` with a new variant `JointHidden`, resulting in: - `Joint` means "can join with the next token *and* that token is a punct". - `JointHidden` means "can join with the next token *and* that token is a not a punct". - `Alone` means "cannot join with the next token". This *drastically* improves the output of `print_tts`. For example, this: ``` stringify!(let a: Vec<u32> = vec![];) ``` currently produces this string: ``` let a : Vec < u32 > = vec! [] ; ``` With this PR, it now produces this string: ``` let a: Vec<u32> = vec![] ; ``` (The space after the `]` is because `TokenTree::Delimited` currently doesn't have spacing information. The subsequent commit fixes this.) The new `print_tts` doesn't replicate original code perfectly. E.g. multiple space characters will be condensed into a single space character. But it's much improved. `print_tts` still produces the old, uglier output for code produced by proc macros. Because we have to translate the generated code from `proc_macro::Spacing` to the more expressive `token::Spacing`, which results in too much `proc_macro::Along` usage and no `proc_macro::JointHidden` usage. So `space_between` still exists and is used by `print_tts` in conjunction with the `Spacing` field. This change will also help with the removal of `Token::Interpolated`. Currently interpolated tokens are pretty-printed nicely via AST pretty printing. `Token::Interpolated` removal will mean they get printed with `print_tts`. Without this change, that would result in much uglier output for code produced by decl macro expansions. With this change, AST pretty printing and `print_tts` produce similar results. The commit also tweaks the comments on `proc_macro::Spacing`. In particular, it refers to "compound tokens" rather than "multi-char operators" because lifetimes aren't operators.
2023-08-08 01:43:44 +00:00
= note: expanding `test! { let x = 1+1 }`
= note: to `test! ((x, 1+1))`
= note: expanding `test! { (x, 1+1) }`
= note: to `let x = 1+1;`
error: aborting due to 5 previous errors
2018-03-15 15:13:47 +00:00
2020-09-05 12:55:15 +00:00
For more information about this error, try `rustc --explain E0774`.