diff --git a/compiler/rustc_mir_build/src/thir/print.rs b/compiler/rustc_mir_build/src/thir/print.rs index 5330e3397db8e..ddb56a04c308d 100644 --- a/compiler/rustc_mir_build/src/thir/print.rs +++ b/compiler/rustc_mir_build/src/thir/print.rs @@ -357,7 +357,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> { print_indented!(self, format!("pat: {:?}", pat), depth_lvl + 1); print_indented!(self, "}", depth_lvl); } - Match { scrutinee, arms, .. } => { + Match { scrutinee, arms, match_source } => { print_indented!(self, "Match {", depth_lvl); print_indented!(self, "scrutinee:", depth_lvl + 1); self.print_expr(*scrutinee, depth_lvl + 2); @@ -367,6 +367,7 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> { self.print_arm(*arm_id, depth_lvl + 2); } print_indented!(self, "]", depth_lvl + 1); + print_indented!(self, format!("match_source: {:?}", match_source), depth_lvl + 1); print_indented!(self, "}", depth_lvl); } Block { block } => self.print_block(*block, depth_lvl), diff --git a/tests/ui/thir-print/thir-tree-match-for.rs b/tests/ui/thir-print/thir-tree-match-for.rs new file mode 100644 index 0000000000000..b1f9009ed6d35 --- /dev/null +++ b/tests/ui/thir-print/thir-tree-match-for.rs @@ -0,0 +1,32 @@ +//@ check-pass +//@ compile-flags: -Zunpretty=thir-tree +//@ normalize-stdout: "\[[a-z0-9]{4}\]" -> "" +//@ normalize-stdout: "DefId\(\d+:\d+" -> "DefId(N:M" + +fn match_non_loop(x:u32, y: u32) { + match x { + 0 | 1 => 0, + 2..3 => 1, + y => 2, + }; +} + +fn match_from_for(x: u32, y: u32) { + for i in x..y { + i; + } +} + +// same resulting structure +fn match_loop_nonfor(x: u32, y: u32) { + match IntoIterator::into_iter(x..y) { + mut iter => loop { + match Iterator::next(&mut iter) { + Option::None => break, + Option::Some(i) => { i; }, + }; + } + } +} + +fn main() {} diff --git a/tests/ui/thir-print/thir-tree-match-for.stdout b/tests/ui/thir-print/thir-tree-match-for.stdout new file mode 100644 index 0000000000000..62a8a0978ea75 --- /dev/null +++ b/tests/ui/thir-print/thir-tree-match-for.stdout @@ -0,0 +1,1419 @@ +DefId(N:M ~ thir_tree_match_for::match_non_loop): +params: [ + Param { + ty: u32 + ty_span: Some($DIR/thir-tree-match-for.rs:6:21: 6:24 (#0)) + self_kind: None + hir_id: Some(HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).1)) + param: Some( + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:6:19: 6:20 (#0) + kind: PatKind { + Binding { + name: "x" + mode: BindingMode(No, Not) + var: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).2)) + ty: u32 + is_primary: true + is_shorthand: false + subpattern: None + } + } + } + ) + } + Param { + ty: u32 + ty_span: Some($DIR/thir-tree-match-for.rs:6:29: 6:32 (#0)) + self_kind: None + hir_id: Some(HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).3)) + param: Some( + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:6:26: 6:27 (#0) + kind: PatKind { + Binding { + name: "y" + mode: BindingMode(No, Not) + var: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).4)) + ty: u32 + is_primary: true + is_shorthand: false + subpattern: None + } + } + } + ) + } +] +body: + Expr { + ty: () + temp_scope_id: 25 + span: $DIR/thir-tree-match-for.rs:6:34: 12:2 (#0) + kind: + Scope { + region_scope: Node(25) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).25) + value: + Expr { + ty: () + temp_scope_id: 25 + span: $DIR/thir-tree-match-for.rs:6:34: 12:2 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/thir-tree-match-for.rs:6:34: 12:2 (#0) + region_scope: Node(5) + safety_mode: Safe + stmts: [ + Stmt { + kind: Expr { + scope: Node(24) + expr: + Expr { + ty: i32 + temp_scope_id: 6 + span: $DIR/thir-tree-match-for.rs:7:3: 11:4 (#0) + kind: + Scope { + region_scope: Node(6) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).6) + value: + Expr { + ty: i32 + temp_scope_id: 6 + span: $DIR/thir-tree-match-for.rs:7:3: 11:4 (#0) + kind: + Match { + scrutinee: + Expr { + ty: u32 + temp_scope_id: 7 + span: $DIR/thir-tree-match-for.rs:7:9: 7:10 (#0) + kind: + Scope { + region_scope: Node(7) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).7) + value: + Expr { + ty: u32 + temp_scope_id: 7 + span: $DIR/thir-tree-match-for.rs:7:9: 7:10 (#0) + kind: + VarRef { + id: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).2)) + } + } + } + } + arms: [ + Arm { + pattern: + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:8:5: 8:10 (#0) + kind: PatKind { + Or { + pats: [ + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:8:5: 8:6 (#0) + kind: PatKind { + Constant { + value: 0_u32 + } + } + } + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:8:9: 8:10 (#0) + kind: PatKind { + Constant { + value: 1_u32 + } + } + } + ] + } + } + } + guard: None + body: + Expr { + ty: i32 + temp_scope_id: 15 + span: $DIR/thir-tree-match-for.rs:8:14: 8:15 (#0) + kind: + Scope { + region_scope: Node(15) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).15) + value: + Expr { + ty: i32 + temp_scope_id: 15 + span: $DIR/thir-tree-match-for.rs:8:14: 8:15 (#0) + kind: + Literal( lit: Spanned { node: Int(Pu128(0), Unsuffixed), span: $DIR/thir-tree-match-for.rs:8:14: 8:15 (#0) }, neg: false) + + } + } + } + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).14) + scope: Node(14) + span: $DIR/thir-tree-match-for.rs:8:5: 8:15 (#0) + } + Arm { + pattern: + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:9:5: 9:9 (#0) + extra: PatExtra { + expanded_const: None + ascriptions: [] + } + kind: PatKind { + Range ( PatRange { lo: Finite(Leaf(0x00000002)), hi: Finite(Leaf(0x00000003)), end: Excluded, ty: u32 } ) + } + } + guard: None + body: + Expr { + ty: i32 + temp_scope_id: 20 + span: $DIR/thir-tree-match-for.rs:9:14: 9:15 (#0) + kind: + Scope { + region_scope: Node(20) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).20) + value: + Expr { + ty: i32 + temp_scope_id: 20 + span: $DIR/thir-tree-match-for.rs:9:14: 9:15 (#0) + kind: + Literal( lit: Spanned { node: Int(Pu128(1), Unsuffixed), span: $DIR/thir-tree-match-for.rs:9:14: 9:15 (#0) }, neg: false) + + } + } + } + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).19) + scope: Node(19) + span: $DIR/thir-tree-match-for.rs:9:5: 9:15 (#0) + } + Arm { + pattern: + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:10:8: 10:9 (#0) + kind: PatKind { + Binding { + name: "y" + mode: BindingMode(No, Not) + var: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).21)) + ty: u32 + is_primary: true + is_shorthand: false + subpattern: None + } + } + } + guard: None + body: + Expr { + ty: i32 + temp_scope_id: 23 + span: $DIR/thir-tree-match-for.rs:10:14: 10:15 (#0) + kind: + Scope { + region_scope: Node(23) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).23) + value: + Expr { + ty: i32 + temp_scope_id: 23 + span: $DIR/thir-tree-match-for.rs:10:14: 10:15 (#0) + kind: + Literal( lit: Spanned { node: Int(Pu128(2), Unsuffixed), span: $DIR/thir-tree-match-for.rs:10:14: 10:15 (#0) }, neg: false) + + } + } + } + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_non_loop).22) + scope: Node(22) + span: $DIR/thir-tree-match-for.rs:10:8: 10:15 (#0) + } + ] + match_source: Normal + } + } + } + } + } + } + ] + expr: [] + } + } + } + } + + +DefId(N:M ~ thir_tree_match_for::match_from_for): +params: [ + Param { + ty: u32 + ty_span: Some($DIR/thir-tree-match-for.rs:14:22: 14:25 (#0)) + self_kind: None + hir_id: Some(HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).1)) + param: Some( + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:14:19: 14:20 (#0) + kind: PatKind { + Binding { + name: "x" + mode: BindingMode(No, Not) + var: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).2)) + ty: u32 + is_primary: true + is_shorthand: false + subpattern: None + } + } + } + ) + } + Param { + ty: u32 + ty_span: Some($DIR/thir-tree-match-for.rs:14:30: 14:33 (#0)) + self_kind: None + hir_id: Some(HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).3)) + param: Some( + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:14:27: 14:28 (#0) + kind: PatKind { + Binding { + name: "y" + mode: BindingMode(No, Not) + var: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).4)) + ty: u32 + is_primary: true + is_shorthand: false + subpattern: None + } + } + } + ) + } +] +body: + Expr { + ty: () + temp_scope_id: 45 + span: $DIR/thir-tree-match-for.rs:14:35: 18:2 (#0) + kind: + Scope { + region_scope: Node(45) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).45) + value: + Expr { + ty: () + temp_scope_id: 45 + span: $DIR/thir-tree-match-for.rs:14:35: 18:2 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/thir-tree-match-for.rs:14:35: 18:2 (#0) + region_scope: Node(5) + safety_mode: Safe + stmts: [] + expr: + Expr { + ty: () + temp_scope_id: 44 + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + kind: + Scope { + region_scope: Node(44) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).44) + value: + Expr { + ty: () + temp_scope_id: 44 + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + kind: + Use { + source: + Expr { + ty: () + temp_scope_id: 43 + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + kind: + Scope { + region_scope: Node(43) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).43) + value: + Expr { + ty: () + temp_scope_id: 43 + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + kind: + Match { + scrutinee: + Expr { + ty: std::ops::Range + temp_scope_id: 42 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Scope { + region_scope: Node(42) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).42) + value: + Expr { + ty: std::ops::Range + temp_scope_id: 42 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Call { + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + from_hir_call: true + fn_span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + fun: + Expr { + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + temp_scope_id: 41 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Scope { + region_scope: Node(41) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).41) + value: + Expr { + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + temp_scope_id: 41 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + ZstLiteral(user_ty: None) + } + } + } + args: [ + Expr { + ty: std::ops::Range + temp_scope_id: 6 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#4) + kind: + Scope { + region_scope: Node(6) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).6) + value: + Expr { + ty: std::ops::Range + temp_scope_id: 6 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#4) + kind: + Adt { + adt_def: + AdtDef { + did: DefId(N:M ~ core::ops::range::Range) + variants: [VariantDef { def_id: DefId(N:M ~ core::ops::range::Range), ctor: None, name: "Range", discr: Relative(0), fields: [FieldDef { did: DefId(N:M ~ core::ops::range::Range::start), name: "start", vis: Public, safety: Safe, value: None }, FieldDef { did: DefId(N:M ~ core::ops::range::Range::end), name: "end", vis: Public, safety: Safe, value: None }], tainted: None, flags: }] + flags: IS_STRUCT + repr: ReprOptions { int: None, align: None, pack: None, flags: , scalable: None, field_shuffle_seed: 3488599726022204405 } + } + variant_index: 0 + args: [u32] + user_ty: None + field 0: + Expr { + ty: u32 + temp_scope_id: 7 + span: $DIR/thir-tree-match-for.rs:15:12: 15:13 (#0) + kind: + Scope { + region_scope: Node(7) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).7) + value: + Expr { + ty: u32 + temp_scope_id: 7 + span: $DIR/thir-tree-match-for.rs:15:12: 15:13 (#0) + kind: + VarRef { + id: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).2)) + } + } + } + } + field 1: + Expr { + ty: u32 + temp_scope_id: 10 + span: $DIR/thir-tree-match-for.rs:15:15: 15:16 (#0) + kind: + Scope { + region_scope: Node(10) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).10) + value: + Expr { + ty: u32 + temp_scope_id: 10 + span: $DIR/thir-tree-match-for.rs:15:15: 15:16 (#0) + kind: + VarRef { + id: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).4)) + } + } + } + } + base: None + } + } + } + } + ] + } + } + } + } + arms: [ + Arm { + pattern: + Pat { + ty: std::ops::Range + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: PatKind { + Binding { + name: "iter" + mode: BindingMode(No, Mut) + var: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).29)) + ty: std::ops::Range + is_primary: true + is_shorthand: false + subpattern: None + } + } + } + guard: None + body: + Expr { + ty: () + temp_scope_id: 15 + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + kind: + Scope { + region_scope: Node(15) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).15) + value: + Expr { + ty: () + temp_scope_id: 15 + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + kind: + Loop ( + body: + Expr { + ty: () + temp_scope_id: 38 + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + kind: + Block { + targeted_by_break: false + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + region_scope: Node(38) + safety_mode: Safe + stmts: [ + Stmt { + kind: Expr { + scope: Node(37) + expr: + Expr { + ty: () + temp_scope_id: 36 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Scope { + region_scope: Node(36) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).36) + value: + Expr { + ty: () + temp_scope_id: 36 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Match { + scrutinee: + Expr { + ty: std::option::Option + temp_scope_id: 35 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Scope { + region_scope: Node(35) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).35) + value: + Expr { + ty: std::option::Option + temp_scope_id: 35 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Call { + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + from_hir_call: true + fn_span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + fun: + Expr { + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + temp_scope_id: 34 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Scope { + region_scope: Node(34) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).34) + value: + Expr { + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + temp_scope_id: 34 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + ZstLiteral(user_ty: None) + } + } + } + args: [ + Expr { + ty: &'{erased} mut std::ops::Range + temp_scope_id: 32 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Scope { + region_scope: Node(32) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).32) + value: + Expr { + ty: &'{erased} mut std::ops::Range + temp_scope_id: 32 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Borrow ( + borrow_kind: Mut { kind: TwoPhaseBorrow } + arg: + Expr { + ty: std::ops::Range + temp_scope_id: 32 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Deref { + Expr { + ty: &'{erased} mut std::ops::Range + temp_scope_id: 32 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Borrow ( + borrow_kind: Mut { kind: Default } + arg: + Expr { + ty: std::ops::Range + temp_scope_id: 31 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + Scope { + region_scope: Node(31) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).31) + value: + Expr { + ty: std::ops::Range + temp_scope_id: 31 + span: $DIR/thir-tree-match-for.rs:15:12: 15:16 (#7) + kind: + VarRef { + id: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).29)) + } + } + } + } + ) + } + } + } + ) + } + } + } + ] + } + } + } + } + arms: [ + Arm { + pattern: + Pat { + ty: std::option::Option + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + kind: PatKind { + Variant { + adt_def: + AdtDef { + did: DefId(N:M ~ core::option::Option) + variants: [VariantDef { def_id: DefId(N:M ~ core::option::Option::None), ctor: Some((Const, DefId(N:M ~ core::option::Option::None::{constructor#0}))), name: "None", discr: Relative(0), fields: [], tainted: None, flags: }, VariantDef { def_id: DefId(N:M ~ core::option::Option::Some), ctor: Some((Fn, DefId(N:M ~ core::option::Option::Some::{constructor#0}))), name: "Some", discr: Relative(1), fields: [FieldDef { did: DefId(N:M ~ core::option::Option::Some::0), name: "0", vis: Public, safety: Safe, value: None }], tainted: None, flags: }] + flags: IS_ENUM + repr: ReprOptions { int: None, align: None, pack: None, flags: , scalable: None, field_shuffle_seed: 11004682594870345353 } + } + args: [u32] + variant_index: 0 + subpatterns: [] + } + } + } + guard: None + body: + Expr { + ty: () + temp_scope_id: 16 + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + kind: + Scope { + region_scope: Node(16) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).16) + value: + Expr { + ty: () + temp_scope_id: 16 + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + kind: + NeverToAny { + source: + Expr { + ty: ! + temp_scope_id: 16 + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + kind: + Break ( + label: Node(15) + ) + } + } + } + } + } + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).19) + scope: Node(19) + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + } + Arm { + pattern: + Pat { + ty: std::option::Option + span: $DIR/thir-tree-match-for.rs:15:7: 15:8 (#7) + kind: PatKind { + Variant { + adt_def: + AdtDef { + did: DefId(N:M ~ core::option::Option) + variants: [VariantDef { def_id: DefId(N:M ~ core::option::Option::None), ctor: Some((Const, DefId(N:M ~ core::option::Option::None::{constructor#0}))), name: "None", discr: Relative(0), fields: [], tainted: None, flags: }, VariantDef { def_id: DefId(N:M ~ core::option::Option::Some), ctor: Some((Fn, DefId(N:M ~ core::option::Option::Some::{constructor#0}))), name: "Some", discr: Relative(1), fields: [FieldDef { did: DefId(N:M ~ core::option::Option::Some::0), name: "0", vis: Public, safety: Safe, value: None }], tainted: None, flags: }] + flags: IS_ENUM + repr: ReprOptions { int: None, align: None, pack: None, flags: , scalable: None, field_shuffle_seed: 11004682594870345353 } + } + args: [u32] + variant_index: 1 + subpatterns: [ + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:15:7: 15:8 (#0) + kind: PatKind { + Binding { + name: "i" + mode: BindingMode(No, Not) + var: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).14)) + ty: u32 + is_primary: true + is_shorthand: false + subpattern: None + } + } + } + ] + } + } + } + guard: None + body: + Expr { + ty: () + temp_scope_id: 27 + span: $DIR/thir-tree-match-for.rs:15:17: 17:4 (#0) + kind: + Scope { + region_scope: Node(27) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).27) + value: + Expr { + ty: () + temp_scope_id: 27 + span: $DIR/thir-tree-match-for.rs:15:17: 17:4 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/thir-tree-match-for.rs:15:17: 17:4 (#0) + region_scope: Node(23) + safety_mode: Safe + stmts: [ + Stmt { + kind: Expr { + scope: Node(26) + expr: + Expr { + ty: u32 + temp_scope_id: 24 + span: $DIR/thir-tree-match-for.rs:16:5: 16:6 (#0) + kind: + Scope { + region_scope: Node(24) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).24) + value: + Expr { + ty: u32 + temp_scope_id: 24 + span: $DIR/thir-tree-match-for.rs:16:5: 16:6 (#0) + kind: + VarRef { + id: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).14)) + } + } + } + } + } + } + ] + expr: [] + } + } + } + } + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).28) + scope: Node(28) + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + } + ] + match_source: ForLoopDesugar + } + } + } + } + } + } + ] + expr: [] + } + } + ) + } + } + } + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_from_for).39) + scope: Node(39) + span: $DIR/thir-tree-match-for.rs:15:3: 17:4 (#7) + } + ] + match_source: ForLoopDesugar + } + } + } + } + } + } + } + } + } + } + } + } + + +DefId(N:M ~ thir_tree_match_for::match_loop_nonfor): +params: [ + Param { + ty: u32 + ty_span: Some($DIR/thir-tree-match-for.rs:21:25: 21:28 (#0)) + self_kind: None + hir_id: Some(HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).1)) + param: Some( + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:21:22: 21:23 (#0) + kind: PatKind { + Binding { + name: "x" + mode: BindingMode(No, Not) + var: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).2)) + ty: u32 + is_primary: true + is_shorthand: false + subpattern: None + } + } + } + ) + } + Param { + ty: u32 + ty_span: Some($DIR/thir-tree-match-for.rs:21:33: 21:36 (#0)) + self_kind: None + hir_id: Some(HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).3)) + param: Some( + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:21:30: 21:31 (#0) + kind: PatKind { + Binding { + name: "y" + mode: BindingMode(No, Not) + var: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).4)) + ty: u32 + is_primary: true + is_shorthand: false + subpattern: None + } + } + } + ) + } +] +body: + Expr { + ty: () + temp_scope_id: 48 + span: $DIR/thir-tree-match-for.rs:21:38: 30:2 (#0) + kind: + Scope { + region_scope: Node(48) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).48) + value: + Expr { + ty: () + temp_scope_id: 48 + span: $DIR/thir-tree-match-for.rs:21:38: 30:2 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/thir-tree-match-for.rs:21:38: 30:2 (#0) + region_scope: Node(5) + safety_mode: Safe + stmts: [] + expr: + Expr { + ty: () + temp_scope_id: 6 + span: $DIR/thir-tree-match-for.rs:22:3: 29:4 (#0) + kind: + Scope { + region_scope: Node(6) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).6) + value: + Expr { + ty: () + temp_scope_id: 6 + span: $DIR/thir-tree-match-for.rs:22:3: 29:4 (#0) + kind: + Match { + scrutinee: + Expr { + ty: std::ops::Range + temp_scope_id: 7 + span: $DIR/thir-tree-match-for.rs:22:9: 22:38 (#0) + kind: + Scope { + region_scope: Node(7) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).7) + value: + Expr { + ty: std::ops::Range + temp_scope_id: 7 + span: $DIR/thir-tree-match-for.rs:22:9: 22:38 (#0) + kind: + Call { + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + from_hir_call: true + fn_span: $DIR/thir-tree-match-for.rs:22:9: 22:38 (#0) + fun: + Expr { + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + temp_scope_id: 8 + span: $DIR/thir-tree-match-for.rs:22:9: 22:32 (#0) + kind: + Scope { + region_scope: Node(8) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).8) + value: + Expr { + ty: FnDef(DefId(N:M ~ core::iter::traits::collect::IntoIterator::into_iter), [std::ops::Range]) + temp_scope_id: 8 + span: $DIR/thir-tree-match-for.rs:22:9: 22:32 (#0) + kind: + ZstLiteral(user_ty: None) + } + } + } + args: [ + Expr { + ty: std::ops::Range + temp_scope_id: 11 + span: $DIR/thir-tree-match-for.rs:22:33: 22:37 (#8) + kind: + Scope { + region_scope: Node(11) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).11) + value: + Expr { + ty: std::ops::Range + temp_scope_id: 11 + span: $DIR/thir-tree-match-for.rs:22:33: 22:37 (#8) + kind: + Adt { + adt_def: + AdtDef { + did: DefId(N:M ~ core::ops::range::Range) + variants: [VariantDef { def_id: DefId(N:M ~ core::ops::range::Range), ctor: None, name: "Range", discr: Relative(0), fields: [FieldDef { did: DefId(N:M ~ core::ops::range::Range::start), name: "start", vis: Public, safety: Safe, value: None }, FieldDef { did: DefId(N:M ~ core::ops::range::Range::end), name: "end", vis: Public, safety: Safe, value: None }], tainted: None, flags: }] + flags: IS_STRUCT + repr: ReprOptions { int: None, align: None, pack: None, flags: , scalable: None, field_shuffle_seed: 3488599726022204405 } + } + variant_index: 0 + args: [u32] + user_ty: None + field 0: + Expr { + ty: u32 + temp_scope_id: 12 + span: $DIR/thir-tree-match-for.rs:22:33: 22:34 (#0) + kind: + Scope { + region_scope: Node(12) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).12) + value: + Expr { + ty: u32 + temp_scope_id: 12 + span: $DIR/thir-tree-match-for.rs:22:33: 22:34 (#0) + kind: + VarRef { + id: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).2)) + } + } + } + } + field 1: + Expr { + ty: u32 + temp_scope_id: 15 + span: $DIR/thir-tree-match-for.rs:22:36: 22:37 (#0) + kind: + Scope { + region_scope: Node(15) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).15) + value: + Expr { + ty: u32 + temp_scope_id: 15 + span: $DIR/thir-tree-match-for.rs:22:36: 22:37 (#0) + kind: + VarRef { + id: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).4)) + } + } + } + } + base: None + } + } + } + } + ] + } + } + } + } + arms: [ + Arm { + pattern: + Pat { + ty: std::ops::Range + span: $DIR/thir-tree-match-for.rs:23:5: 23:13 (#0) + kind: PatKind { + Binding { + name: "iter" + mode: BindingMode(No, Mut) + var: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).19)) + ty: std::ops::Range + is_primary: true + is_shorthand: false + subpattern: None + } + } + } + guard: None + body: + Expr { + ty: () + temp_scope_id: 21 + span: $DIR/thir-tree-match-for.rs:23:17: 28:6 (#0) + kind: + Scope { + region_scope: Node(21) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).21) + value: + Expr { + ty: () + temp_scope_id: 21 + span: $DIR/thir-tree-match-for.rs:23:17: 28:6 (#0) + kind: + Loop ( + body: + Expr { + ty: () + temp_scope_id: 22 + span: $DIR/thir-tree-match-for.rs:23:22: 28:6 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/thir-tree-match-for.rs:23:22: 28:6 (#0) + region_scope: Node(22) + safety_mode: Safe + stmts: [ + Stmt { + kind: Expr { + scope: Node(47) + expr: + Expr { + ty: () + temp_scope_id: 23 + span: $DIR/thir-tree-match-for.rs:24:7: 27:8 (#0) + kind: + Scope { + region_scope: Node(23) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).23) + value: + Expr { + ty: () + temp_scope_id: 23 + span: $DIR/thir-tree-match-for.rs:24:7: 27:8 (#0) + kind: + Match { + scrutinee: + Expr { + ty: std::option::Option + temp_scope_id: 24 + span: $DIR/thir-tree-match-for.rs:24:13: 24:38 (#0) + kind: + Scope { + region_scope: Node(24) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).24) + value: + Expr { + ty: std::option::Option + temp_scope_id: 24 + span: $DIR/thir-tree-match-for.rs:24:13: 24:38 (#0) + kind: + Call { + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + from_hir_call: true + fn_span: $DIR/thir-tree-match-for.rs:24:13: 24:38 (#0) + fun: + Expr { + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + temp_scope_id: 25 + span: $DIR/thir-tree-match-for.rs:24:13: 24:27 (#0) + kind: + Scope { + region_scope: Node(25) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).25) + value: + Expr { + ty: FnDef(DefId(N:M ~ core::iter::traits::iterator::Iterator::next), [std::ops::Range]) + temp_scope_id: 25 + span: $DIR/thir-tree-match-for.rs:24:13: 24:27 (#0) + kind: + ZstLiteral(user_ty: None) + } + } + } + args: [ + Expr { + ty: &'{erased} mut std::ops::Range + temp_scope_id: 28 + span: $DIR/thir-tree-match-for.rs:24:28: 24:37 (#0) + kind: + Scope { + region_scope: Node(28) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).28) + value: + Expr { + ty: &'{erased} mut std::ops::Range + temp_scope_id: 28 + span: $DIR/thir-tree-match-for.rs:24:28: 24:37 (#0) + kind: + Borrow ( + borrow_kind: Mut { kind: TwoPhaseBorrow } + arg: + Expr { + ty: std::ops::Range + temp_scope_id: 28 + span: $DIR/thir-tree-match-for.rs:24:28: 24:37 (#0) + kind: + Deref { + Expr { + ty: &'{erased} mut std::ops::Range + temp_scope_id: 28 + span: $DIR/thir-tree-match-for.rs:24:28: 24:37 (#0) + kind: + Borrow ( + borrow_kind: Mut { kind: Default } + arg: + Expr { + ty: std::ops::Range + temp_scope_id: 29 + span: $DIR/thir-tree-match-for.rs:24:33: 24:37 (#0) + kind: + Scope { + region_scope: Node(29) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).29) + value: + Expr { + ty: std::ops::Range + temp_scope_id: 29 + span: $DIR/thir-tree-match-for.rs:24:33: 24:37 (#0) + kind: + VarRef { + id: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).19)) + } + } + } + } + ) + } + } + } + ) + } + } + } + ] + } + } + } + } + arms: [ + Arm { + pattern: + Pat { + ty: std::option::Option + span: $DIR/thir-tree-match-for.rs:25:11: 25:23 (#0) + kind: PatKind { + Variant { + adt_def: + AdtDef { + did: DefId(N:M ~ core::option::Option) + variants: [VariantDef { def_id: DefId(N:M ~ core::option::Option::None), ctor: Some((Const, DefId(N:M ~ core::option::Option::None::{constructor#0}))), name: "None", discr: Relative(0), fields: [], tainted: None, flags: }, VariantDef { def_id: DefId(N:M ~ core::option::Option::Some), ctor: Some((Fn, DefId(N:M ~ core::option::Option::Some::{constructor#0}))), name: "Some", discr: Relative(1), fields: [FieldDef { did: DefId(N:M ~ core::option::Option::Some::0), name: "0", vis: Public, safety: Safe, value: None }], tainted: None, flags: }] + flags: IS_ENUM + repr: ReprOptions { int: None, align: None, pack: None, flags: , scalable: None, field_shuffle_seed: 11004682594870345353 } + } + args: [u32] + variant_index: 0 + subpatterns: [] + } + } + } + guard: None + body: + Expr { + ty: () + temp_scope_id: 36 + span: $DIR/thir-tree-match-for.rs:25:27: 25:32 (#0) + kind: + Scope { + region_scope: Node(36) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).36) + value: + Expr { + ty: () + temp_scope_id: 36 + span: $DIR/thir-tree-match-for.rs:25:27: 25:32 (#0) + kind: + NeverToAny { + source: + Expr { + ty: ! + temp_scope_id: 36 + span: $DIR/thir-tree-match-for.rs:25:27: 25:32 (#0) + kind: + Break ( + label: Node(21) + ) + } + } + } + } + } + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).35) + scope: Node(35) + span: $DIR/thir-tree-match-for.rs:25:11: 25:32 (#0) + } + Arm { + pattern: + Pat { + ty: std::option::Option + span: $DIR/thir-tree-match-for.rs:26:11: 26:26 (#0) + kind: PatKind { + Variant { + adt_def: + AdtDef { + did: DefId(N:M ~ core::option::Option) + variants: [VariantDef { def_id: DefId(N:M ~ core::option::Option::None), ctor: Some((Const, DefId(N:M ~ core::option::Option::None::{constructor#0}))), name: "None", discr: Relative(0), fields: [], tainted: None, flags: }, VariantDef { def_id: DefId(N:M ~ core::option::Option::Some), ctor: Some((Fn, DefId(N:M ~ core::option::Option::Some::{constructor#0}))), name: "Some", discr: Relative(1), fields: [FieldDef { did: DefId(N:M ~ core::option::Option::Some::0), name: "0", vis: Public, safety: Safe, value: None }], tainted: None, flags: }] + flags: IS_ENUM + repr: ReprOptions { int: None, align: None, pack: None, flags: , scalable: None, field_shuffle_seed: 11004682594870345353 } + } + args: [u32] + variant_index: 1 + subpatterns: [ + Pat { + ty: u32 + span: $DIR/thir-tree-match-for.rs:26:24: 26:25 (#0) + kind: PatKind { + Binding { + name: "i" + mode: BindingMode(No, Not) + var: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).40)) + ty: u32 + is_primary: true + is_shorthand: false + subpattern: None + } + } + } + ] + } + } + } + guard: None + body: + Expr { + ty: () + temp_scope_id: 42 + span: $DIR/thir-tree-match-for.rs:26:30: 26:36 (#0) + kind: + Scope { + region_scope: Node(42) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).42) + value: + Expr { + ty: () + temp_scope_id: 42 + span: $DIR/thir-tree-match-for.rs:26:30: 26:36 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/thir-tree-match-for.rs:26:30: 26:36 (#0) + region_scope: Node(43) + safety_mode: Safe + stmts: [ + Stmt { + kind: Expr { + scope: Node(46) + expr: + Expr { + ty: u32 + temp_scope_id: 44 + span: $DIR/thir-tree-match-for.rs:26:32: 26:33 (#0) + kind: + Scope { + region_scope: Node(44) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).44) + value: + Expr { + ty: u32 + temp_scope_id: 44 + span: $DIR/thir-tree-match-for.rs:26:32: 26:33 (#0) + kind: + VarRef { + id: LocalVarId(HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).40)) + } + } + } + } + } + } + ] + expr: [] + } + } + } + } + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).41) + scope: Node(41) + span: $DIR/thir-tree-match-for.rs:26:11: 26:36 (#0) + } + ] + match_source: Normal + } + } + } + } + } + } + ] + expr: [] + } + } + ) + } + } + } + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::match_loop_nonfor).20) + scope: Node(20) + span: $DIR/thir-tree-match-for.rs:23:5: 28:6 (#0) + } + ] + match_source: Normal + } + } + } + } + } + } + } + } + + +DefId(N:M ~ thir_tree_match_for::main): +params: [ +] +body: + Expr { + ty: () + temp_scope_id: 2 + span: $DIR/thir-tree-match-for.rs:32:11: 32:13 (#0) + kind: + Scope { + region_scope: Node(2) + hir_id: HirId(DefId(N:M ~ thir_tree_match_for::main).2) + value: + Expr { + ty: () + temp_scope_id: 2 + span: $DIR/thir-tree-match-for.rs:32:11: 32:13 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/thir-tree-match-for.rs:32:11: 32:13 (#0) + region_scope: Node(1) + safety_mode: Safe + stmts: [] + expr: [] + } + } + } + } + + diff --git a/tests/ui/thir-print/thir-tree-match.stdout b/tests/ui/thir-print/thir-tree-match.stdout index 31f8d368736c0..33baafeb48b26 100644 --- a/tests/ui/thir-print/thir-tree-match.stdout +++ b/tests/ui/thir-print/thir-tree-match.stdout @@ -246,6 +246,7 @@ body: span: $DIR/thir-tree-match.rs:19:9: 19:28 (#0) } ] + match_source: Normal } } }