diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2022-10-10 19:21:35 +0400 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2022-10-11 09:04:52 +0400 |
| commit | 1a8f177772658a244e79a9aa2d48898a4e24c9ce (patch) | |
| tree | aa829f9272204646daf41265ed1a19a6bdd9bdbd /compiler/rustc_resolve/src/lib.rs | |
| parent | 518263d889818d16a09a8260f212f8ff4bf345f1 (diff) | |
| download | rust-1a8f177772658a244e79a9aa2d48898a4e24c9ce.tar.gz rust-1a8f177772658a244e79a9aa2d48898a4e24c9ce.zip | |
rustc_hir: Less error-prone methods for accessing `PartialRes` resolution
Diffstat (limited to 'compiler/rustc_resolve/src/lib.rs')
| -rw-r--r-- | compiler/rustc_resolve/src/lib.rs | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 9173c3692ce..bf941726123 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -1882,12 +1882,10 @@ impl<'a> Resolver<'a> { match self.maybe_resolve_path(&segments, Some(ns), &parent_scope) { PathResult::Module(ModuleOrUniformRoot::Module(module)) => Some(module.res().unwrap()), - PathResult::NonModule(path_res) if path_res.unresolved_segments() == 0 => { - Some(path_res.base_res()) + PathResult::NonModule(path_res) => path_res.full_res(), + PathResult::Module(ModuleOrUniformRoot::ExternPrelude) | PathResult::Failed { .. } => { + None } - PathResult::Module(ModuleOrUniformRoot::ExternPrelude) - | PathResult::NonModule(..) - | PathResult::Failed { .. } => None, PathResult::Module(..) | PathResult::Indeterminate => unreachable!(), } } @@ -1938,12 +1936,8 @@ impl<'a> Resolver<'a> { return None; } - let partial_res = self.partial_res_map.get(&expr.id)?; - if partial_res.unresolved_segments() != 0 { - return None; - } - - if let Res::Def(def::DefKind::Fn, def_id) = partial_res.base_res() { + let res = self.partial_res_map.get(&expr.id)?.full_res()?; + if let Res::Def(def::DefKind::Fn, def_id) = res { // We only support cross-crate argument rewriting. Uses // within the same crate should be updated to use the new // const generics style. |
