Skip to content

Commit

Permalink
Merge pull request #823 from dtolnay/expr
Browse files Browse the repository at this point in the history
Fix precedence of attributes on binary expression
  • Loading branch information
dtolnay committed May 25, 2020
2 parents 5243a9b + 4e70a0e commit b9498c7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 6 additions & 2 deletions src/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,12 @@ pub mod parsing {
) -> Result<Stmt> {
let mut e = expr::parsing::expr_early(input)?;

attrs.extend(e.replace_attrs(Vec::new()));
e.replace_attrs(attrs);
let mut attr_target = &mut e;
while let Expr::Binary(e) = attr_target {
attr_target = &mut e.left;
}
attrs.extend(attr_target.replace_attrs(Vec::new()));
attr_target.replace_attrs(attrs);

if input.peek(Token![;]) {
return Ok(Stmt::Semi(e, input.parse()?));
Expand Down
4 changes: 0 additions & 4 deletions tests/repo/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,6 @@ use walkdir::DirEntry;
const REVISION: &str = "46e85b4328fe18492894093c1092dfe509df4370";

static EXCLUDE: &[&str] = &[
// TODO: attribute on binary expr
// https://github.com/dtolnay/syn/issues/820
"tools/clippy/tests/ui/cfg_attr_rustfmt.rs",

// TODO: type alias item with trait bound
// https://github.com/dtolnay/syn/issues/821
"test/ui/parser/item-free-type-bounds-syntactic-pass.rs",
Expand Down

0 comments on commit b9498c7

Please sign in to comment.