@@ -2287,24 +2287,25 @@ impl<'a> Resolver<'a> {
2287
2287
PatKind :: Ident ( bmode, ref ident, ref opt_pat) => {
2288
2288
// First try to resolve the identifier as some existing
2289
2289
// entity, then fall back to a fresh binding.
2290
- let resolution = if let Ok ( resolution ) = self . resolve_path ( pat . id ,
2291
- & Path :: from_ident ( ident . span , ident . node ) , 0 , ValueNS ) {
2290
+ let local_def = self . resolve_identifier ( ident . node , ValueNS , true ) ;
2291
+ let resolution = if let Some ( LocalDef { def , .. } ) = local_def {
2292
2292
let always_binding = !pat_src. is_refutable ( ) || opt_pat. is_some ( ) ||
2293
2293
bmode != BindingMode :: ByValue ( Mutability :: Immutable ) ;
2294
- match resolution . base_def {
2294
+ match def {
2295
2295
Def :: Struct ( ..) | Def :: Variant ( ..) |
2296
2296
Def :: Const ( ..) | Def :: AssociatedConst ( ..) if !always_binding => {
2297
2297
// A constant, unit variant, etc pattern.
2298
- resolution
2298
+ PathResolution :: new ( def )
2299
2299
}
2300
2300
Def :: Struct ( ..) | Def :: Variant ( ..) |
2301
2301
Def :: Const ( ..) | Def :: AssociatedConst ( ..) | Def :: Static ( ..) => {
2302
2302
// A fresh binding that shadows something unacceptable.
2303
+ let kind_name = PathResolution :: new ( def) . kind_name ( ) ;
2303
2304
resolve_error (
2304
2305
self ,
2305
2306
ident. span ,
2306
2307
ResolutionError :: BindingShadowsSomethingUnacceptable (
2307
- pat_src. descr ( ) , resolution . kind_name ( ) , ident. node . name )
2308
+ pat_src. descr ( ) , kind_name, ident. node . name )
2308
2309
) ;
2309
2310
err_path_resolution ( )
2310
2311
}
0 commit comments