Skip to content

Syntax extensions (and macros) that start a line want to be a whole statement #5941

Closed
@paulstansifer

Description

@paulstansifer
{ stringify!(bees).to_owned() }
 foo.rs:5:27: 5:28 error: unexpected token: `.`
 foo.rs:5          { stringify!(bees).to_owned() }
                                     ^

However, if you wrap the macro invocation in parens...

 { (stringify!(bees)).to_owned() }

...it works.

The tricky thing about this problem is that, when the parser sees stringify!, it doesn't know whether it'll be a statement macro or an expression macro; currently, it commits to the former, which breaks if the invocation has to be an expression.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-parserArea: The lexing & parsing of Rust source code to an ASTA-syntaxextArea: Syntax extensionsP-mediumMedium priority

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions