Skip to content

Commit cdeaff9

Browse files
try only deconstruct
1 parent 52882f6 commit cdeaff9

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

compiler/rustc_middle/src/thir/visit.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ pub fn walk_expr<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
4141
expr: &'thir Expr<'tcx>,
4242
) {
4343
use ExprKind::*;
44-
match expr.kind {
44+
let Expr { kind, ty: _, temp_lifetime: _, span: _ } = expr;
45+
match kind {
4546
Scope { value, region_scope: _, lint_level: _ } => {
4647
visitor.visit_expr(&visitor.thir()[value])
4748
}
@@ -191,7 +192,8 @@ pub fn walk_stmt<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
191192
visitor: &mut V,
192193
stmt: &'thir Stmt<'tcx>,
193194
) {
194-
match &stmt.kind {
195+
let Stmt { kind } = stmt;
196+
match kind {
195197
StmtKind::Expr { expr, scope: _ } => visitor.visit_expr(&visitor.thir()[*expr]),
196198
StmtKind::Let {
197199
initializer,
@@ -217,10 +219,12 @@ pub fn walk_block<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
217219
visitor: &mut V,
218220
block: &'thir Block,
219221
) {
220-
for &stmt in &*block.stmts {
222+
let Block { stmts, expr, targeted_by_break: _, region_scope: _, span: _, safety_mode: _ } =
223+
block;
224+
for &stmt in &*stmts {
221225
visitor.visit_stmt(&visitor.thir()[stmt]);
222226
}
223-
if let Some(expr) = block.expr {
227+
if let Some(expr) = expr {
224228
visitor.visit_expr(&visitor.thir()[expr]);
225229
}
226230
}
@@ -229,11 +233,12 @@ pub fn walk_arm<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
229233
visitor: &mut V,
230234
arm: &'thir Arm<'tcx>,
231235
) {
232-
if let Some(expr) = arm.guard {
236+
let Arm { guard, pattern, body, lint_level: _, span: _, scope: _ } = arm;
237+
if let Some(expr) = guard {
233238
visitor.visit_expr(&visitor.thir()[expr])
234239
}
235-
visitor.visit_pat(&arm.pattern);
236-
visitor.visit_expr(&visitor.thir()[arm.body]);
240+
visitor.visit_pat(pattern);
241+
visitor.visit_expr(&visitor.thir()[body]);
237242
}
238243

239244
pub fn walk_pat<'thir, 'tcx: 'thir, V: Visitor<'thir, 'tcx>>(
@@ -249,7 +254,8 @@ pub(crate) fn for_each_immediate_subpat<'a, 'tcx>(
249254
pat: &'a Pat<'tcx>,
250255
mut callback: impl FnMut(&'a Pat<'tcx>),
251256
) {
252-
match &pat.kind {
257+
let Pat { kind, ty: _, span: _ } = pat;
258+
match kind {
253259
PatKind::Missing
254260
| PatKind::Wild
255261
| PatKind::Binding { subpattern: None, .. }

0 commit comments

Comments
 (0)