You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 rust-lang#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 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.
Copy file name to clipboardExpand all lines: tests/ui/macros/trace_faulty_macros.stderr
+3-10
Original file line number
Diff line number
Diff line change
@@ -50,7 +50,7 @@ LL | my_recursive_macro!();
50
50
= note: expanding `my_recursive_macro! { }`
51
51
= note: to `my_recursive_macro! ();`
52
52
53
-
error: expected expression, found pattern `A { a : a, b : 0, c : _, .. }`
53
+
error: expected expression, found `pat` metavariable
54
54
--> $DIR/trace_faulty_macros.rs:16:9
55
55
|
56
56
LL | $a
@@ -69,22 +69,15 @@ LL | #[derive(Debug)]
69
69
LL | fn use_derive_macro_as_attr() {}
70
70
| -------------------------------- not a `struct`, `enum` or `union`
71
71
72
-
error: expected expression, found pattern `1+1`
72
+
error: expected expression, found `pat` metavariable
73
73
--> $DIR/trace_faulty_macros.rs:49:37
74
74
|
75
-
LL | (let $p:pat = $e:expr) => {test!(($p,$e))};
76
-
| -- this is interpreted as expression, but it is expected to be pattern
77
-
...
78
75
LL | (($p:pat, $e:pat)) => {let $p = $e;};
79
76
| ^^ expected expression
80
77
...
81
78
LL | test!(let x = 1+1);
82
-
| ------------------
83
-
| | |
84
-
| | this is expected to be expression
85
-
| in this macro invocation
79
+
| ------------------ in this macro invocation
86
80
|
87
-
= 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
88
81
= note: this error originates in the macro `test` (in Nightly builds, run with -Z macro-backtrace for more info)
0 commit comments