The loosest precedence exposed on `expr`'s *left spine*, the mirror of [`right_edge`]. For a *right* operand (an operator on its left), this is what decides parenthesization: a left-associative operator printed to its left reaches into the left spine and re-associates if that spine exposes a precedence at or below the operator's. The top operator alone is not enough, because a left-nested chain ca
(expr: &Expr<T>)
| 784 | /// own token on the left (a prefix operator, a keyword, `(…)`, a literal) are |
| 785 | /// `ATOM`. |
| 786 | fn left_edge<T: AstInfo>(expr: &Expr<T>) -> u8 { |
| 787 | match expr { |
| 788 | // Left-transparent infixes / postfix-keyword constructs: the subject (or |
| 789 | // left operand) sits on the left spine, so descend into it. |
| 790 | Expr::Or { left, .. } => prec::OR.min(left_edge(left)), |
| 791 | Expr::And { left, .. } => prec::AND.min(left_edge(left)), |
| 792 | Expr::Op { |
| 793 | op, |
| 794 | expr1, |
| 795 | expr2: Some(_), |
| 796 | } => binary_op_precedence(op).min(left_edge(expr1)), |
| 797 | Expr::IsExpr { expr, .. } => prec::IS.min(left_edge(expr)), |
| 798 | Expr::AnyExpr { left, .. } |
| 799 | | Expr::AllExpr { left, .. } |
| 800 | | Expr::AnySubquery { left, .. } |
| 801 | | Expr::AllSubquery { left, .. } => prec::CMP.min(left_edge(left)), |
| 802 | Expr::Like { expr, .. } |
| 803 | | Expr::Between { expr, .. } |
| 804 | | Expr::InList { expr, .. } |
| 805 | | Expr::InSubquery { expr, .. } => prec::LIKE.min(left_edge(expr)), |
| 806 | // Everything else leads with its own token on the left: a prefix |
| 807 | // operator (`-`/`+`/`~`/`NOT`), a keyword, `(…)`, `ARRAY[…]`, a literal, |
| 808 | // or a `COLLATE`/`::`/`[…]` whose own operand the printer parenthesizes |
| 809 | // when it isn't self-delimiting. Nothing to the left binds into it. |
| 810 | _ => prec::ATOM, |
| 811 | } |
| 812 | } |
| 813 | |
| 814 | /// Write `operand` for a binary operator, parenthesizing it iff `needs_parens`. |
| 815 | fn write_binary_operand<W: fmt::Write, T: AstInfo>( |
no test coverage detected