Stream: t-compiler/rust-analyzer

Topic: Move towards upstream `macro_rules!` model


Jonas Schievink [he/him] (Dec 14 2020 at 13:46, on Zulip):

@matklad any opinions on https://github.com/rust-analyzer/ungrammar/pull/14? I'd like to clean up how we handle macros, and this would be a useful step towards that.

matklad (Dec 14 2020 at 13:47, on Zulip):

Missed that

matklad (Dec 14 2020 at 13:48, on Zulip):

I guess, it makes sense, even if I don't like it from purity perspective :D

matklad (Dec 14 2020 at 13:48, on Zulip):

@Jonas Schievink feel free to merge (to also check that you have perms)

Jonas Schievink [he/him] (Dec 14 2020 at 13:50, on Zulip):

Thanks! Merging seems to work

Jonas Schievink [he/him] (Dec 14 2020 at 13:51, on Zulip):

Hmm, what kind of version bump does this need? Just minor?

Jonas Schievink [he/him] (Dec 14 2020 at 13:52, on Zulip):

Ah I'm not a crate owner anyways https://crates.io/crates/ungrammar

matklad (Dec 14 2020 at 13:53, on Zulip):

@Jonas Schievink there's CI job for continious publishing

matklad (Dec 14 2020 at 13:53, on Zulip):

but I prob should add a team

matklad (Dec 14 2020 at 13:53, on Zulip):

minod bump would be ok

Jonas Schievink [he/him] (Dec 14 2020 at 14:04, on Zulip):

thread 'main' panicked at 'not yet implemented: Rep(Seq([Token(Token(14)), Node(Node(39))]))', xtask/src/codegen/gen_syntax.rs:585:13

seems like xtask codegen dislikes (';' MacroArm)*, although it has no problems with (',' GenericArg)* in GenericArgList

matklad (Dec 14 2020 at 14:06, on Zulip):

Yeah, there's a special-casing special-case in there

matklad (Dec 14 2020 at 14:07, on Zulip):

lower_comma_list

Jonas Schievink [he/him] (Dec 14 2020 at 14:07, on Zulip):

ah, yeah

matklad (Dec 14 2020 at 14:07, on Zulip):

although, it should be generic over comma token?

matklad (Dec 14 2020 at 14:08, on Zulip):

Perhaps you need () around the comma list?

Jonas Schievink [he/him] (Dec 14 2020 at 14:09, on Zulip):

yeah, looks like it. although macro rules aren't optional.

matklad (Dec 14 2020 at 14:10, on Zulip):

that needs to be a validation error I think

Jonas Schievink [he/him] (Dec 14 2020 at 17:21, on Zulip):

Hmm, this generates the wrong API for MacroArm

MacroArm =
  TokenTree '=>' TokenTree

The resulting MacroArm type only has a single fn token_tree(&self) -> Option<TokenTree>

matklad (Dec 14 2020 at 17:22, on Zulip):

https://github.com/rust-analyzer/ungrammar/blob/d41a4110554501314bdfcabe5b41971abda99397/rust.ungram#L382-L389

matklad (Dec 14 2020 at 17:22, on Zulip):

I think you need

MacroArm =
  pattern:TokenTree '=>' template:TokenTree
Jonas Schievink [he/him] (Dec 14 2020 at 17:22, on Zulip):

aah, nice

Jonas Schievink [he/him] (Dec 14 2020 at 18:03, on Zulip):

I think I'll roll back the addition of MacroArm, it requires too many changes in mbe

matklad (Dec 14 2020 at 19:23, on Zulip):

yeah...

Last update: Jul 26 2021 at 13:15UTC