diff options
| author | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-06-19 22:32:51 +0000 |
|---|---|---|
| committer | Jeffrey Seyfried <jeffrey.seyfried@gmail.com> | 2016-06-28 05:28:23 +0000 |
| commit | 4a13bcb4fbd2a305ebc6906960a00f72342295a9 (patch) | |
| tree | 1aed7e97049c79046a993b18e11af51725003e0e | |
| parent | 2dc15f2b96bad1c03fde93640b2d092600b0bf0c (diff) | |
| download | rust-4a13bcb4fbd2a305ebc6906960a00f72342295a9.tar.gz rust-4a13bcb4fbd2a305ebc6906960a00f72342295a9.zip | |
groundwork: use `resolve_identifier` instead of `resolve_path` to classify ident patterns
| -rw-r--r-- | src/librustc_resolve/lib.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/librustc_resolve/lib.rs b/src/librustc_resolve/lib.rs index 8ffa95ec7e9..00d6bc69bdf 100644 --- a/src/librustc_resolve/lib.rs +++ b/src/librustc_resolve/lib.rs @@ -2287,24 +2287,25 @@ impl<'a> Resolver<'a> { PatKind::Ident(bmode, ref ident, ref opt_pat) => { // First try to resolve the identifier as some existing // entity, then fall back to a fresh binding. - let resolution = if let Ok(resolution) = self.resolve_path(pat.id, - &Path::from_ident(ident.span, ident.node), 0, ValueNS) { + let local_def = self.resolve_identifier(ident.node, ValueNS, true); + let resolution = if let Some(LocalDef { def, .. }) = local_def { let always_binding = !pat_src.is_refutable() || opt_pat.is_some() || bmode != BindingMode::ByValue(Mutability::Immutable); - match resolution.base_def { + match def { Def::Struct(..) | Def::Variant(..) | Def::Const(..) | Def::AssociatedConst(..) if !always_binding => { // A constant, unit variant, etc pattern. - resolution + PathResolution::new(def) } Def::Struct(..) | Def::Variant(..) | Def::Const(..) | Def::AssociatedConst(..) | Def::Static(..) => { // A fresh binding that shadows something unacceptable. + let kind_name = PathResolution::new(def).kind_name(); resolve_error( self, ident.span, ResolutionError::BindingShadowsSomethingUnacceptable( - pat_src.descr(), resolution.kind_name(), ident.node.name) + pat_src.descr(), kind_name, ident.node.name) ); err_path_resolution() } |
