Skip to content

Commit 977106a

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 bca5f56 commit 977106a

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
@@ -759,15 +759,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
759759
pattern,
760760
UserTypeProjections::none(),
761761
&mut |this, name, mode, var, span, ty, user_ty| {
762-
if visibility_scope.is_none() {
763-
visibility_scope =
764-
Some(this.new_source_scope(scope_span, LintLevel::Inherited));
765-
}
762+
let vis_scope = *visibility_scope
763+
.get_or_insert_with(|| this.new_source_scope(scope_span, LintLevel::Inherited));
766764
let source_info = SourceInfo { span, scope: this.source_scope };
767-
let visibility_scope = visibility_scope.unwrap();
765+
768766
this.declare_binding(
769767
source_info,
770-
visibility_scope,
768+
vis_scope,
771769
name,
772770
mode,
773771
var,

0 commit comments

Comments
 (0)