Skip to content

Commit 65a6af2

Browse files
committed
Boolean hate.
1 parent 6e36008 commit 65a6af2

File tree

1 file changed

+15
-5
lines changed
  • compiler/rustc_hir_analysis/src/check

1 file changed

+15
-5
lines changed

compiler/rustc_hir_analysis/src/check/region.rs

+15-5
Original file line numberDiff line numberDiff line change
@@ -495,13 +495,19 @@ fn resolve_expr<'tcx>(
495495
visitor.cx = prev_cx;
496496
}
497497

498+
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
499+
enum LetKind {
500+
Regular,
501+
Super,
502+
}
503+
498504
fn resolve_local<'tcx>(
499505
visitor: &mut ScopeResolutionVisitor<'tcx>,
500506
pat: Option<&'tcx hir::Pat<'tcx>>,
501507
init: Option<&'tcx hir::Expr<'tcx>>,
502-
super_let: bool,
508+
let_kind: LetKind,
503509
) {
504-
debug!("resolve_local(pat={:?}, init={:?}, super_let={:?})", pat, init, super_let);
510+
debug!("resolve_local(pat={:?}, init={:?}, let_kind={:?})", pat, init, let_kind);
505511

506512
// As an exception to the normal rules governing temporary
507513
// lifetimes, initializers in a let have a temporary lifetime
@@ -559,7 +565,7 @@ fn resolve_local<'tcx>(
559565
// A, but the inner rvalues `a()` and `b()` have an extended lifetime
560566
// due to rule C.
561567

562-
if super_let {
568+
if let_kind == LetKind::Super {
563569
if let Some(scope) = visitor.extended_super_lets.remove(&pat.unwrap().hir_id.local_id) {
564570
// This expression was lifetime-extended by a parent let binding. E.g.
565571
//
@@ -861,7 +867,7 @@ impl<'tcx> Visitor<'tcx> for ScopeResolutionVisitor<'tcx> {
861867
local_id: body.value.hir_id.local_id,
862868
data: ScopeData::Destruction,
863869
});
864-
resolve_local(this, None, Some(body.value), false);
870+
resolve_local(this, None, Some(body.value), LetKind::Regular);
865871
}
866872
})
867873
}
@@ -879,7 +885,11 @@ impl<'tcx> Visitor<'tcx> for ScopeResolutionVisitor<'tcx> {
879885
resolve_expr(self, ex, false);
880886
}
881887
fn visit_local(&mut self, l: &'tcx LetStmt<'tcx>) {
882-
resolve_local(self, Some(l.pat), l.init, l.super_.is_some());
888+
let let_kind = match l.super_ {
889+
Some(_) => LetKind::Super,
890+
None => LetKind::Regular,
891+
};
892+
resolve_local(self, Some(l.pat), l.init, let_kind);
883893
}
884894
fn visit_inline_const(&mut self, c: &'tcx hir::ConstBlock) {
885895
let body = self.tcx.hir_body(c.body);

0 commit comments

Comments
 (0)