Stream: t-compiler/rust-analyzer

Topic: Semicolon tokens


ivan770 (Mar 26 2021 at 14:44, on Zulip):

It sounds weird, but trying to obtain a semicolon token of some nodes results in None, even if node does have a semicolon token in code. Am I missing something? image.png image.png image.png

ivan770 (Mar 26 2021 at 14:45, on Zulip):

Found something similar with match arms and commas after them while working on item movers

Lukas Wirth (Mar 26 2021 at 14:46, on Zulip):

your macro_call there is a MacroCall node, the semicolon doesn't belong to that node though

Lukas Wirth (Mar 26 2021 at 14:46, on Zulip):

it belongs to the parent which is a ExprStmt

ivan770 (Mar 26 2021 at 14:47, on Zulip):

Oh, my bad, should've looked at node tree :sweat_smile:

Lukas Wirth (Mar 26 2021 at 14:47, on Zulip):

You'll need something like macro_call.syntax().parent().and_then(ast::ExprStmt::cast).unwrap().semicolon_token()(minus the unwrap later on ideally)

Last update: Jul 29 2021 at 09:00UTC