Skip to content
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

Update syn and bump version #353

Merged
merged 1 commit into from Nov 5, 2018
Merged

Update syn and bump version #353

merged 1 commit into from Nov 5, 2018

Conversation

@Eijebong
Copy link
Member

Eijebong commented Oct 17, 2018

No description provided.

@Eijebong
Copy link
Member Author

Eijebong commented Oct 17, 2018

@dtolnay Mind having a quick look ? Especially the fork parts

impl Parse for Tag {
fn parse(input: ParseStream) -> Result<Self> {
input.parse::<Token![<]>()?;
let closing = input.parse::<Option<Token![/]>>()?;

This comment has been minimized.

@dtolnay

dtolnay Oct 17, 2018

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()?;
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>() {

This comment has been minimized.

@dtolnay

dtolnay Oct 17, 2018

I would write this as:

let name = match input.call(Ident::parse_any)? {
    ref wildcard if wildcard == "_" => None,
    other => Some(other),
};
None
};
input.parse::<Token![>]>()?;
Ok(Tag {
kind: if closing.is_some() { TagKind::EndTag } else { TagKind::StartTag },

This comment has been minimized.

@dtolnay

dtolnay Oct 17, 2018

This needs to be unindented by one level.

));
impl Parse for LHS {
fn parse(input: ParseStream) -> Result<Self> {
if let Ok(p) = input.fork().parse::<syn::Pat>() {

This comment has been minimized.

@dtolnay

dtolnay Oct 17, 2018

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))
}
};
let lhs = input.parse::<LHS>()?;
input.parse::<Token![=>]>()?;
let rhs = if let Ok(expr) = input.fork().parse() {

This comment has been minimized.

@dtolnay

dtolnay Oct 17, 2018

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.

input.parse::<Token![else]>()?;
RHS::Else
};
input.parse::<Option<Token![,]>>()?;

This comment has been minimized.

@dtolnay

dtolnay Oct 17, 2018

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 {

This comment has been minimized.

@dtolnay

dtolnay Oct 17, 2018

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.

This comment has been minimized.

@Eijebong

Eijebong Oct 17, 2018

Author Member

Way better now. Thanks a lot

@Eijebong Eijebong force-pushed the Eijebong:synup branch from 713b8fe to a3eda83 Oct 17, 2018
@Eijebong Eijebong mentioned this pull request Nov 1, 2018
@SimonSapin
Copy link
Member

SimonSapin commented Nov 5, 2018

@bors-servo r=dtolnay+SimonSapin

@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2018

📌 Commit a3eda83 has been approved by dtolnay+SimonSapin

@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2018

Testing commit a3eda83 with merge 99ae7d3...

bors-servo added a commit that referenced this pull request Nov 5, 2018
Update syn and bump version
@bors-servo
Copy link
Contributor

bors-servo commented Nov 5, 2018

☀️ Test successful - status-travis
Approved by: dtolnay+SimonSapin
Pushing 99ae7d3 to master...

@bors-servo bors-servo merged commit a3eda83 into servo:master Nov 5, 2018
1 check passed
1 check passed
homu Test successful
Details
@SimonSapin
Copy link
Member

SimonSapin commented Nov 5, 2018

bors-servo added a commit to servo/servo that referenced this pull request Nov 30, 2018
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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.