diff options
| author | bors <bors@rust-lang.org> | 2017-11-07 18:04:33 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-11-07 18:04:33 +0000 |
| commit | 7f6417e9b72de63666fd92caf1a6b96a778b60ed (patch) | |
| tree | cbdb0b5298e76188aea3582191e2ad82dfc811b9 /src/libsyntax | |
| parent | 7ade24f67201531778e7674b4b63ebf1a23c9643 (diff) | |
| parent | 0d53ecd0c788d5c492cf5023c8c76420ef349244 (diff) | |
| download | rust-7f6417e9b72de63666fd92caf1a6b96a778b60ed.tar.gz rust-7f6417e9b72de63666fd92caf1a6b96a778b60ed.zip | |
Auto merge of #45822 - kennytm:rollup, r=kennytm
Rollup of 9 pull requests - Successful merges: #45470, #45588, #45682, #45714, #45751, #45764, #45778, #45782, #45784 - Failed merges:
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/print/pprust.rs | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 227db93cf65..5cb8e8694cf 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1987,6 +1987,15 @@ impl<'a> State<'a> { Fixity::None => (prec + 1, prec + 1), }; + let left_prec = match (&lhs.node, op.node) { + // These cases need parens: `x as i32 < y` has the parser thinking that `i32 < y` is + // the beginning of a path type. It starts trying to parse `x as (i32 < y ...` instead + // of `(x as i32) < ...`. We need to convince it _not_ to do that. + (&ast::ExprKind::Cast { .. }, ast::BinOpKind::Lt) | + (&ast::ExprKind::Cast { .. }, ast::BinOpKind::Shl) => parser::PREC_FORCE_PAREN, + _ => left_prec, + }; + self.print_expr_maybe_paren(lhs, left_prec)?; self.s.space()?; self.word_space(op.node.to_string())?; |
