@@ -1522,23 +1522,27 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
15221522 ident : Ident ,
15231523 has_sub : bool ,
15241524 ) -> Option < Res > {
1525+ // An immutable (no `mut`) by-value (no `ref`) binding pattern without
1526+ // a sub pattern (no `@ $pat`) is syntactically ambiguous as it could
1527+ // also be interpreted as a path to e.g. a constant, variant, etc.
1528+ let is_syntactic_ambiguity = !has_sub && bm == BindingMode :: ByValue ( Mutability :: Not ) ;
1529+
15251530 let ls_binding = self . resolve_ident_in_lexical_scope ( ident, ValueNS , None , pat. span ) ?;
15261531 let ( res, binding) = match ls_binding {
1527- LexicalScopeBinding :: Item ( binding) if binding. is_ambiguity ( ) => {
1532+ LexicalScopeBinding :: Item ( binding)
1533+ if is_syntactic_ambiguity && binding. is_ambiguity ( ) =>
1534+ {
15281535 // For ambiguous bindings we don't know all their definitions and cannot check
15291536 // whether they can be shadowed by fresh bindings or not, so force an error.
1537+ // issues/33118#issuecomment-233962221 (see below) still applies here,
1538+ // but we have to ignore it for backward compatibility.
15301539 self . r . record_use ( ident, ValueNS , binding, false ) ;
15311540 return None ;
15321541 }
15331542 LexicalScopeBinding :: Item ( binding) => ( binding. res ( ) , Some ( binding) ) ,
15341543 LexicalScopeBinding :: Res ( res) => ( res, None ) ,
15351544 } ;
15361545
1537- // An immutable (no `mut`) by-value (no `ref`) binding pattern without
1538- // a sub pattern (no `@ $pat`) is syntactically ambiguous as it could
1539- // also be interpreted as a path to e.g. a constant, variant, etc.
1540- let is_syntactic_ambiguity = !has_sub && bm == BindingMode :: ByValue ( Mutability :: Not ) ;
1541-
15421546 match res {
15431547 Res :: SelfCtor ( _) // See #70549.
15441548 | Res :: Def (
0 commit comments