Stop leaking identifiers in parser generator and use more DSLv2 types#977
Conversation
|
| Labeled, ParserDefinitionNode, ParserDefinitionRef, TriviaParserDefinitionRef, | ||
| }; | ||
| use crate::parser::versioned::{Versioned as _, VersionedQuote as _}; | ||
|
|
There was a problem hiding this comment.
I suggest removing the as _ from import statements, to enable unused warnings when it is no longer needed.
There was a problem hiding this comment.
That's not true: after removing the usages I still get correct unused import: `Versioned as _` rustc diagnostic; like I mentioned, this is somewhat special-cased by rustc.
There was a problem hiding this comment.
this is somewhat special-cased by rustc
hmmm, this is surprising. it goes against how underscore behaves in other places! thanks for pointing out 🤔
I wonder what is the benefit of that syntax then, rather than just use Versioned;? in this case, the underscore is meaningless to rustc?
There was a problem hiding this comment.
It exists when you want to import a trait but also use a type with the same name - in this case, using the trait in scope allows you to use the trait methods but you can still use the other data type with a given name.
Part of #638, ticks the "stop leaking identifiers" box
codegen_language_definition::model::Identifierin PG rather than rely on&'static strs from DSL v1, so we don't leak anymore and we start using the DSLv2 type in PGParserModelused in the MVC fashion for PG codegenThe remaining work is to stop using the DSLv1
Grammar(Visitor)but rather directly collect items from and use the DSLv2 model to construct the finalParserModelfor codegen.I wouldn't look too much into details like duplicated doc comments for the state accumulator/model because it's going away in the next PR, similarly naming for stuff like
Versioned(Quote)that's also renamed temporarily and will be changed/removed since we will move off the DSLv1 model.