Skip to content

Commit a580b4e

Browse files
authored
Rollup merge of rust-lang#121619 - RossSmyth:pfix_match, r=petrochenkov
Experimental feature postfix match This has a basic experimental implementation for the RFC postfix match (rust-lang/rfcs#3295, rust-lang#121618). [Liaison is](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/Postfix.20Match.20Liaison/near/423301844) ```@scottmcm``` with the lang team's [experimental feature gate process](https://github.com/rust-lang/lang-team/blob/master/src/how_to/experiment.md). This feature has had an RFC for a while, and there has been discussion on it for a while. It would probably be valuable to see it out in the field rather than continue discussing it. This feature also allows to see how popular postfix expressions like this are for the postfix macros RFC, as those will take more time to implement. It is entirely implemented in the parser, so it should be relatively easy to remove if needed. This PR is split in to 5 commits to ease review. 1. The implementation of the feature & gating. 2. Add a MatchKind field, fix uses, fix pretty. 3. Basic rustfmt impl, as rustfmt crashes upon seeing this syntax without a fix. 4. Add new MatchSource to HIR for Clippy & other HIR consumers
2 parents 0e62b18 + c36d5e3 commit a580b4e

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

clippy_lints/src/redundant_else.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ impl<'ast> Visitor<'ast> for BreakVisitor {
105105
fn visit_expr(&mut self, expr: &'ast Expr) {
106106
self.is_break = match expr.kind {
107107
ExprKind::Break(..) | ExprKind::Continue(..) | ExprKind::Ret(..) => true,
108-
ExprKind::Match(_, ref arms) => arms.iter().all(|arm|
108+
ExprKind::Match(_, ref arms, _) => arms.iter().all(|arm|
109109
arm.body.is_none() || arm.body.as_deref().is_some_and(|body| self.check_expr(body))
110110
),
111111
ExprKind::If(_, ref then, Some(ref els)) => self.check_block(then) && self.check_expr(els),

clippy_lints/src/suspicious_operation_groupings.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ fn ident_difference_expr_with_base_location(
552552
| (Gen(_, _, _), Gen(_, _, _))
553553
| (Block(_, _), Block(_, _))
554554
| (Closure(_), Closure(_))
555-
| (Match(_, _), Match(_, _))
555+
| (Match(_, _, _), Match(_, _, _))
556556
| (Loop(_, _, _), Loop(_, _, _))
557557
| (ForLoop { .. }, ForLoop { .. })
558558
| (While(_, _, _), While(_, _, _))

clippy_utils/src/ast_utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ pub fn eq_expr(l: &Expr, r: &Expr) -> bool {
198198
},
199199
(AssignOp(lo, lp, lv), AssignOp(ro, rp, rv)) => lo.node == ro.node && eq_expr(lp, rp) && eq_expr(lv, rv),
200200
(Field(lp, lf), Field(rp, rf)) => eq_id(*lf, *rf) && eq_expr(lp, rp),
201-
(Match(ls, la), Match(rs, ra)) => eq_expr(ls, rs) && over(la, ra, eq_arm),
201+
(Match(ls, la, lkind), Match(rs, ra, rkind)) => (lkind == rkind) && eq_expr(ls, rs) && over(la, ra, eq_arm),
202202
(
203203
Closure(box ast::Closure {
204204
binder: lb,

0 commit comments

Comments
 (0)