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

Corrects issue #28777 by removing, once a binary operator is found, the #30375

Merged
merged 4 commits into from
Dec 31, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions src/libsyntax/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2813,16 +2813,25 @@ impl<'a> Parser<'a> {


let rhs = try!(match op.fixity() {
Fixity::Right => self.with_res(restrictions, |this|{
this.parse_assoc_expr_with(op.precedence(), LhsExpr::NotYetParsed)
Fixity::Right => self.with_res(
restrictions & !Restrictions::RESTRICTION_STMT_EXPR,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be written as restrictions - Restrictions::RESTRICTION_STMT_EXPR, AFAIK.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are correct. I missed the support for - as set difference in bitflags. Thank you.

|this|{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be a space between | and {.

this.parse_assoc_expr_with(op.precedence(),
LhsExpr::NotYetParsed)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be indented one more time to the right (or aligned with op.precedence()).

}),
Fixity::Left => self.with_res(restrictions, |this|{
this.parse_assoc_expr_with(op.precedence() + 1, LhsExpr::NotYetParsed)
Fixity::Left => self.with_res(
restrictions & !Restrictions::RESTRICTION_STMT_EXPR,
|this|{
this.parse_assoc_expr_with(op.precedence() + 1,
LhsExpr::NotYetParsed)
}),
// We currently have no non-associative operators that are not handled above by
// the special cases. The code is here only for future convenience.
Fixity::None => self.with_res(restrictions, |this|{
this.parse_assoc_expr_with(op.precedence() + 1, LhsExpr::NotYetParsed)
Fixity::None => self.with_res(
restrictions & !Restrictions::RESTRICTION_STMT_EXPR,
|this|{
this.parse_assoc_expr_with(op.precedence() + 1,
LhsExpr::NotYetParsed)
}),
});

Expand Down