aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-03-23 17:03:09 +0000
committerFlorian Diebold <[email protected]>2019-03-23 17:03:09 +0000
commitdbfc68cea05c82d5bd7f8ee4f1cec4b173517eb4 (patch)
tree0a7386866a6bc0b1f3dc4d3653e683edeeca940f /crates/ra_hir/src
parent5a6a3d077734d12fe5c7de2af64572611b23b79b (diff)
Fix apply_substs assertion failure
Fixes #1030.
Diffstat (limited to 'crates/ra_hir/src')
-rw-r--r--crates/ra_hir/src/ty/infer.rs4
-rw-r--r--crates/ra_hir/src/ty/tests.rs23
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]
1795fn bug_1030() {
1796 assert_snapshot_matches!(infer(r#"
1797struct HashSet<T, H>;
1798struct FxHasher;
1799type FxHashSet<T> = HashSet<T, FxHasher>;
1800
1801impl<T, H> HashSet<T, H> {
1802 fn default() -> HashSet<T, H> {}
1803}
1804
1805pub 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]
1795fn cross_crate_associated_method_call() { 1818fn 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#"