Simplify handling of visibility_scope in declare_bindings

This avoids the need to unwrap an option after ensuring that it is some.
This commit is contained in:
Zalathar 2025-02-16 17:43:11 +11:00
parent bca5f567d2
commit 977106a215

View file

@ -759,15 +759,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
pattern,
UserTypeProjections::none(),
&mut |this, name, mode, var, span, ty, user_ty| {
if visibility_scope.is_none() {
visibility_scope =
Some(this.new_source_scope(scope_span, LintLevel::Inherited));
}
let vis_scope = *visibility_scope
.get_or_insert_with(|| this.new_source_scope(scope_span, LintLevel::Inherited));
let source_info = SourceInfo { span, scope: this.source_scope };
let visibility_scope = visibility_scope.unwrap();
this.declare_binding(
source_info,
visibility_scope,
vis_scope,
name,
mode,
var,