- let binding = self.resolve_ident_in_lexical_scope(ident, ValueNS, None, pat.span)?;
- if is_syntactic_ambiguity && binding.is_ambiguity() {
- // For ambiguous bindings we don't know all their definitions and cannot check
- // whether they can be shadowed by fresh bindings or not, so force an error.
- // issues/33118#issuecomment-233962221 (see below) still applies here,
- // but we have to ignore it for backward compatibility.
- self.r.record_use(ident, binding, false);
- return None;
- }
+ let ls_binding = self.resolve_ident_in_lexical_scope(ident, ValueNS, None, pat.span)?;
+ let (res, binding) = match ls_binding {
+ LexicalScopeBinding::Item(binding)
+ if is_syntactic_ambiguity && binding.is_ambiguity() =>
+ {
+ // For ambiguous bindings we don't know all their definitions and cannot check
+ // whether they can be shadowed by fresh bindings or not, so force an error.
+ // issues/33118#issuecomment-233962221 (see below) still applies here,
+ // but we have to ignore it for backward compatibility.
+ self.r.record_use(ident, binding, false);
+ return None;
+ }
+ LexicalScopeBinding::Item(binding) => (binding.res(), Some(binding)),
+ LexicalScopeBinding::Res(res) => (res, None),
+ };