Skip to content

Commit 61dba61

Browse files
committed
relocate and reindent record_rvalue_scope_if_borrow_expr
1 parent 581f20b commit 61dba61

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
@@ -596,87 +596,87 @@ fn resolve_local<'tcx>(
596596
| PatKind::Err(_) => false,
597597
}
598598
}
599+
}
599600

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

0 commit comments

Comments
 (0)