aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-06-08 16:38:14 +0100
committerAleksey Kladov <[email protected]>2019-06-08 16:38:14 +0100
commit780e1a365b10027c4bd4adcc939ab32da1d91492 (patch)
tree549695a76379384898d49fc8eeb41d08ea55ef93
parentbb55111c209a9d3a6249cab35308a506b7f22d53 (diff)
somewhat better name
-rw-r--r--crates/ra_hir/src/resolve.rs6
-rw-r--r--crates/ra_hir/src/source_binder.rs4
-rw-r--r--crates/ra_hir/src/ty/infer.rs37
-rw-r--r--crates/ra_hir/src/ty/lower.rs4
4 files changed, 29 insertions, 22 deletions
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs
index d6956f45e..347bcf27d 100644
--- a/crates/ra_hir/src/resolve.rs
+++ b/crates/ra_hir/src/resolve.rs
@@ -165,7 +165,11 @@ impl Resolver {
165 165
166 /// Returns the fully resolved path if we were able to resolve it. 166 /// Returns the fully resolved path if we were able to resolve it.
167 /// otherwise returns `PerNs::none` 167 /// otherwise returns `PerNs::none`
168 pub(crate) fn resolve_path(&self, db: &impl HirDatabase, path: &Path) -> PerNs<Resolution> { 168 pub(crate) fn resolve_path_without_assoc_items(
169 &self,
170 db: &impl HirDatabase,
171 path: &Path,
172 ) -> PerNs<Resolution> {
169 // into_fully_resolved() returns the fully resolved path or PerNs::none() otherwise 173 // into_fully_resolved() returns the fully resolved path or PerNs::none() otherwise
170 self.resolve_path_segments(db, path).into_fully_resolved() 174 self.resolve_path_segments(db, path).into_fully_resolved()
171 } 175 }
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs
index 410064d45..63ec59314 100644
--- a/crates/ra_hir/src/source_binder.rs
+++ b/crates/ra_hir/src/source_binder.rs
@@ -277,7 +277,7 @@ impl SourceAnalyzer {
277 db: &impl HirDatabase, 277 db: &impl HirDatabase,
278 path: &crate::Path, 278 path: &crate::Path,
279 ) -> PerNs<crate::Resolution> { 279 ) -> PerNs<crate::Resolution> {
280 self.resolver.resolve_path(db, path) 280 self.resolver.resolve_path_without_assoc_items(db, path)
281 } 281 }
282 282
283 pub fn resolve_path(&self, db: &impl HirDatabase, path: &ast::Path) -> Option<PathResolution> { 283 pub fn resolve_path(&self, db: &impl HirDatabase, path: &ast::Path) -> Option<PathResolution> {
@@ -294,7 +294,7 @@ impl SourceAnalyzer {
294 } 294 }
295 } 295 }
296 let hir_path = crate::Path::from_ast(path)?; 296 let hir_path = crate::Path::from_ast(path)?;
297 let res = self.resolver.resolve_path(db, &hir_path); 297 let res = self.resolver.resolve_path_without_assoc_items(db, &hir_path);
298 let res = res.clone().take_types().or_else(|| res.take_values())?; 298 let res = res.clone().take_types().or_else(|| res.take_values())?;
299 let res = match res { 299 let res = match res {
300 crate::Resolution::Def(it) => PathResolution::Def(it), 300 crate::Resolution::Def(it) => PathResolution::Def(it),
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index 6cc5dbc6f..6aa727ea1 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -610,23 +610,26 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
610 None => return (Ty::Unknown, None), 610 None => return (Ty::Unknown, None),
611 }; 611 };
612 let resolver = &self.resolver; 612 let resolver = &self.resolver;
613 let typable: Option<TypableDef> = match resolver.resolve_path(self.db, &path).take_types() { 613 let typable: Option<TypableDef> =
614 Some(Resolution::Def(def)) => def.into(), 614 // FIXME: this should resolve assoc items as well, see this example:
615 Some(Resolution::LocalBinding(..)) => { 615 // https://play.rust-lang.org/?gist=087992e9e22495446c01c0d4e2d69521
616 // this cannot happen 616 match resolver.resolve_path_without_assoc_items(self.db, &path).take_types() {
617 log::error!("path resolved to local binding in type ns"); 617 Some(Resolution::Def(def)) => def.into(),
618 return (Ty::Unknown, None); 618 Some(Resolution::LocalBinding(..)) => {
619 } 619 // this cannot happen
620 Some(Resolution::GenericParam(..)) => { 620 log::error!("path resolved to local binding in type ns");
621 // generic params can't be used in struct literals 621 return (Ty::Unknown, None);
622 return (Ty::Unknown, None); 622 }
623 } 623 Some(Resolution::GenericParam(..)) => {
624 Some(Resolution::SelfType(..)) => { 624 // generic params can't be used in struct literals
625 // FIXME this is allowed in an impl for a struct, handle this 625 return (Ty::Unknown, None);
626 return (Ty::Unknown, None); 626 }
627 } 627 Some(Resolution::SelfType(..)) => {
628 None => return (Ty::Unknown, None), 628 // FIXME this is allowed in an impl for a struct, handle this
629 }; 629 return (Ty::Unknown, None);
630 }
631 None => return (Ty::Unknown, None),
632 };
630 let def = match typable { 633 let def = match typable {
631 None => return (Ty::Unknown, None), 634 None => return (Ty::Unknown, None),
632 Some(it) => it, 635 Some(it) => it,
diff --git a/crates/ra_hir/src/ty/lower.rs b/crates/ra_hir/src/ty/lower.rs
index 71cd72234..26c213a41 100644
--- a/crates/ra_hir/src/ty/lower.rs
+++ b/crates/ra_hir/src/ty/lower.rs
@@ -65,7 +65,7 @@ impl Ty {
65 65
66 pub(crate) fn from_hir_path(db: &impl HirDatabase, resolver: &Resolver, path: &Path) -> Self { 66 pub(crate) fn from_hir_path(db: &impl HirDatabase, resolver: &Resolver, path: &Path) -> Self {
67 // Resolve the path (in type namespace) 67 // Resolve the path (in type namespace)
68 let resolution = resolver.resolve_path(db, path).take_types(); 68 let resolution = resolver.resolve_path_without_assoc_items(db, path).take_types();
69 69
70 let def = match resolution { 70 let def = match resolution {
71 Some(Resolution::Def(def)) => def, 71 Some(Resolution::Def(def)) => def,
@@ -216,7 +216,7 @@ impl TraitRef {
216 path: &Path, 216 path: &Path,
217 explicit_self_ty: Option<Ty>, 217 explicit_self_ty: Option<Ty>,
218 ) -> Option<Self> { 218 ) -> Option<Self> {
219 let resolved = match resolver.resolve_path(db, &path).take_types()? { 219 let resolved = match resolver.resolve_path_without_assoc_items(db, &path).take_types()? {
220 Resolution::Def(ModuleDef::Trait(tr)) => tr, 220 Resolution::Def(ModuleDef::Trait(tr)) => tr,
221 _ => return None, 221 _ => return None,
222 }; 222 };