Skip to content

Commit ebcc424

Browse files
committed
Simplify handling of visibility_scope in declare_bindings
This avoids the need to unwrap an option after ensuring that it is some.
1 parent 87b1691 commit ebcc424

File tree

1 file changed

+4
-6
lines changed
  • compiler/rustc_mir_build/src/builder/matches

1 file changed

+4
-6
lines changed

compiler/rustc_mir_build/src/builder/matches/mod.rs

+4-6
Original file line numberDiff line numberDiff line change
@@ -760,15 +760,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
760760
pattern,
761761
UserTypeProjections::none(),
762762
&mut |this, name, mode, var, span, ty, user_ty| {
763-
if visibility_scope.is_none() {
764-
visibility_scope =
765-
Some(this.new_source_scope(scope_span, LintLevel::Inherited));
766-
}
763+
let vis_scope = *visibility_scope
764+
.get_or_insert_with(|| this.new_source_scope(scope_span, LintLevel::Inherited));
767765
let source_info = SourceInfo { span, scope: this.source_scope };
768-
let visibility_scope = visibility_scope.unwrap();
766+
769767
this.declare_binding(
770768
source_info,
771-
visibility_scope,
769+
vis_scope,
772770
name,
773771
mode,
774772
var,

0 commit comments

Comments
 (0)