Add FCW to disallow $crate in macro matcher#155121
Add FCW to disallow $crate in macro matcher#155121nik-rev wants to merge 1 commit intorust-lang:mainfrom
$crate in macro matcher#155121Conversation
|
r? @JohnTitor rustbot has assigned @JohnTitor. Use Why was this reviewer chosen?The reviewer was selected based on:
|
d27f291 to
67232bd
Compare
|
@rustbot label +I-lang-nominated |
This comment has been minimized.
This comment has been minimized.
67232bd to
30cb21b
Compare
|
The list before the |
$crate in macro transcriber$crate in macro matcher
fafa622 to
e667cac
Compare
ah, thanks! fixed. |
This comment has been minimized.
This comment has been minimized.
e667cac to
afc40cd
Compare
|
Does this also fix #147028 ? |
afc40cd to
2a77185
Compare
Co-authored-by: @CAD97
2a77185 to
8a42eb4
Compare
I updated this PR to include the test cases from that issue and made sure they also trigger this new lint. Now, is it right to say that this PR "closes" the issue, considering that the behavior is still the same, albeit linted now? |
This PR adds a new warn-by-default future incompatibility lint that lints on usage of
$crateinside of a macro matcher.Tracking Issue: #155123
Reason:
Example:
This shows the strange property of
$cratein a matcher: thecall!macro is defined insidelib.rs, so the$cratetoken belongs tolib.rs. Yet, despite that, it still matches against the$cratetoken produced inside ofmain.rs.Expected behavior:
$crate: without a fragment specifier, error indicating that a fragment specifier is missing$crate:tt: with a fragment specifier, error indicating that$crateis a reserved identifier that cannot be used as the name of a metavariable.Explanation and example is from #99037
History:
Previous PR: #99447, which received no response from the author, so I'm picking it up
Issues:
$crateis treated as a normal identifier in amacro_rulesmatcher #147028CC @CAD97