-
Notifications
You must be signed in to change notification settings - Fork 250
Update syn and bump version #353
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
Conversation
@dtolnay Mind having a quick look ? Especially the |
html5ever/macros/match_token.rs
Outdated
impl Parse for Tag { | ||
fn parse(input: ParseStream) -> Result<Self> { | ||
input.parse::<Token![<]>()?; | ||
let closing = input.parse::<Option<Token![/]>>()?; |
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 would write this with the type on the left because ![/]>>()?;
is over the threshold of reasonable adjacent punctuation.
let closing: Option<Token![/]> = input.parse()?;
html5ever/macros/match_token.rs
Outdated
fn parse(input: ParseStream) -> Result<Self> { | ||
input.parse::<Token![<]>()?; | ||
let closing = input.parse::<Option<Token![/]>>()?; | ||
let name = if let Ok(i) = input.parse::<syn::Ident>() { |
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 would write this as:
let name = match input.call(Ident::parse_any)? {
ref wildcard if wildcard == "_" => None,
other => Some(other),
};
html5ever/macros/match_token.rs
Outdated
}; | ||
input.parse::<Token![>]>()?; | ||
Ok(Tag { | ||
kind: if closing.is_some() { TagKind::EndTag } else { TagKind::StartTag }, |
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 needs to be unindented by one level.
html5ever/macros/match_token.rs
Outdated
)); | ||
impl Parse for LHS { | ||
fn parse(input: ParseStream) -> Result<Self> { | ||
if let Ok(p) = input.fork().parse::<syn::Pat>() { |
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 would write this as:
if input.peek(Token![<]) {
let mut tags = Vec::new();
while !input.peek(Token![=>]) {
tags.push(input.parse()?);
}
Ok(LHS::Tags(tags))
} else {
let p: Pat = input.parse()?;
Ok(LHS::Pattern(p))
}
html5ever/macros/match_token.rs
Outdated
}; | ||
let lhs = input.parse::<LHS>()?; | ||
input.parse::<Token![=>]>()?; | ||
let rhs = if let Ok(expr) = input.fork().parse() { |
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 probably not doing what you intended. This is bleeding over into the next arm and relying on the fact that { /* ... */ } < TAG > =>
is not a valid expression -- because =>
is not a valid beginning of expression. You should parse each arm without parsing the LHS of the next arm as part of the previous arm's expression.
html5ever/macros/match_token.rs
Outdated
input.parse::<Token![else]>()?; | ||
RHS::Else | ||
}; | ||
input.parse::<Option<Token![,]>>()?; |
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 too lenient and allows commas to be omitted where they should be required. Have the parser require a comma after else
and after expressions that are not block, unless in the last arm.
} | ||
) | ||
)); | ||
impl Parse for MatchToken { |
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.
Regarding fork -- I don't see anything in the input syntax that would require fork. All of this can be parsed with two tokens of lookahead. Please implement the parsing without using fork to make debugging easier and error messages better.
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.
Way better now. Thanks a lot
@bors-servo r=dtolnay+SimonSapin |
📌 Commit a3eda83 has been approved by |
Update syn and bump version
☀️ Test successful - status-travis |
Update syn - servo/html5ever#353 - servo/rust-cssparser#229 - servo/webrender#3264 - servo/media#162 - rust-lang/rust-bindgen#1409 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/22085) <!-- Reviewable:end -->
No description provided.