mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-01 20:47:36 +00:00

The one notable test change is `tests/ui/macros/trace_faulty_macros.rs`. This commit removes the complicated `Interpolated` handling in `expected_expression_found` that results in a longer error message. But I think the new, shorter message is actually an improvement. The original complaint was in #71039, when the error message started with "error: expected expression, found `1 + 1`". That was confusing because `1 + 1` is an expression. Other than that, the reporter said "the whole error message is not too bad if you ignore the first line". Subsequently, extra complexity and wording was added to the error message. But I don't think the extra wording actually helps all that much. In particular, it still says of the `1+1` that "this is expected to be expression". This repeats the problem from the original complaint! This commit removes the extra complexity, reverting to a simpler error message. This is primarily because the traversal is a pain without `Interpolated` tokens. Nonetheless, I think the error message is *improved*. It now starts with "expected expression, found `pat` metavariable", which is much clearer and the real problem. It also doesn't say anything specific about `1+1`, which is good, because the `1+1` isn't really relevant to the error -- it's the `$e:pat` that's important.
108 lines
3.6 KiB
Plaintext
108 lines
3.6 KiB
Plaintext
error: no rules expected `bcd`
|
|
--> $DIR/trace_faulty_macros.rs:7:26
|
|
|
|
|
LL | macro_rules! my_faulty_macro {
|
|
| ---------------------------- when calling this macro
|
|
LL | () => {
|
|
LL | my_faulty_macro!(bcd);
|
|
| ^^^ no rules expected this token in macro call
|
|
...
|
|
LL | my_faulty_macro!();
|
|
| ------------------ 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)
|
|
|
|
note: trace_macro
|
|
--> $DIR/trace_faulty_macros.rs:31:5
|
|
|
|
|
LL | my_faulty_macro!();
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: expanding `my_faulty_macro! { }`
|
|
= note: to `my_faulty_macro! (bcd);`
|
|
= note: expanding `my_faulty_macro! { bcd }`
|
|
|
|
error: recursion limit reached while expanding `my_recursive_macro!`
|
|
--> $DIR/trace_faulty_macros.rs:22:9
|
|
|
|
|
LL | my_recursive_macro!();
|
|
| ^^^^^^^^^^^^^^^^^^^^^
|
|
...
|
|
LL | my_recursive_macro!();
|
|
| --------------------- in this macro invocation
|
|
|
|
|
= 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)
|
|
|
|
note: trace_macro
|
|
--> $DIR/trace_faulty_macros.rs:32:5
|
|
|
|
|
LL | my_recursive_macro!();
|
|
| ^^^^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= note: expanding `my_recursive_macro! { }`
|
|
= note: to `my_recursive_macro! ();`
|
|
= note: expanding `my_recursive_macro! { }`
|
|
= note: to `my_recursive_macro! ();`
|
|
= note: expanding `my_recursive_macro! { }`
|
|
= note: to `my_recursive_macro! ();`
|
|
= note: expanding `my_recursive_macro! { }`
|
|
= note: to `my_recursive_macro! ();`
|
|
|
|
error: expected expression, found `pat` metavariable
|
|
--> $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)
|
|
|
|
error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s
|
|
--> $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`
|
|
|
|
error: expected expression, found `pat` metavariable
|
|
--> $DIR/trace_faulty_macros.rs:49:37
|
|
|
|
|
LL | (($p:pat, $e:pat)) => {let $p = $e;};
|
|
| ^^ expected expression
|
|
...
|
|
LL | test!(let x = 1+1);
|
|
| ------------------ in this macro invocation
|
|
|
|
|
= note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
|
|
|
|
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 : _, .. });`
|
|
= note: expanding `pat_macro! { A { a : a, b : 0, c : _, .. } }`
|
|
= note: to `A { a : a, b : 0, c : _, .. }`
|
|
|
|
note: trace_macro
|
|
--> $DIR/trace_faulty_macros.rs:53:5
|
|
|
|
|
LL | test!(let x = 1+1);
|
|
| ^^^^^^^^^^^^^^^^^^
|
|
|
|
|
= 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
|
|
|
|
For more information about this error, try `rustc --explain E0774`.
|