rust compiler suggests to add lifetime to macro: `#'static[...]`
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Code
https://github.com/Anatoly03/Netz/tree/bf8c6917b68c70cc0677b540402c4d64707670bc/util-parser
(The token stream generated by the broken macro is logged into the console.)
Current output
error[E0106]: missing lifetime specifier
--> util-parser/tests/whitespace.rs:5:5
|
5 | #[grammar(~)]
| ^ expected named lifetime parameter
|
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
= note: this error originates in the attribute macro `grammar` (in Nightly builds, run with -Z macro-backtrace for more info)
help: consider using the `'static` lifetime, but this is uncommon unless you're returning a borrowed value from a `const` or a `static`
|
5 | #'static [grammar(~)]
| +++++++
help: instead, you are more likely to want to return an owned value
|
5 | String
|
Desired output
[expand macro code with broken lines displayed]
error[????]: could not compile macro `grammar` due to ... errors
Rationale and extra context
Other cases
No response
Rust Version
rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-apple-darwin
release: 1.81.0
LLVM version: 18.1.7
Anything else?
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the diagnostic with the linked Netz util-parser tree and Rust 1.81.0, starting from the grammar attribute macro and its logged token stream. Done means broken macro expansion lines are displayed and the misleading lifetime suggestion is replaced by a macro-compilation error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 38/100