diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 37 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/lower.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 6 |
3 files changed, 26 insertions, 21 deletions
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 | }; |
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index c34e89af7..54b2a8c16 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -2481,8 +2481,10 @@ fn main() { | |||
2481 | } | 2481 | } |
2482 | "#), | 2482 | "#), |
2483 | @r###" | 2483 | @r###" |
2484 | [156; 182) '{ ...,2); }': () | 2484 | ⋮ |
2485 | [166; 167) 'x': Foo"### | 2485 | ⋮[156; 182) '{ ...,2); }': () |
2486 | ⋮[166; 167) 'x': Foo | ||
2487 | "### | ||
2486 | ); | 2488 | ); |
2487 | } | 2489 | } |
2488 | 2490 | ||