@@ -1522,23 +1522,27 @@ impl<'a, 'b, 'ast> LateResolutionVisitor<'a, 'b, 'ast> {
1522
1522
ident : Ident ,
1523
1523
has_sub : bool ,
1524
1524
) -> 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
+
1525
1530
let ls_binding = self . resolve_ident_in_lexical_scope ( ident, ValueNS , None , pat. span ) ?;
1526
1531
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
+ {
1528
1535
// For ambiguous bindings we don't know all their definitions and cannot check
1529
1536
// 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.
1530
1539
self . r . record_use ( ident, ValueNS , binding, false ) ;
1531
1540
return None ;
1532
1541
}
1533
1542
LexicalScopeBinding :: Item ( binding) => ( binding. res ( ) , Some ( binding) ) ,
1534
1543
LexicalScopeBinding :: Res ( res) => ( res, None ) ,
1535
1544
} ;
1536
1545
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
-
1542
1546
match res {
1543
1547
Res :: SelfCtor ( _) // See #70549.
1544
1548
| Res :: Def (
0 commit comments