-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve the error message when forwarding a matched fragment to another macro #110222
Improve the error message when forwarding a matched fragment to another macro #110222
Conversation
Adds a link to the relevant part of The Rust Reference in the eror message, and suggests a possible fix (replacing the fragment specifier with :tt in the macro definition). Fixes typos in the original message. Signed-off-by: Lena Milizé <me@lvmn.org>
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @davidtwco (or someone else) soon. Please see the contribution instructions for more information. Namely, in order to ensure the minimum review times lag, PR authors and assigned reviewers should ensure that the review label (
|
And wrap the link in the diagnostic in angle brackets. Signed-off-by: Lena Milizé <me@lvmn.org>
@bors r+ |
…iaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#110153 (Fix typos in compiler) - rust-lang#110165 (rustdoc: use CSS `overscroll-behavior` instead of JavaScript) - rust-lang#110175 (Symbol cleanups) - rust-lang#110203 (Remove `..` from return type notation) - rust-lang#110205 (rustdoc: make settings radio and checks thicker, less contrast) - rust-lang#110222 (Improve the error message when forwarding a matched fragment to another macro) - rust-lang#110237 (Split out a separate feature gate for impl trait in associated types) - rust-lang#110241 (tidy: Issue an error when UI test limits are too high) Failed merges: - rust-lang#110218 (Remove `ToRegionVid`) r? `@ghost` `@rustbot` modify labels: rollup
Adds a link to Forwarding a matched fragment section of the Rust Reference, and suggests a possible fix (using
:tt
instead in the macro definition).Also removes typos from the original message, it should be
:lifetime
instead of$lifetime
.Motivation
When trying to write a macro which uses a literal in the matcher from the outer macro, like the following one, using a fragment specified that isn't one of
:ident
,:lifetime
, or:tt
currently results in a hard to understand message.Before
After
Unresolved questions
$name:literal
part of the outer macro, instead of being in the notes section at the end. But I'm not familiar with how the compiler works at all, and I have no idea how to approach this kind of solution.:tt
isn't accurate when there's more thantt
being matched, for example when the input is anitem
.