Skip to content

Commit db7ea4b

Browse files
committed
relocate and reindent record_rvalue_scope_if_borrow_expr
1 parent 82ae0ee commit db7ea4b

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
@@ -603,87 +603,87 @@ fn resolve_local<'tcx>(
603603
| PatKind::Err(_) => false,
604604
}
605605
}
606+
}
606607

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

0 commit comments

Comments
 (0)