Skip to content

Commit 10b76eb

Browse files
committed
relocate and reindent record_rvalue_scope_if_borrow_expr
1 parent 5904356 commit 10b76eb

File tree

1 file changed

+70
-70
lines changed
  • compiler/rustc_hir_analysis/src/check

1 file changed

+70
-70
lines changed

compiler/rustc_hir_analysis/src/check/region.rs

Lines changed: 70 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -602,87 +602,87 @@ fn resolve_local<'tcx>(
602602
| PatKind::Err(_) => false,
603603
}
604604
}
605+
}
605606

606-
/// If `expr` matches the `E&` grammar, then records an extended rvalue scope as appropriate:
607-
///
608-
/// ```text
609-
/// E& = & ET
610-
/// | StructName { ..., f: E&, ... }
611-
/// | [ ..., E&, ... ]
612-
/// | ( ..., E&, ... )
613-
/// | {...; E&}
614-
/// | { super let ... = E&; ... }
615-
/// | if _ { ...; E& } else { ...; E& }
616-
/// | match _ { ..., _ => E&, ... }
617-
/// | box E&
618-
/// | E& as ...
619-
/// | ( E& )
620-
/// ```
621-
fn record_rvalue_scope_if_borrow_expr<'tcx>(
622-
visitor: &mut ScopeResolutionVisitor<'tcx>,
623-
expr: &hir::Expr<'_>,
624-
blk_id: Option<Scope>,
625-
) {
626-
match expr.kind {
627-
hir::ExprKind::AddrOf(_, _, subexpr) => {
628-
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
629-
visitor.scope_tree.record_rvalue_candidate(
630-
subexpr.hir_id,
631-
RvalueCandidate { target: subexpr.hir_id.local_id, lifetime: blk_id },
632-
);
633-
}
634-
hir::ExprKind::Struct(_, fields, _) => {
635-
for field in fields {
636-
record_rvalue_scope_if_borrow_expr(visitor, field.expr, blk_id);
637-
}
607+
/// If `expr` matches the `E&` grammar, then records an extended rvalue scope as appropriate:
608+
///
609+
/// ```text
610+
/// E& = & ET
611+
/// | StructName { ..., f: E&, ... }
612+
/// | [ ..., E&, ... ]
613+
/// | ( ..., E&, ... )
614+
/// | {...; E&}
615+
/// | { super let ... = E&; ... }
616+
/// | if _ { ...; E& } else { ...; E& }
617+
/// | match _ { ..., _ => E&, ... }
618+
/// | box E&
619+
/// | E& as ...
620+
/// | ( E& )
621+
/// ```
622+
fn record_rvalue_scope_if_borrow_expr<'tcx>(
623+
visitor: &mut ScopeResolutionVisitor<'tcx>,
624+
expr: &hir::Expr<'_>,
625+
blk_id: Option<Scope>,
626+
) {
627+
match expr.kind {
628+
hir::ExprKind::AddrOf(_, _, subexpr) => {
629+
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
630+
visitor.scope_tree.record_rvalue_candidate(
631+
subexpr.hir_id,
632+
RvalueCandidate { target: subexpr.hir_id.local_id, lifetime: blk_id },
633+
);
634+
}
635+
hir::ExprKind::Struct(_, fields, _) => {
636+
for field in fields {
637+
record_rvalue_scope_if_borrow_expr(visitor, field.expr, blk_id);
638638
}
639-
hir::ExprKind::Array(subexprs) | hir::ExprKind::Tup(subexprs) => {
640-
for subexpr in subexprs {
641-
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
642-
}
639+
}
640+
hir::ExprKind::Array(subexprs) | hir::ExprKind::Tup(subexprs) => {
641+
for subexpr in subexprs {
642+
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
643643
}
644-
hir::ExprKind::Cast(subexpr, _) => {
645-
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id)
644+
}
645+
hir::ExprKind::Cast(subexpr, _) => {
646+
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id)
647+
}
648+
hir::ExprKind::Block(block, _) => {
649+
if let Some(subexpr) = block.expr {
650+
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
646651
}
647-
hir::ExprKind::Block(block, _) => {
648-
if let Some(subexpr) = block.expr {
649-
record_rvalue_scope_if_borrow_expr(visitor, subexpr, blk_id);
650-
}
651-
for stmt in block.stmts {
652-
if let hir::StmtKind::Let(local) = stmt.kind
653-
&& let Some(_) = local.super_
654-
{
655-
visitor.extended_super_lets.insert(local.pat.hir_id.local_id, blk_id);
656-
}
652+
for stmt in block.stmts {
653+
if let hir::StmtKind::Let(local) = stmt.kind
654+
&& let Some(_) = local.super_
655+
{
656+
visitor.extended_super_lets.insert(local.pat.hir_id.local_id, blk_id);
657657
}
658658
}
659-
hir::ExprKind::If(_, then_block, else_block) => {
660-
record_rvalue_scope_if_borrow_expr(visitor, then_block, blk_id);
661-
if let Some(else_block) = else_block {
662-
record_rvalue_scope_if_borrow_expr(visitor, else_block, blk_id);
663-
}
659+
}
660+
hir::ExprKind::If(_, then_block, else_block) => {
661+
record_rvalue_scope_if_borrow_expr(visitor, then_block, blk_id);
662+
if let Some(else_block) = else_block {
663+
record_rvalue_scope_if_borrow_expr(visitor, else_block, blk_id);
664664
}
665-
hir::ExprKind::Match(_, arms, _) => {
666-
for arm in arms {
667-
record_rvalue_scope_if_borrow_expr(visitor, arm.body, blk_id);
668-
}
665+
}
666+
hir::ExprKind::Match(_, arms, _) => {
667+
for arm in arms {
668+
record_rvalue_scope_if_borrow_expr(visitor, arm.body, blk_id);
669669
}
670-
hir::ExprKind::Call(func, args) => {
671-
// Recurse into tuple constructors, such as `Some(&temp())`.
672-
//
673-
// That way, there is no difference between `Some(..)` and `Some { 0: .. }`,
674-
// even though the former is syntactically a function call.
675-
if let hir::ExprKind::Path(path) = &func.kind
676-
&& let hir::QPath::Resolved(None, path) = path
677-
&& let Res::SelfCtor(_) | Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) = path.res
678-
{
679-
for arg in args {
680-
record_rvalue_scope_if_borrow_expr(visitor, arg, blk_id);
681-
}
670+
}
671+
hir::ExprKind::Call(func, args) => {
672+
// Recurse into tuple constructors, such as `Some(&temp())`.
673+
//
674+
// That way, there is no difference between `Some(..)` and `Some { 0: .. }`,
675+
// even though the former is syntactically a function call.
676+
if let hir::ExprKind::Path(path) = &func.kind
677+
&& let hir::QPath::Resolved(None, path) = path
678+
&& let Res::SelfCtor(_) | Res::Def(DefKind::Ctor(_, CtorKind::Fn), _) = path.res
679+
{
680+
for arg in args {
681+
record_rvalue_scope_if_borrow_expr(visitor, arg, blk_id);
682682
}
683683
}
684-
_ => {}
685684
}
685+
_ => {}
686686
}
687687
}
688688

0 commit comments

Comments
 (0)