Skip to content

Commit 4a13bcb

Browse files
committed
groundwork: use resolve_identifier instead of resolve_path to classify ident patterns
1 parent 2dc15f2 commit 4a13bcb

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

src/librustc_resolve/lib.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,24 +2287,25 @@ impl<'a> Resolver<'a> {
22872287
PatKind::Ident(bmode, ref ident, ref opt_pat) => {
22882288
// First try to resolve the identifier as some existing
22892289
// 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 {
22922292
let always_binding = !pat_src.is_refutable() || opt_pat.is_some() ||
22932293
bmode != BindingMode::ByValue(Mutability::Immutable);
2294-
match resolution.base_def {
2294+
match def {
22952295
Def::Struct(..) | Def::Variant(..) |
22962296
Def::Const(..) | Def::AssociatedConst(..) if !always_binding => {
22972297
// A constant, unit variant, etc pattern.
2298-
resolution
2298+
PathResolution::new(def)
22992299
}
23002300
Def::Struct(..) | Def::Variant(..) |
23012301
Def::Const(..) | Def::AssociatedConst(..) | Def::Static(..) => {
23022302
// A fresh binding that shadows something unacceptable.
2303+
let kind_name = PathResolution::new(def).kind_name();
23032304
resolve_error(
23042305
self,
23052306
ident.span,
23062307
ResolutionError::BindingShadowsSomethingUnacceptable(
2307-
pat_src.descr(), resolution.kind_name(), ident.node.name)
2308+
pat_src.descr(), kind_name, ident.node.name)
23082309
);
23092310
err_path_resolution()
23102311
}

0 commit comments

Comments
 (0)