-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Stop leaking identifiers in parser generator and use more DSLv2 types #977
Stop leaking identifiers in parser generator and use more DSLv2 types #977
Conversation
|
}; | ||
use crate::parser::versioned::{Versioned as _, VersionedQuote as _}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Part of #638, ticks the "stop leaking identifiers" box
codegen_language_definition::model::Identifier
in PG rather than rely on&'static str
s from DSL v1, so we don't leak anymore and we start using the DSLv2 type in PGParserModel
used 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 finalParserModel
for 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.