diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 23 |
2 files changed, 25 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 132ee0ca2..cff7e7481 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -407,7 +407,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
407 | 407 | ||
408 | let substs = | 408 | let substs = |
409 | Ty::substs_from_path_segment(self.db, &self.resolver, segment, typable); | 409 | Ty::substs_from_path_segment(self.db, &self.resolver, segment, typable); |
410 | self.db.type_for_def(typable, Namespace::Types).apply_substs(substs) | 410 | self.db.type_for_def(typable, Namespace::Types).subst(&substs) |
411 | } | 411 | } |
412 | Resolution::LocalBinding(_) => { | 412 | Resolution::LocalBinding(_) => { |
413 | // can't have a local binding in an associated item path | 413 | // can't have a local binding in an associated item path |
@@ -466,7 +466,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
466 | let typable: Option<TypableDef> = def.into(); | 466 | let typable: Option<TypableDef> = def.into(); |
467 | let typable = typable?; | 467 | let typable = typable?; |
468 | let substs = Ty::substs_from_path(self.db, &self.resolver, path, typable); | 468 | let substs = Ty::substs_from_path(self.db, &self.resolver, path, typable); |
469 | let ty = self.db.type_for_def(typable, Namespace::Values).apply_substs(substs); | 469 | let ty = self.db.type_for_def(typable, Namespace::Values).subst(&substs); |
470 | let ty = self.insert_type_vars(ty); | 470 | let ty = self.insert_type_vars(ty); |
471 | Some(ty) | 471 | Some(ty) |
472 | } | 472 | } |
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 0f2172ddf..5d8ad4aa7 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -1792,6 +1792,29 @@ fn test<R>(query_response: Canonical<QueryResponse<R>>) { | |||
1792 | } | 1792 | } |
1793 | 1793 | ||
1794 | #[test] | 1794 | #[test] |
1795 | fn bug_1030() { | ||
1796 | assert_snapshot_matches!(infer(r#" | ||
1797 | struct HashSet<T, H>; | ||
1798 | struct FxHasher; | ||
1799 | type FxHashSet<T> = HashSet<T, FxHasher>; | ||
1800 | |||
1801 | impl<T, H> HashSet<T, H> { | ||
1802 | fn default() -> HashSet<T, H> {} | ||
1803 | } | ||
1804 | |||
1805 | pub fn main_loop() { | ||
1806 | FxHashSet::default(); | ||
1807 | } | ||
1808 | "#), | ||
1809 | @r###" | ||
1810 | [144; 146) '{}': () | ||
1811 | [169; 198) '{ ...t(); }': () | ||
1812 | [175; 193) 'FxHash...efault': fn default<{unknown}, {unknown}>() -> HashSet<T, H> | ||
1813 | [175; 195) 'FxHash...ault()': HashSet<{unknown}, {unknown}>"### | ||
1814 | ); | ||
1815 | } | ||
1816 | |||
1817 | #[test] | ||
1795 | fn cross_crate_associated_method_call() { | 1818 | fn cross_crate_associated_method_call() { |
1796 | let (mut db, pos) = MockDatabase::with_position( | 1819 | let (mut db, pos) = MockDatabase::with_position( |
1797 | r#" | 1820 | r#" |