Auto merge of #116170 - matthewjasper:remove-thir-destruction-scopes, r=cjgillot

Don't include destruction scopes in THIR

They are not used by anyone, and add memory/performance overhead.
This commit is contained in:
bors 2023-12-09 12:38:32 +00:00
commit 1dfb2283d7
11 changed files with 235 additions and 468 deletions

View file

@ -349,10 +349,6 @@ impl ScopeTree {
} }
} }
pub fn opt_destruction_scope(&self, n: hir::ItemLocalId) -> Option<Scope> {
self.destruction_scopes.get(&n).cloned()
}
pub fn record_var_scope(&mut self, var: hir::ItemLocalId, lifetime: Scope) { pub fn record_var_scope(&mut self, var: hir::ItemLocalId, lifetime: Scope) {
debug!("record_var_scope(sub={:?}, sup={:?})", var, lifetime); debug!("record_var_scope(sub={:?}, sup={:?})", var, lifetime);
assert!(var != lifetime.item_local_id()); assert!(var != lifetime.item_local_id());

View file

@ -134,7 +134,6 @@ pub struct Block {
/// This does *not* include labels on loops, e.g. `'label: loop {}`. /// This does *not* include labels on loops, e.g. `'label: loop {}`.
pub targeted_by_break: bool, pub targeted_by_break: bool,
pub region_scope: region::Scope, pub region_scope: region::Scope,
pub opt_destruction_scope: Option<region::Scope>,
/// The span of the block, including the opening braces, /// The span of the block, including the opening braces,
/// the label, and the `unsafe` keyword, if present. /// the label, and the `unsafe` keyword, if present.
pub span: Span, pub span: Span,
@ -193,7 +192,6 @@ pub enum BlockSafety {
#[derive(Clone, Debug, HashStable)] #[derive(Clone, Debug, HashStable)]
pub struct Stmt<'tcx> { pub struct Stmt<'tcx> {
pub kind: StmtKind<'tcx>, pub kind: StmtKind<'tcx>,
pub opt_destruction_scope: Option<region::Scope>,
} }
#[derive(Clone, Debug, HashStable)] #[derive(Clone, Debug, HashStable)]
@ -1224,12 +1222,12 @@ impl<'tcx> fmt::Display for Pat<'tcx> {
mod size_asserts { mod size_asserts {
use super::*; use super::*;
// tidy-alphabetical-start // tidy-alphabetical-start
static_assert_size!(Block, 56); static_assert_size!(Block, 48);
static_assert_size!(Expr<'_>, 64); static_assert_size!(Expr<'_>, 64);
static_assert_size!(ExprKind<'_>, 40); static_assert_size!(ExprKind<'_>, 40);
static_assert_size!(Pat<'_>, 64); static_assert_size!(Pat<'_>, 64);
static_assert_size!(PatKind<'_>, 48); static_assert_size!(PatKind<'_>, 48);
static_assert_size!(Stmt<'_>, 56); static_assert_size!(Stmt<'_>, 48);
static_assert_size!(StmtKind<'_>, 48); static_assert_size!(StmtKind<'_>, 48);
// tidy-alphabetical-end // tidy-alphabetical-end
} }

View file

@ -13,32 +13,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
ast_block: BlockId, ast_block: BlockId,
source_info: SourceInfo, source_info: SourceInfo,
) -> BlockAnd<()> { ) -> BlockAnd<()> {
let Block { let Block { region_scope, span, ref stmts, expr, targeted_by_break, safety_mode } =
region_scope, self.thir[ast_block];
opt_destruction_scope,
span,
ref stmts,
expr,
targeted_by_break,
safety_mode,
} = self.thir[ast_block];
let expr = expr.map(|expr| &self.thir[expr]); let expr = expr.map(|expr| &self.thir[expr]);
self.in_opt_scope(opt_destruction_scope.map(|de| (de, source_info)), move |this| { self.in_scope((region_scope, source_info), LintLevel::Inherited, move |this| {
this.in_scope((region_scope, source_info), LintLevel::Inherited, move |this| { if targeted_by_break {
if targeted_by_break { this.in_breakable_scope(None, destination, span, |this| {
this.in_breakable_scope(None, destination, span, |this| { Some(this.ast_block_stmts(
Some(this.ast_block_stmts(
destination,
block,
span,
stmts,
expr,
safety_mode,
region_scope,
))
})
} else {
this.ast_block_stmts(
destination, destination,
block, block,
span, span,
@ -46,9 +27,19 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
expr, expr,
safety_mode, safety_mode,
region_scope, region_scope,
) ))
} })
}) } else {
this.ast_block_stmts(
destination,
block,
span,
stmts,
expr,
safety_mode,
region_scope,
)
}
}) })
} }
@ -92,20 +83,15 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let source_info = this.source_info(span); let source_info = this.source_info(span);
for stmt in stmts { for stmt in stmts {
let Stmt { ref kind, opt_destruction_scope } = this.thir[*stmt]; let Stmt { ref kind } = this.thir[*stmt];
match kind { match kind {
StmtKind::Expr { scope, expr } => { StmtKind::Expr { scope, expr } => {
this.block_context.push(BlockFrame::Statement { ignores_expr_result: true }); this.block_context.push(BlockFrame::Statement { ignores_expr_result: true });
let si = (*scope, source_info);
unpack!( unpack!(
block = this.in_opt_scope( block = this.in_scope(si, LintLevel::Inherited, |this| {
opt_destruction_scope.map(|de| (de, source_info)), this.stmt_expr(block, &this.thir[*expr], Some(*scope))
|this| { })
let si = (*scope, source_info);
this.in_scope(si, LintLevel::Inherited, |this| {
this.stmt_expr(block, &this.thir[*expr], Some(*scope))
})
}
)
); );
} }
StmtKind::Let { StmtKind::Let {
@ -221,43 +207,38 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let init = &this.thir[*initializer]; let init = &this.thir[*initializer];
let initializer_span = init.span; let initializer_span = init.span;
let scope = (*init_scope, source_info);
let failure = unpack!( let failure = unpack!(
block = this.in_opt_scope( block = this.in_scope(scope, *lint_level, |this| {
opt_destruction_scope.map(|de| (de, source_info)), this.declare_bindings(
|this| { visibility_scope,
let scope = (*init_scope, source_info); remainder_span,
this.in_scope(scope, *lint_level, |this| { pattern,
this.declare_bindings( None,
visibility_scope, Some((Some(&destination), initializer_span)),
remainder_span, );
pattern, this.visit_primary_bindings(
None, pattern,
Some((Some(&destination), initializer_span)), UserTypeProjections::none(),
); &mut |this, _, _, _, node, span, _, _| {
this.visit_primary_bindings( this.storage_live_binding(
pattern,
UserTypeProjections::none(),
&mut |this, _, _, _, node, span, _, _| {
this.storage_live_binding(
block,
node,
span,
OutsideGuard,
true,
);
},
);
this.ast_let_else(
block, block,
init, node,
initializer_span, span,
*else_block, OutsideGuard,
&last_remainder_scope, true,
pattern, );
) },
}) );
} this.ast_let_else(
) block,
init,
initializer_span,
*else_block,
&last_remainder_scope,
pattern,
)
})
); );
this.cfg.goto(failure, source_info, failure_entry); this.cfg.goto(failure, source_info, failure_entry);
@ -298,25 +279,20 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
if let Some(init) = initializer { if let Some(init) = initializer {
let init = &this.thir[*init]; let init = &this.thir[*init];
let initializer_span = init.span; let initializer_span = init.span;
let scope = (*init_scope, source_info);
unpack!( unpack!(
block = this.in_opt_scope( block = this.in_scope(scope, *lint_level, |this| {
opt_destruction_scope.map(|de| (de, source_info)), this.declare_bindings(
|this| { visibility_scope,
let scope = (*init_scope, source_info); remainder_span,
this.in_scope(scope, *lint_level, |this| { pattern,
this.declare_bindings( None,
visibility_scope, Some((None, initializer_span)),
remainder_span, );
pattern, this.expr_into_pattern(block, &pattern, init)
None, // irrefutable pattern
Some((None, initializer_span)), })
);
this.expr_into_pattern(block, pattern, init)
// irrefutable pattern
})
},
)
) )
} else { } else {
let scope = (*init_scope, source_info); let scope = (*init_scope, source_info);

View file

@ -536,27 +536,6 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
(then_block, else_block) (then_block, else_block)
} }
pub(crate) fn in_opt_scope<F, R>(
&mut self,
opt_scope: Option<(region::Scope, SourceInfo)>,
f: F,
) -> BlockAnd<R>
where
F: FnOnce(&mut Builder<'a, 'tcx>) -> BlockAnd<R>,
{
debug!("in_opt_scope(opt_scope={:?})", opt_scope);
if let Some(region_scope) = opt_scope {
self.push_scope(region_scope);
}
let mut block;
let rv = unpack!(block = f(self));
if let Some(region_scope) = opt_scope {
unpack!(block = self.pop_scope(region_scope, block));
}
debug!("in_scope: exiting opt_scope={:?} block={:?}", opt_scope, block);
block.and(rv)
}
/// Convenience wrapper that pushes a scope and then executes `f` /// Convenience wrapper that pushes a scope and then executes `f`
/// to build its contents, popping the scope afterwards. /// to build its contents, popping the scope afterwards.
#[instrument(skip(self, f), level = "debug")] #[instrument(skip(self, f), level = "debug")]

View file

@ -13,15 +13,12 @@ impl<'tcx> Cx<'tcx> {
// We have to eagerly lower the "spine" of the statements // We have to eagerly lower the "spine" of the statements
// in order to get the lexical scoping correctly. // in order to get the lexical scoping correctly.
let stmts = self.mirror_stmts(block.hir_id.local_id, block.stmts); let stmts = self.mirror_stmts(block.hir_id.local_id, block.stmts);
let opt_destruction_scope =
self.region_scope_tree.opt_destruction_scope(block.hir_id.local_id);
let block = Block { let block = Block {
targeted_by_break: block.targeted_by_break, targeted_by_break: block.targeted_by_break,
region_scope: region::Scope { region_scope: region::Scope {
id: block.hir_id.local_id, id: block.hir_id.local_id,
data: region::ScopeData::Node, data: region::ScopeData::Node,
}, },
opt_destruction_scope,
span: block.span, span: block.span,
stmts, stmts,
expr: block.expr.map(|expr| self.mirror_expr(expr)), expr: block.expr.map(|expr| self.mirror_expr(expr)),
@ -49,7 +46,6 @@ impl<'tcx> Cx<'tcx> {
.enumerate() .enumerate()
.filter_map(|(index, stmt)| { .filter_map(|(index, stmt)| {
let hir_id = stmt.hir_id; let hir_id = stmt.hir_id;
let opt_dxn_ext = self.region_scope_tree.opt_destruction_scope(hir_id.local_id);
match stmt.kind { match stmt.kind {
hir::StmtKind::Expr(expr) | hir::StmtKind::Semi(expr) => { hir::StmtKind::Expr(expr) | hir::StmtKind::Semi(expr) => {
let stmt = Stmt { let stmt = Stmt {
@ -60,7 +56,6 @@ impl<'tcx> Cx<'tcx> {
}, },
expr: self.mirror_expr(expr), expr: self.mirror_expr(expr),
}, },
opt_destruction_scope: opt_dxn_ext,
}; };
Some(self.thir.stmts.push(stmt)) Some(self.thir.stmts.push(stmt))
} }
@ -122,7 +117,6 @@ impl<'tcx> Cx<'tcx> {
lint_level: LintLevel::Explicit(local.hir_id), lint_level: LintLevel::Explicit(local.hir_id),
span, span,
}, },
opt_destruction_scope: opt_dxn_ext,
}; };
Some(self.thir.stmts.push(stmt)) Some(self.thir.stmts.push(stmt))
} }

View file

@ -54,7 +54,7 @@ impl<'tcx> Cx<'tcx> {
trace!(?expr.ty, "after adjustments"); trace!(?expr.ty, "after adjustments");
// Next, wrap this up in the expr's scope. // Finally, wrap this up in the expr's scope.
expr = Expr { expr = Expr {
temp_lifetime: expr.temp_lifetime, temp_lifetime: expr.temp_lifetime,
ty: expr.ty, ty: expr.ty,
@ -66,22 +66,6 @@ impl<'tcx> Cx<'tcx> {
}, },
}; };
// Finally, create a destruction scope, if any.
if let Some(region_scope) =
self.region_scope_tree.opt_destruction_scope(hir_expr.hir_id.local_id)
{
expr = Expr {
temp_lifetime: expr.temp_lifetime,
ty: expr.ty,
span: hir_expr.span,
kind: ExprKind::Scope {
region_scope,
value: self.thir.exprs.push(expr),
lint_level: LintLevel::Inherited,
},
};
}
// OK, all done! // OK, all done!
self.thir.exprs.push(expr) self.thir.exprs.push(expr)
} }

View file

@ -91,23 +91,11 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
} }
fn print_block(&mut self, block_id: BlockId, depth_lvl: usize) { fn print_block(&mut self, block_id: BlockId, depth_lvl: usize) {
let Block { let Block { targeted_by_break, span, region_scope, stmts, expr, safety_mode } =
targeted_by_break, &self.thir.blocks[block_id];
opt_destruction_scope,
span,
region_scope,
stmts,
expr,
safety_mode,
} = &self.thir.blocks[block_id];
print_indented!(self, "Block {", depth_lvl); print_indented!(self, "Block {", depth_lvl);
print_indented!(self, format!("targeted_by_break: {}", targeted_by_break), depth_lvl + 1); print_indented!(self, format!("targeted_by_break: {}", targeted_by_break), depth_lvl + 1);
print_indented!(
self,
format!("opt_destruction_scope: {:?}", opt_destruction_scope),
depth_lvl + 1
);
print_indented!(self, format!("span: {:?}", span), depth_lvl + 1); print_indented!(self, format!("span: {:?}", span), depth_lvl + 1);
print_indented!(self, format!("region_scope: {:?}", region_scope), depth_lvl + 1); print_indented!(self, format!("region_scope: {:?}", region_scope), depth_lvl + 1);
print_indented!(self, format!("safety_mode: {:?}", safety_mode), depth_lvl + 1); print_indented!(self, format!("safety_mode: {:?}", safety_mode), depth_lvl + 1);
@ -133,14 +121,9 @@ impl<'a, 'tcx> ThirPrinter<'a, 'tcx> {
} }
fn print_stmt(&mut self, stmt_id: StmtId, depth_lvl: usize) { fn print_stmt(&mut self, stmt_id: StmtId, depth_lvl: usize) {
let Stmt { kind, opt_destruction_scope } = &self.thir.stmts[stmt_id]; let Stmt { kind } = &self.thir.stmts[stmt_id];
print_indented!(self, "Stmt {", depth_lvl); print_indented!(self, "Stmt {", depth_lvl);
print_indented!(
self,
format!("opt_destruction_scope: {:?}", opt_destruction_scope),
depth_lvl + 1
);
match kind { match kind {
StmtKind::Expr { scope, expr } => { StmtKind::Expr { scope, expr } => {

View file

@ -66,18 +66,6 @@ Thir {
), ),
span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0), span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0),
}, },
Expr {
kind: Scope {
region_scope: Destruction(3),
lint_level: Inherited,
value: e3,
},
ty: Foo,
temp_lifetime: Some(
Node(3),
),
span: $DIR/thir-flat-const-variant.rs:12:23: 12:35 (#0),
},
], ],
stmts: [], stmts: [],
params: [], params: [],
@ -151,18 +139,6 @@ Thir {
), ),
span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0), span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0),
}, },
Expr {
kind: Scope {
region_scope: Destruction(3),
lint_level: Inherited,
value: e3,
},
ty: Foo,
temp_lifetime: Some(
Node(3),
),
span: $DIR/thir-flat-const-variant.rs:13:23: 13:36 (#0),
},
], ],
stmts: [], stmts: [],
params: [], params: [],
@ -236,18 +212,6 @@ Thir {
), ),
span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0), span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0),
}, },
Expr {
kind: Scope {
region_scope: Destruction(3),
lint_level: Inherited,
value: e3,
},
ty: Foo,
temp_lifetime: Some(
Node(3),
),
span: $DIR/thir-flat-const-variant.rs:14:24: 14:36 (#0),
},
], ],
stmts: [], stmts: [],
params: [], params: [],
@ -321,18 +285,6 @@ Thir {
), ),
span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0), span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0),
}, },
Expr {
kind: Scope {
region_scope: Destruction(3),
lint_level: Inherited,
value: e3,
},
ty: Foo,
temp_lifetime: Some(
Node(3),
),
span: $DIR/thir-flat-const-variant.rs:15:24: 15:37 (#0),
},
], ],
stmts: [], stmts: [],
params: [], params: [],
@ -348,7 +300,6 @@ Thir {
Block { Block {
targeted_by_break: false, targeted_by_break: false,
region_scope: Node(1), region_scope: Node(1),
opt_destruction_scope: None,
span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0), span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0),
stmts: [], stmts: [],
expr: None, expr: None,
@ -380,18 +331,6 @@ Thir {
), ),
span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0), span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0),
}, },
Expr {
kind: Scope {
region_scope: Destruction(2),
lint_level: Inherited,
value: e1,
},
ty: (),
temp_lifetime: Some(
Node(2),
),
span: $DIR/thir-flat-const-variant.rs:18:11: 18:13 (#0),
},
], ],
stmts: [], stmts: [],
params: [], params: [],

View file

@ -8,7 +8,6 @@ Thir {
Block { Block {
targeted_by_break: false, targeted_by_break: false,
region_scope: Node(1), region_scope: Node(1),
opt_destruction_scope: None,
span: $DIR/thir-flat.rs:4:15: 4:17 (#0), span: $DIR/thir-flat.rs:4:15: 4:17 (#0),
stmts: [], stmts: [],
expr: None, expr: None,
@ -40,18 +39,6 @@ Thir {
), ),
span: $DIR/thir-flat.rs:4:15: 4:17 (#0), span: $DIR/thir-flat.rs:4:15: 4:17 (#0),
}, },
Expr {
kind: Scope {
region_scope: Destruction(2),
lint_level: Inherited,
value: e1,
},
ty: (),
temp_lifetime: Some(
Node(2),
),
span: $DIR/thir-flat.rs:4:15: 4:17 (#0),
},
], ],
stmts: [], stmts: [],
params: [], params: [],

View file

@ -31,262 +31,217 @@ body:
span: $DIR/thir-tree-match.rs:15:32: 21:2 (#0) span: $DIR/thir-tree-match.rs:15:32: 21:2 (#0)
kind: kind:
Scope { Scope {
region_scope: Destruction(26) region_scope: Node(26)
lint_level: Inherited lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).26))
value: value:
Expr { Expr {
ty: bool ty: bool
temp_lifetime: Some(Node(26)) temp_lifetime: Some(Node(26))
span: $DIR/thir-tree-match.rs:15:32: 21:2 (#0) span: $DIR/thir-tree-match.rs:15:32: 21:2 (#0)
kind: kind:
Scope { Block {
region_scope: Node(26) targeted_by_break: false
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).26)) span: $DIR/thir-tree-match.rs:15:32: 21:2 (#0)
value: region_scope: Node(25)
safety_mode: Safe
stmts: []
expr:
Expr { Expr {
ty: bool ty: bool
temp_lifetime: Some(Node(26)) temp_lifetime: Some(Node(26))
span: $DIR/thir-tree-match.rs:15:32: 21:2 (#0) span: $DIR/thir-tree-match.rs:16:5: 20:6 (#0)
kind: kind:
Block { Scope {
targeted_by_break: false region_scope: Node(3)
opt_destruction_scope: None lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).3))
span: $DIR/thir-tree-match.rs:15:32: 21:2 (#0) value:
region_scope: Node(25)
safety_mode: Safe
stmts: []
expr:
Expr { Expr {
ty: bool ty: bool
temp_lifetime: Some(Node(26)) temp_lifetime: Some(Node(26))
span: $DIR/thir-tree-match.rs:16:5: 20:6 (#0) span: $DIR/thir-tree-match.rs:16:5: 20:6 (#0)
kind: kind:
Scope { Match {
region_scope: Node(3) scrutinee:
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).3))
value:
Expr { Expr {
ty: bool ty: Foo
temp_lifetime: Some(Node(26)) temp_lifetime: Some(Node(26))
span: $DIR/thir-tree-match.rs:16:5: 20:6 (#0) span: $DIR/thir-tree-match.rs:16:11: 16:14 (#0)
kind: kind:
Match { Scope {
scrutinee: region_scope: Node(4)
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).4))
value:
Expr { Expr {
ty: Foo ty: Foo
temp_lifetime: Some(Node(26)) temp_lifetime: Some(Node(26))
span: $DIR/thir-tree-match.rs:16:11: 16:14 (#0) span: $DIR/thir-tree-match.rs:16:11: 16:14 (#0)
kind: kind:
Scope { VarRef {
region_scope: Node(4) id: LocalVarId(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).2))
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).4))
value:
Expr {
ty: Foo
temp_lifetime: Some(Node(26))
span: $DIR/thir-tree-match.rs:16:11: 16:14 (#0)
kind:
VarRef {
id: LocalVarId(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).2))
}
}
} }
} }
arms: [ }
Arm { }
pattern: arms: [
Arm {
pattern:
Pat: {
ty: Foo
span: $DIR/thir-tree-match.rs:17:9: 17:32 (#0)
kind: PatKind {
Variant {
adt_def:
AdtDef {
did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo)
variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }]
flags: IS_ENUM
repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 }
args: []
variant_index: 0
subpatterns: [
Pat: { Pat: {
ty: Foo ty: Bar
span: $DIR/thir-tree-match.rs:17:9: 17:32 (#0) span: $DIR/thir-tree-match.rs:17:21: 17:31 (#0)
kind: PatKind { kind: PatKind {
Variant { Variant {
adt_def: adt_def:
AdtDef { AdtDef {
did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo) did: DefId(0:3 ~ thir_tree_match[fcf8]::Bar)
variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }] variants: [VariantDef { def_id: DefId(0:4 ~ thir_tree_match[fcf8]::Bar::First), ctor: Some((Const, DefId(0:5 ~ thir_tree_match[fcf8]::Bar::First::{constructor#0}))), name: "First", discr: Relative(0), fields: [], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:6 ~ thir_tree_match[fcf8]::Bar::Second), ctor: Some((Const, DefId(0:7 ~ thir_tree_match[fcf8]::Bar::Second::{constructor#0}))), name: "Second", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:8 ~ thir_tree_match[fcf8]::Bar::Third), ctor: Some((Const, DefId(0:9 ~ thir_tree_match[fcf8]::Bar::Third::{constructor#0}))), name: "Third", discr: Relative(2), fields: [], flags: NO_VARIANT_FLAGS }]
flags: IS_ENUM flags: IS_ENUM
repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 } repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 10333377570083945360 }
args: [] args: []
variant_index: 0 variant_index: 0
subpatterns: [ subpatterns: []
Pat: {
ty: Bar
span: $DIR/thir-tree-match.rs:17:21: 17:31 (#0)
kind: PatKind {
Variant {
adt_def:
AdtDef {
did: DefId(0:3 ~ thir_tree_match[fcf8]::Bar)
variants: [VariantDef { def_id: DefId(0:4 ~ thir_tree_match[fcf8]::Bar::First), ctor: Some((Const, DefId(0:5 ~ thir_tree_match[fcf8]::Bar::First::{constructor#0}))), name: "First", discr: Relative(0), fields: [], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:6 ~ thir_tree_match[fcf8]::Bar::Second), ctor: Some((Const, DefId(0:7 ~ thir_tree_match[fcf8]::Bar::Second::{constructor#0}))), name: "Second", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:8 ~ thir_tree_match[fcf8]::Bar::Third), ctor: Some((Const, DefId(0:9 ~ thir_tree_match[fcf8]::Bar::Third::{constructor#0}))), name: "Third", discr: Relative(2), fields: [], flags: NO_VARIANT_FLAGS }]
flags: IS_ENUM
repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 10333377570083945360 }
args: []
variant_index: 0
subpatterns: []
}
}
}
]
} }
} }
} }
guard: None ]
body: }
}
}
guard: None
body:
Expr {
ty: bool
temp_lifetime: Some(Node(13))
span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0)
kind:
Scope {
region_scope: Node(13)
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).13))
value:
Expr { Expr {
ty: bool ty: bool
temp_lifetime: Some(Node(13)) temp_lifetime: Some(Node(13))
span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0) span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0)
kind: kind:
Scope { Literal( lit: Spanned { node: Bool(true), span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0) }, neg: false)
region_scope: Destruction(13)
lint_level: Inherited
value:
Expr {
ty: bool
temp_lifetime: Some(Node(13))
span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0)
kind:
Scope {
region_scope: Node(13)
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).13))
value:
Expr {
ty: bool
temp_lifetime: Some(Node(13))
span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0)
kind:
Literal( lit: Spanned { node: Bool(true), span: $DIR/thir-tree-match.rs:17:36: 17:40 (#0) }, neg: false)
}
}
}
}
} }
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).12))
scope: Node(12)
span: $DIR/thir-tree-match.rs:17:9: 17:40 (#0)
} }
Arm { }
pattern: lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).12))
scope: Node(12)
span: $DIR/thir-tree-match.rs:17:9: 17:40 (#0)
}
Arm {
pattern:
Pat: {
ty: Foo
span: $DIR/thir-tree-match.rs:18:9: 18:23 (#0)
kind: PatKind {
Variant {
adt_def:
AdtDef {
did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo)
variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }]
flags: IS_ENUM
repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 }
args: []
variant_index: 0
subpatterns: [
Pat: { Pat: {
ty: Foo ty: Bar
span: $DIR/thir-tree-match.rs:18:9: 18:23 (#0) span: $DIR/thir-tree-match.rs:18:21: 18:22 (#0)
kind: PatKind { kind: PatKind {
Variant { Wild
adt_def:
AdtDef {
did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo)
variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }]
flags: IS_ENUM
repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 }
args: []
variant_index: 0
subpatterns: [
Pat: {
ty: Bar
span: $DIR/thir-tree-match.rs:18:21: 18:22 (#0)
kind: PatKind {
Wild
}
}
]
}
} }
} }
guard: None ]
body: }
}
}
guard: None
body:
Expr {
ty: bool
temp_lifetime: Some(Node(19))
span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0)
kind:
Scope {
region_scope: Node(19)
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).19))
value:
Expr { Expr {
ty: bool ty: bool
temp_lifetime: Some(Node(19)) temp_lifetime: Some(Node(19))
span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0) span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0)
kind: kind:
Scope { Literal( lit: Spanned { node: Bool(false), span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0) }, neg: false)
region_scope: Destruction(19)
lint_level: Inherited
value:
Expr {
ty: bool
temp_lifetime: Some(Node(19))
span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0)
kind:
Scope {
region_scope: Node(19)
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).19))
value:
Expr {
ty: bool
temp_lifetime: Some(Node(19))
span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0)
kind:
Literal( lit: Spanned { node: Bool(false), span: $DIR/thir-tree-match.rs:18:27: 18:32 (#0) }, neg: false)
}
}
}
}
} }
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).18))
scope: Node(18)
span: $DIR/thir-tree-match.rs:18:9: 18:32 (#0)
} }
Arm { }
pattern: lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).18))
Pat: { scope: Node(18)
ty: Foo span: $DIR/thir-tree-match.rs:18:9: 18:32 (#0)
span: $DIR/thir-tree-match.rs:19:9: 19:20 (#0) }
kind: PatKind { Arm {
Variant { pattern:
adt_def: Pat: {
AdtDef { ty: Foo
did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo) span: $DIR/thir-tree-match.rs:19:9: 19:20 (#0)
variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }] kind: PatKind {
flags: IS_ENUM Variant {
repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 } adt_def:
args: [] AdtDef {
variant_index: 1 did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo)
subpatterns: [] variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }]
} flags: IS_ENUM
} repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 }
} args: []
guard: None variant_index: 1
body: subpatterns: []
}
}
}
guard: None
body:
Expr {
ty: bool
temp_lifetime: Some(Node(24))
span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0)
kind:
Scope {
region_scope: Node(24)
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).24))
value:
Expr { Expr {
ty: bool ty: bool
temp_lifetime: Some(Node(24)) temp_lifetime: Some(Node(24))
span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0) span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0)
kind: kind:
Scope { Literal( lit: Spanned { node: Bool(true), span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0) }, neg: false)
region_scope: Destruction(24)
lint_level: Inherited
value:
Expr {
ty: bool
temp_lifetime: Some(Node(24))
span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0)
kind:
Scope {
region_scope: Node(24)
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).24))
value:
Expr {
ty: bool
temp_lifetime: Some(Node(24))
span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0)
kind:
Literal( lit: Spanned { node: Bool(true), span: $DIR/thir-tree-match.rs:19:24: 19:28 (#0) }, neg: false)
}
}
}
}
} }
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).23))
scope: Node(23)
span: $DIR/thir-tree-match.rs:19:9: 19:28 (#0)
} }
]
} }
lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).23))
scope: Node(23)
span: $DIR/thir-tree-match.rs:19:9: 19:28 (#0)
} }
]
} }
} }
} }
@ -307,33 +262,21 @@ body:
span: $DIR/thir-tree-match.rs:23:11: 23:13 (#0) span: $DIR/thir-tree-match.rs:23:11: 23:13 (#0)
kind: kind:
Scope { Scope {
region_scope: Destruction(2) region_scope: Node(2)
lint_level: Inherited lint_level: Explicit(HirId(DefId(0:17 ~ thir_tree_match[fcf8]::main).2))
value: value:
Expr { Expr {
ty: () ty: ()
temp_lifetime: Some(Node(2)) temp_lifetime: Some(Node(2))
span: $DIR/thir-tree-match.rs:23:11: 23:13 (#0) span: $DIR/thir-tree-match.rs:23:11: 23:13 (#0)
kind: kind:
Scope { Block {
region_scope: Node(2) targeted_by_break: false
lint_level: Explicit(HirId(DefId(0:17 ~ thir_tree_match[fcf8]::main).2)) span: $DIR/thir-tree-match.rs:23:11: 23:13 (#0)
value: region_scope: Node(1)
Expr { safety_mode: Safe
ty: () stmts: []
temp_lifetime: Some(Node(2)) expr: []
span: $DIR/thir-tree-match.rs:23:11: 23:13 (#0)
kind:
Block {
targeted_by_break: false
opt_destruction_scope: None
span: $DIR/thir-tree-match.rs:23:11: 23:13 (#0)
region_scope: Node(1)
safety_mode: Safe
stmts: []
expr: []
}
}
} }
} }
} }

View file

@ -8,33 +8,21 @@ body:
span: $DIR/thir-tree.rs:4:15: 4:17 (#0) span: $DIR/thir-tree.rs:4:15: 4:17 (#0)
kind: kind:
Scope { Scope {
region_scope: Destruction(2) region_scope: Node(2)
lint_level: Inherited lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree[7aaa]::main).2))
value: value:
Expr { Expr {
ty: () ty: ()
temp_lifetime: Some(Node(2)) temp_lifetime: Some(Node(2))
span: $DIR/thir-tree.rs:4:15: 4:17 (#0) span: $DIR/thir-tree.rs:4:15: 4:17 (#0)
kind: kind:
Scope { Block {
region_scope: Node(2) targeted_by_break: false
lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree[7aaa]::main).2)) span: $DIR/thir-tree.rs:4:15: 4:17 (#0)
value: region_scope: Node(1)
Expr { safety_mode: Safe
ty: () stmts: []
temp_lifetime: Some(Node(2)) expr: []
span: $DIR/thir-tree.rs:4:15: 4:17 (#0)
kind:
Block {
targeted_by_break: false
opt_destruction_scope: None
span: $DIR/thir-tree.rs:4:15: 4:17 (#0)
region_scope: Node(1)
safety_mode: Safe
stmts: []
expr: []
}
}
} }
} }
} }