diff options
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 80 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/tests.rs | 54 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/traits/chalk.rs | 6 |
3 files changed, 30 insertions, 110 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index eb5ca6769..9aad2d3fe 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -5,16 +5,14 @@ | |||
5 | use std::sync::Arc; | 5 | use std::sync::Arc; |
6 | 6 | ||
7 | use arrayvec::ArrayVec; | 7 | use arrayvec::ArrayVec; |
8 | use hir_def::CrateModuleId; | ||
9 | use rustc_hash::FxHashMap; | 8 | use rustc_hash::FxHashMap; |
10 | 9 | ||
11 | use crate::{ | 10 | use crate::{ |
12 | db::HirDatabase, | 11 | db::HirDatabase, |
13 | impl_block::{ImplBlock, ImplId}, | ||
14 | resolve::Resolver, | 12 | resolve::Resolver, |
15 | ty::primitive::{FloatBitness, Uncertain}, | 13 | ty::primitive::{FloatBitness, Uncertain}, |
16 | ty::{Ty, TypeCtor}, | 14 | ty::{Ty, TypeCtor}, |
17 | AssocItem, Crate, Function, Module, Mutability, Name, Trait, | 15 | AssocItem, Crate, Function, ImplBlock, Module, Mutability, Name, Trait, |
18 | }; | 16 | }; |
19 | 17 | ||
20 | use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef}; | 18 | use super::{autoderef, lower, Canonical, InEnvironment, TraitEnvironment, TraitRef}; |
@@ -39,65 +37,46 @@ impl TyFingerprint { | |||
39 | 37 | ||
40 | #[derive(Debug, PartialEq, Eq)] | 38 | #[derive(Debug, PartialEq, Eq)] |
41 | pub struct CrateImplBlocks { | 39 | pub struct CrateImplBlocks { |
42 | /// To make sense of the CrateModuleIds, we need the source root. | 40 | impls: FxHashMap<TyFingerprint, Vec<ImplBlock>>, |
43 | krate: Crate, | 41 | impls_by_trait: FxHashMap<Trait, Vec<ImplBlock>>, |
44 | impls: FxHashMap<TyFingerprint, Vec<(CrateModuleId, ImplId)>>, | ||
45 | impls_by_trait: FxHashMap<Trait, Vec<(CrateModuleId, ImplId)>>, | ||
46 | } | 42 | } |
47 | 43 | ||
48 | impl CrateImplBlocks { | 44 | impl CrateImplBlocks { |
49 | pub fn lookup_impl_blocks<'a>(&'a self, ty: &Ty) -> impl Iterator<Item = ImplBlock> + 'a { | 45 | pub(crate) fn impls_in_crate_query( |
46 | db: &impl HirDatabase, | ||
47 | krate: Crate, | ||
48 | ) -> Arc<CrateImplBlocks> { | ||
49 | let mut crate_impl_blocks = | ||
50 | CrateImplBlocks { impls: FxHashMap::default(), impls_by_trait: FxHashMap::default() }; | ||
51 | if let Some(module) = krate.root_module(db) { | ||
52 | crate_impl_blocks.collect_recursive(db, module); | ||
53 | } | ||
54 | Arc::new(crate_impl_blocks) | ||
55 | } | ||
56 | pub fn lookup_impl_blocks(&self, ty: &Ty) -> impl Iterator<Item = ImplBlock> + '_ { | ||
50 | let fingerprint = TyFingerprint::for_impl(ty); | 57 | let fingerprint = TyFingerprint::for_impl(ty); |
51 | fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flat_map(|i| i.iter()).map( | 58 | fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flatten().copied() |
52 | move |(module_id, impl_id)| { | ||
53 | let module = Module::new(self.krate, *module_id); | ||
54 | ImplBlock::from_id(module, *impl_id) | ||
55 | }, | ||
56 | ) | ||
57 | } | 59 | } |
58 | 60 | ||
59 | pub fn lookup_impl_blocks_for_trait<'a>( | 61 | pub fn lookup_impl_blocks_for_trait(&self, tr: Trait) -> impl Iterator<Item = ImplBlock> + '_ { |
60 | &'a self, | 62 | self.impls_by_trait.get(&tr).into_iter().flatten().copied() |
61 | tr: Trait, | ||
62 | ) -> impl Iterator<Item = ImplBlock> + 'a { | ||
63 | self.impls_by_trait.get(&tr).into_iter().flat_map(|i| i.iter()).map( | ||
64 | move |(module_id, impl_id)| { | ||
65 | let module = Module::new(self.krate, *module_id); | ||
66 | ImplBlock::from_id(module, *impl_id) | ||
67 | }, | ||
68 | ) | ||
69 | } | 63 | } |
70 | 64 | ||
71 | pub fn all_impls<'a>(&'a self) -> impl Iterator<Item = ImplBlock> + 'a { | 65 | pub fn all_impls<'a>(&'a self) -> impl Iterator<Item = ImplBlock> + 'a { |
72 | self.impls.values().chain(self.impls_by_trait.values()).flat_map(|i| i.iter()).map( | 66 | self.impls.values().chain(self.impls_by_trait.values()).flatten().copied() |
73 | move |(module_id, impl_id)| { | ||
74 | let module = Module::new(self.krate, *module_id); | ||
75 | ImplBlock::from_id(module, *impl_id) | ||
76 | }, | ||
77 | ) | ||
78 | } | 67 | } |
79 | 68 | ||
80 | fn collect_recursive(&mut self, db: &impl HirDatabase, module: Module) { | 69 | fn collect_recursive(&mut self, db: &impl HirDatabase, module: Module) { |
81 | let module_impl_blocks = db.impls_in_module(module); | 70 | for impl_block in module.impl_blocks(db) { |
82 | |||
83 | for (impl_id, _) in module_impl_blocks.impls.iter() { | ||
84 | let impl_block = ImplBlock::from_id(module_impl_blocks.module, impl_id); | ||
85 | |||
86 | let target_ty = impl_block.target_ty(db); | 71 | let target_ty = impl_block.target_ty(db); |
87 | 72 | ||
88 | if impl_block.target_trait(db).is_some() { | 73 | if impl_block.target_trait(db).is_some() { |
89 | if let Some(tr) = impl_block.target_trait_ref(db) { | 74 | if let Some(tr) = impl_block.target_trait_ref(db) { |
90 | self.impls_by_trait | 75 | self.impls_by_trait.entry(tr.trait_).or_default().push(impl_block); |
91 | .entry(tr.trait_) | ||
92 | .or_insert_with(Vec::new) | ||
93 | .push((module.id.module_id, impl_id)); | ||
94 | } | 76 | } |
95 | } else { | 77 | } else { |
96 | if let Some(target_ty_fp) = TyFingerprint::for_impl(&target_ty) { | 78 | if let Some(target_ty_fp) = TyFingerprint::for_impl(&target_ty) { |
97 | self.impls | 79 | self.impls.entry(target_ty_fp).or_default().push(impl_block); |
98 | .entry(target_ty_fp) | ||
99 | .or_insert_with(Vec::new) | ||
100 | .push((module.id.module_id, impl_id)); | ||
101 | } | 80 | } |
102 | } | 81 | } |
103 | } | 82 | } |
@@ -106,21 +85,6 @@ impl CrateImplBlocks { | |||
106 | self.collect_recursive(db, child); | 85 | self.collect_recursive(db, child); |
107 | } | 86 | } |
108 | } | 87 | } |
109 | |||
110 | pub(crate) fn impls_in_crate_query( | ||
111 | db: &impl HirDatabase, | ||
112 | krate: Crate, | ||
113 | ) -> Arc<CrateImplBlocks> { | ||
114 | let mut crate_impl_blocks = CrateImplBlocks { | ||
115 | krate, | ||
116 | impls: FxHashMap::default(), | ||
117 | impls_by_trait: FxHashMap::default(), | ||
118 | }; | ||
119 | if let Some(module) = krate.root_module(db) { | ||
120 | crate_impl_blocks.collect_recursive(db, module); | ||
121 | } | ||
122 | Arc::new(crate_impl_blocks) | ||
123 | } | ||
124 | } | 88 | } |
125 | 89 | ||
126 | fn def_crates(db: &impl HirDatabase, cur_crate: Crate, ty: &Ty) -> Option<ArrayVec<[Crate; 2]>> { | 90 | fn def_crates(db: &impl HirDatabase, cur_crate: Crate, ty: &Ty) -> Option<ArrayVec<[Crate; 2]>> { |
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs index 8863c3608..fe9346c78 100644 --- a/crates/ra_hir/src/ty/tests.rs +++ b/crates/ra_hir/src/ty/tests.rs | |||
@@ -254,7 +254,6 @@ fn test(a: u32, b: isize, c: !, d: &str) { | |||
254 | 1.0f32; | 254 | 1.0f32; |
255 | }"#), | 255 | }"#), |
256 | @r###" | 256 | @r###" |
257 | |||
258 | [9; 10) 'a': u32 | 257 | [9; 10) 'a': u32 |
259 | [17; 18) 'b': isize | 258 | [17; 18) 'b': isize |
260 | [27; 28) 'c': ! | 259 | [27; 28) 'c': ! |
@@ -317,7 +316,6 @@ fn test() { | |||
317 | } | 316 | } |
318 | "#), | 317 | "#), |
319 | @r###" | 318 | @r###" |
320 | |||
321 | [15; 20) '{ 1 }': u32 | 319 | [15; 20) '{ 1 }': u32 |
322 | [17; 18) '1': u32 | 320 | [17; 18) '1': u32 |
323 | [48; 53) '{ 1 }': u32 | 321 | [48; 53) '{ 1 }': u32 |
@@ -354,7 +352,7 @@ fn test() { | |||
354 | [66; 74) 'S::foo()': i32 | 352 | [66; 74) 'S::foo()': i32 |
355 | [80; 88) '<S>::foo': fn foo() -> i32 | 353 | [80; 88) '<S>::foo': fn foo() -> i32 |
356 | [80; 90) '<S>::foo()': i32 | 354 | [80; 90) '<S>::foo()': i32 |
357 | "### | 355 | "### |
358 | ); | 356 | ); |
359 | } | 357 | } |
360 | 358 | ||
@@ -409,7 +407,6 @@ fn test() { | |||
409 | } | 407 | } |
410 | "#), | 408 | "#), |
411 | @r###" | 409 | @r###" |
412 | |||
413 | [72; 154) '{ ...a.c; }': () | 410 | [72; 154) '{ ...a.c; }': () |
414 | [82; 83) 'c': C | 411 | [82; 83) 'c': C |
415 | [86; 87) 'C': C(usize) -> C | 412 | [86; 87) 'C': C(usize) -> C |
@@ -443,7 +440,6 @@ fn test() { | |||
443 | E::V2; | 440 | E::V2; |
444 | }"#), | 441 | }"#), |
445 | @r###" | 442 | @r###" |
446 | |||
447 | [48; 82) '{ E:...:V2; }': () | 443 | [48; 82) '{ E:...:V2; }': () |
448 | [52; 70) 'E::V1 ...d: 1 }': E | 444 | [52; 70) 'E::V1 ...d: 1 }': E |
449 | [67; 68) '1': u32 | 445 | [67; 68) '1': u32 |
@@ -471,7 +467,6 @@ fn test(a: &u32, b: &mut u32, c: *const u32, d: *mut u32) { | |||
471 | } | 467 | } |
472 | "#), | 468 | "#), |
473 | @r###" | 469 | @r###" |
474 | |||
475 | [9; 10) 'a': &u32 | 470 | [9; 10) 'a': &u32 |
476 | [18; 19) 'b': &mut u32 | 471 | [18; 19) 'b': &mut u32 |
477 | [31; 32) 'c': *const u32 | 472 | [31; 32) 'c': *const u32 |
@@ -524,7 +519,6 @@ fn test() { | |||
524 | } | 519 | } |
525 | "##), | 520 | "##), |
526 | @r###" | 521 | @r###" |
527 | |||
528 | [11; 221) '{ ...o"#; }': () | 522 | [11; 221) '{ ...o"#; }': () |
529 | [17; 21) '5i32': i32 | 523 | [17; 21) '5i32': i32 |
530 | [27; 31) '5f32': f32 | 524 | [27; 31) '5f32': f32 |
@@ -568,7 +562,6 @@ fn test(x: SomeType) { | |||
568 | } | 562 | } |
569 | "#), | 563 | "#), |
570 | @r###" | 564 | @r###" |
571 | |||
572 | [27; 28) 'x': SomeType | 565 | [27; 28) 'x': SomeType |
573 | [40; 272) '{ ...lo"; }': () | 566 | [40; 272) '{ ...lo"; }': () |
574 | [50; 51) 'b': bool | 567 | [50; 51) 'b': bool |
@@ -632,7 +625,6 @@ fn test() -> &mut &f64 { | |||
632 | } | 625 | } |
633 | "#), | 626 | "#), |
634 | @r###" | 627 | @r###" |
635 | |||
636 | [14; 15) 'x': u32 | 628 | [14; 15) 'x': u32 |
637 | [22; 24) '{}': () | 629 | [22; 24) '{}': () |
638 | [78; 231) '{ ...t &c }': &mut &f64 | 630 | [78; 231) '{ ...t &c }': &mut &f64 |
@@ -679,7 +671,6 @@ impl S { | |||
679 | } | 671 | } |
680 | "#), | 672 | "#), |
681 | @r###" | 673 | @r###" |
682 | |||
683 | [34; 38) 'self': &S | 674 | [34; 38) 'self': &S |
684 | [40; 61) '{ ... }': () | 675 | [40; 61) '{ ... }': () |
685 | [50; 54) 'self': &S | 676 | [50; 54) 'self': &S |
@@ -719,7 +710,6 @@ fn test() -> bool { | |||
719 | } | 710 | } |
720 | "#), | 711 | "#), |
721 | @r###" | 712 | @r###" |
722 | |||
723 | [6; 7) 'x': bool | 713 | [6; 7) 'x': bool |
724 | [22; 34) '{ 0i32 }': i32 | 714 | [22; 34) '{ 0i32 }': i32 |
725 | [28; 32) '0i32': i32 | 715 | [28; 32) '0i32': i32 |
@@ -802,7 +792,6 @@ fn test2(a1: *const A, a2: *mut A) { | |||
802 | } | 792 | } |
803 | "#), | 793 | "#), |
804 | @r###" | 794 | @r###" |
805 | |||
806 | [44; 45) 'a': A | 795 | [44; 45) 'a': A |
807 | [50; 213) '{ ...5.b; }': () | 796 | [50; 213) '{ ...5.b; }': () |
808 | [60; 62) 'a1': A | 797 | [60; 62) 'a1': A |
@@ -970,7 +959,7 @@ fn test(a: A<i32>) { | |||
970 | [374; 375) 'B': B<A<i32>>(T) -> B<T> | 959 | [374; 375) 'B': B<A<i32>>(T) -> B<T> |
971 | [374; 378) 'B(a)': B<A<i32>> | 960 | [374; 378) 'B(a)': B<A<i32>> |
972 | [376; 377) 'a': A<i32> | 961 | [376; 377) 'a': A<i32> |
973 | "### | 962 | "### |
974 | ); | 963 | ); |
975 | } | 964 | } |
976 | 965 | ||
@@ -983,7 +972,6 @@ fn test() { | |||
983 | } | 972 | } |
984 | "#), | 973 | "#), |
985 | @r###" | 974 | @r###" |
986 | |||
987 | [11; 37) '{ l... {}; }': () | 975 | [11; 37) '{ l... {}; }': () |
988 | [20; 21) 'x': () | 976 | [20; 21) 'x': () |
989 | [24; 34) 'if true {}': () | 977 | [24; 34) 'if true {}': () |
@@ -1105,7 +1093,6 @@ fn test(a: A) { | |||
1105 | } | 1093 | } |
1106 | "#), | 1094 | "#), |
1107 | @r###" | 1095 | @r###" |
1108 | |||
1109 | [32; 36) 'self': A | 1096 | [32; 36) 'self': A |
1110 | [38; 39) 'x': u32 | 1097 | [38; 39) 'x': u32 |
1111 | [53; 55) '{}': () | 1098 | [53; 55) '{}': () |
@@ -1142,7 +1129,6 @@ fn test() { | |||
1142 | } | 1129 | } |
1143 | "#), | 1130 | "#), |
1144 | @r###" | 1131 | @r###" |
1145 | |||
1146 | [40; 44) 'self': &str | 1132 | [40; 44) 'self': &str |
1147 | [53; 55) '{}': () | 1133 | [53; 55) '{}': () |
1148 | [69; 89) '{ ...o(); }': () | 1134 | [69; 89) '{ ...o(); }': () |
@@ -1166,7 +1152,6 @@ fn test(x: &str, y: isize) { | |||
1166 | } | 1152 | } |
1167 | "#), | 1153 | "#), |
1168 | @r###" | 1154 | @r###" |
1169 | |||
1170 | [9; 10) 'x': &str | 1155 | [9; 10) 'x': &str |
1171 | [18; 19) 'y': isize | 1156 | [18; 19) 'y': isize |
1172 | [28; 170) '{ ...d"); }': () | 1157 | [28; 170) '{ ...d"); }': () |
@@ -1367,7 +1352,6 @@ fn test() { | |||
1367 | } | 1352 | } |
1368 | "#), | 1353 | "#), |
1369 | @r###" | 1354 | @r###" |
1370 | |||
1371 | [28; 79) '{ ...(1); }': () | 1355 | [28; 79) '{ ...(1); }': () |
1372 | [38; 42) 'A(n)': A<i32> | 1356 | [38; 42) 'A(n)': A<i32> |
1373 | [40; 41) 'n': &i32 | 1357 | [40; 41) 'n': &i32 |
@@ -1396,7 +1380,6 @@ fn test() { | |||
1396 | } | 1380 | } |
1397 | "#), | 1381 | "#), |
1398 | @r###" | 1382 | @r###" |
1399 | |||
1400 | [11; 57) '{ ...= v; }': () | 1383 | [11; 57) '{ ...= v; }': () |
1401 | [21; 22) 'v': &(i32, &i32) | 1384 | [21; 22) 'v': &(i32, &i32) |
1402 | [25; 33) '&(1, &2)': &(i32, &i32) | 1385 | [25; 33) '&(1, &2)': &(i32, &i32) |
@@ -1441,7 +1424,6 @@ fn test() { | |||
1441 | } | 1424 | } |
1442 | "#), | 1425 | "#), |
1443 | @r###" | 1426 | @r###" |
1444 | |||
1445 | [68; 289) '{ ... d; }': () | 1427 | [68; 289) '{ ... d; }': () |
1446 | [78; 79) 'e': E | 1428 | [78; 79) 'e': E |
1447 | [82; 95) 'E::A { x: 3 }': E | 1429 | [82; 95) 'E::A { x: 3 }': E |
@@ -1488,7 +1470,6 @@ fn test(a1: A<u32>, i: i32) { | |||
1488 | } | 1470 | } |
1489 | "#), | 1471 | "#), |
1490 | @r###" | 1472 | @r###" |
1491 | |||
1492 | [36; 38) 'a1': A<u32> | 1473 | [36; 38) 'a1': A<u32> |
1493 | [48; 49) 'i': i32 | 1474 | [48; 49) 'i': i32 |
1494 | [56; 147) '{ ...3.x; }': () | 1475 | [56; 147) '{ ...3.x; }': () |
@@ -1569,7 +1550,6 @@ fn test(a1: A<u32>, o: Option<u64>) { | |||
1569 | } | 1550 | } |
1570 | "#), | 1551 | "#), |
1571 | @r###" | 1552 | @r###" |
1572 | |||
1573 | [79; 81) 'a1': A<u32> | 1553 | [79; 81) 'a1': A<u32> |
1574 | [91; 92) 'o': Option<u64> | 1554 | [91; 92) 'o': Option<u64> |
1575 | [107; 244) '{ ... }; }': () | 1555 | [107; 244) '{ ... }; }': () |
@@ -1604,7 +1584,6 @@ fn test() { | |||
1604 | } | 1584 | } |
1605 | "#), | 1585 | "#), |
1606 | @r###" | 1586 | @r###" |
1607 | |||
1608 | [10; 11) 't': T | 1587 | [10; 11) 't': T |
1609 | [21; 26) '{ t }': T | 1588 | [21; 26) '{ t }': T |
1610 | [23; 24) 't': T | 1589 | [23; 24) 't': T |
@@ -1652,7 +1631,6 @@ fn test() -> i128 { | |||
1652 | } | 1631 | } |
1653 | "#), | 1632 | "#), |
1654 | @r###" | 1633 | @r###" |
1655 | |||
1656 | [74; 78) 'self': A<X, Y> | 1634 | [74; 78) 'self': A<X, Y> |
1657 | [85; 107) '{ ... }': X | 1635 | [85; 107) '{ ... }': X |
1658 | [95; 99) 'self': A<X, Y> | 1636 | [95; 99) 'self': A<X, Y> |
@@ -1706,7 +1684,6 @@ fn test(o: Option<u32>) { | |||
1706 | } | 1684 | } |
1707 | "#), | 1685 | "#), |
1708 | @r###" | 1686 | @r###" |
1709 | |||
1710 | [78; 82) 'self': &Option<T> | 1687 | [78; 82) 'self': &Option<T> |
1711 | [98; 100) '{}': () | 1688 | [98; 100) '{}': () |
1712 | [111; 112) 'o': Option<u32> | 1689 | [111; 112) 'o': Option<u32> |
@@ -1744,7 +1721,6 @@ fn test() -> i128 { | |||
1744 | } | 1721 | } |
1745 | "#), | 1722 | "#), |
1746 | @r###" | 1723 | @r###" |
1747 | |||
1748 | [53; 57) 'self': A<T2> | 1724 | [53; 57) 'self': A<T2> |
1749 | [65; 87) '{ ... }': T2 | 1725 | [65; 87) '{ ... }': T2 |
1750 | [75; 79) 'self': A<T2> | 1726 | [75; 79) 'self': A<T2> |
@@ -1921,7 +1897,6 @@ fn test() { | |||
1921 | } | 1897 | } |
1922 | "#), | 1898 | "#), |
1923 | @r###" | 1899 | @r###" |
1924 | |||
1925 | [56; 64) '{ A {} }': A | 1900 | [56; 64) '{ A {} }': A |
1926 | [58; 62) 'A {}': A | 1901 | [58; 62) 'A {}': A |
1927 | [126; 132) '{ 99 }': u32 | 1902 | [126; 132) '{ 99 }': u32 |
@@ -1961,7 +1936,6 @@ fn test() { | |||
1961 | } | 1936 | } |
1962 | "#), | 1937 | "#), |
1963 | @r###" | 1938 | @r###" |
1964 | |||
1965 | [64; 67) 'val': T | 1939 | [64; 67) 'val': T |
1966 | [82; 109) '{ ... }': Gen<T> | 1940 | [82; 109) '{ ... }': Gen<T> |
1967 | [92; 103) 'Gen { val }': Gen<T> | 1941 | [92; 103) 'Gen { val }': Gen<T> |
@@ -2129,7 +2103,6 @@ fn test(x: X) { | |||
2129 | } | 2103 | } |
2130 | "#), | 2104 | "#), |
2131 | @r###" | 2105 | @r###" |
2132 | |||
2133 | [20; 21) 'x': X | 2106 | [20; 21) 'x': X |
2134 | [26; 47) '{ ...eld; }': () | 2107 | [26; 47) '{ ...eld; }': () |
2135 | [32; 33) 'x': X | 2108 | [32; 33) 'x': X |
@@ -2151,7 +2124,6 @@ fn test() { | |||
2151 | } | 2124 | } |
2152 | "#), | 2125 | "#), |
2153 | @r###" | 2126 | @r###" |
2154 | |||
2155 | [11; 89) '{ ... } }': () | 2127 | [11; 89) '{ ... } }': () |
2156 | [17; 21) 'X {}': {unknown} | 2128 | [17; 21) 'X {}': {unknown} |
2157 | [27; 87) 'match ... }': () | 2129 | [27; 87) 'match ... }': () |
@@ -2174,7 +2146,6 @@ fn quux() { | |||
2174 | } | 2146 | } |
2175 | "#), | 2147 | "#), |
2176 | @r###" | 2148 | @r###" |
2177 | |||
2178 | [11; 41) '{ ...+ y; }': () | 2149 | [11; 41) '{ ...+ y; }': () |
2179 | [21; 22) 'y': i32 | 2150 | [21; 22) 'y': i32 |
2180 | [25; 27) '92': i32 | 2151 | [25; 27) '92': i32 |
@@ -2300,7 +2271,6 @@ fn write() { | |||
2300 | } | 2271 | } |
2301 | "#), | 2272 | "#), |
2302 | @r###" | 2273 | @r###" |
2303 | |||
2304 | [54; 139) '{ ... } }': () | 2274 | [54; 139) '{ ... } }': () |
2305 | [60; 137) 'match ... }': () | 2275 | [60; 137) 'match ... }': () |
2306 | [66; 83) 'someth...nknown': Maybe<{unknown}> | 2276 | [66; 83) 'someth...nknown': Maybe<{unknown}> |
@@ -2322,7 +2292,6 @@ fn test_line_buffer() { | |||
2322 | } | 2292 | } |
2323 | "#), | 2293 | "#), |
2324 | @r###" | 2294 | @r###" |
2325 | |||
2326 | [23; 53) '{ ...n']; }': () | 2295 | [23; 53) '{ ...n']; }': () |
2327 | [29; 50) '&[0, b...b'\n']': &[u8;_] | 2296 | [29; 50) '&[0, b...b'\n']': &[u8;_] |
2328 | [30; 50) '[0, b'...b'\n']': [u8;_] | 2297 | [30; 50) '[0, b'...b'\n']': [u8;_] |
@@ -2446,7 +2415,6 @@ fn test<R>(query_response: Canonical<QueryResponse<R>>) { | |||
2446 | } | 2415 | } |
2447 | "#), | 2416 | "#), |
2448 | @r###" | 2417 | @r###" |
2449 | |||
2450 | [92; 106) 'query_response': Canonical<QueryResponse<R>> | 2418 | [92; 106) 'query_response': Canonical<QueryResponse<R>> |
2451 | [137; 167) '{ ...lue; }': () | 2419 | [137; 167) '{ ...lue; }': () |
2452 | [143; 164) '&query....value': &QueryResponse<R> | 2420 | [143; 164) '&query....value': &QueryResponse<R> |
@@ -2472,7 +2440,6 @@ pub fn main_loop() { | |||
2472 | } | 2440 | } |
2473 | "#), | 2441 | "#), |
2474 | @r###" | 2442 | @r###" |
2475 | |||
2476 | [144; 146) '{}': () | 2443 | [144; 146) '{}': () |
2477 | [169; 198) '{ ...t(); }': () | 2444 | [169; 198) '{ ...t(); }': () |
2478 | [175; 193) 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<T, H> | 2445 | [175; 193) 'FxHash...efault': fn default<{unknown}, FxHasher>() -> HashSet<T, H> |
@@ -2518,7 +2485,6 @@ fn test() { | |||
2518 | } | 2485 | } |
2519 | "#), | 2486 | "#), |
2520 | @r###" | 2487 | @r###" |
2521 | |||
2522 | [49; 50) '0': u32 | 2488 | [49; 50) '0': u32 |
2523 | [80; 83) '101': u32 | 2489 | [80; 83) '101': u32 |
2524 | [95; 213) '{ ...NST; }': () | 2490 | [95; 213) '{ ...NST; }': () |
@@ -2549,7 +2515,6 @@ fn test() { | |||
2549 | } | 2515 | } |
2550 | "#), | 2516 | "#), |
2551 | @r###" | 2517 | @r###" |
2552 | |||
2553 | [29; 32) '101': u32 | 2518 | [29; 32) '101': u32 |
2554 | [70; 73) '101': u32 | 2519 | [70; 73) '101': u32 |
2555 | [85; 280) '{ ...MUT; }': () | 2520 | [85; 280) '{ ...MUT; }': () |
@@ -2588,7 +2553,6 @@ fn test() { | |||
2588 | } | 2553 | } |
2589 | "#), | 2554 | "#), |
2590 | @r###" | 2555 | @r###" |
2591 | |||
2592 | [31; 35) 'self': &Self | 2556 | [31; 35) 'self': &Self |
2593 | [110; 114) 'self': &Self | 2557 | [110; 114) 'self': &Self |
2594 | [170; 228) '{ ...i128 }': () | 2558 | [170; 228) '{ ...i128 }': () |
@@ -2636,7 +2600,6 @@ mod bar_test { | |||
2636 | } | 2600 | } |
2637 | "#), | 2601 | "#), |
2638 | @r###" | 2602 | @r###" |
2639 | |||
2640 | [63; 67) 'self': &Self | 2603 | [63; 67) 'self': &Self |
2641 | [169; 173) 'self': &Self | 2604 | [169; 173) 'self': &Self |
2642 | [300; 337) '{ ... }': () | 2605 | [300; 337) '{ ... }': () |
@@ -2664,7 +2627,6 @@ fn test() { | |||
2664 | } | 2627 | } |
2665 | "#), | 2628 | "#), |
2666 | @r###" | 2629 | @r###" |
2667 | |||
2668 | [33; 37) 'self': &Self | 2630 | [33; 37) 'self': &Self |
2669 | [92; 111) '{ ...d(); }': () | 2631 | [92; 111) '{ ...d(); }': () |
2670 | [98; 99) 'S': S | 2632 | [98; 99) 'S': S |
@@ -2694,7 +2656,6 @@ fn test() { | |||
2694 | } | 2656 | } |
2695 | "#), | 2657 | "#), |
2696 | @r###" | 2658 | @r###" |
2697 | |||
2698 | [43; 47) 'self': &Self | 2659 | [43; 47) 'self': &Self |
2699 | [82; 86) 'self': &Self | 2660 | [82; 86) 'self': &Self |
2700 | [210; 361) '{ ..., i8 }': () | 2661 | [210; 361) '{ ..., i8 }': () |
@@ -2725,7 +2686,6 @@ fn test() { | |||
2725 | } | 2686 | } |
2726 | "#), | 2687 | "#), |
2727 | @r###" | 2688 | @r###" |
2728 | |||
2729 | [33; 37) 'self': &Self | 2689 | [33; 37) 'self': &Self |
2730 | [102; 127) '{ ...d(); }': () | 2690 | [102; 127) '{ ...d(); }': () |
2731 | [108; 109) 'S': S<u32>(T) -> S<T> | 2691 | [108; 109) 'S': S<u32>(T) -> S<T> |
@@ -3130,7 +3090,6 @@ fn test<T: Iterable<Item=u32>>() { | |||
3130 | } | 3090 | } |
3131 | "#), | 3091 | "#), |
3132 | @r###" | 3092 | @r###" |
3133 | |||
3134 | [67; 100) '{ ...own; }': () | 3093 | [67; 100) '{ ...own; }': () |
3135 | [77; 78) 'y': {unknown} | 3094 | [77; 78) 'y': {unknown} |
3136 | [90; 97) 'unknown': {unknown} | 3095 | [90; 97) 'unknown': {unknown} |
@@ -3146,7 +3105,6 @@ const A: u32 = 1 + 1; | |||
3146 | static B: u64 = { let x = 1; x }; | 3105 | static B: u64 = { let x = 1; x }; |
3147 | "#), | 3106 | "#), |
3148 | @r###" | 3107 | @r###" |
3149 | |||
3150 | [16; 17) '1': u32 | 3108 | [16; 17) '1': u32 |
3151 | [16; 21) '1 + 1': u32 | 3109 | [16; 21) '1 + 1': u32 |
3152 | [20; 21) '1': u32 | 3110 | [20; 21) '1': u32 |
@@ -3170,7 +3128,6 @@ fn test() -> u64 { | |||
3170 | } | 3128 | } |
3171 | "#), | 3129 | "#), |
3172 | @r###" | 3130 | @r###" |
3173 | |||
3174 | [38; 87) '{ ... a.1 }': u64 | 3131 | [38; 87) '{ ... a.1 }': u64 |
3175 | [48; 49) 'a': S | 3132 | [48; 49) 'a': S |
3176 | [52; 53) 'S': S(i32, u64) -> S | 3133 | [52; 53) 'S': S(i32, u64) -> S |
@@ -3225,7 +3182,6 @@ fn indexing_arrays() { | |||
3225 | assert_snapshot!( | 3182 | assert_snapshot!( |
3226 | infer("fn main() { &mut [9][2]; }"), | 3183 | infer("fn main() { &mut [9][2]; }"), |
3227 | @r###" | 3184 | @r###" |
3228 | |||
3229 | [10; 26) '{ &mut...[2]; }': () | 3185 | [10; 26) '{ &mut...[2]; }': () |
3230 | [12; 23) '&mut [9][2]': &mut {unknown} | 3186 | [12; 23) '&mut [9][2]': &mut {unknown} |
3231 | [17; 20) '[9]': [i32;_] | 3187 | [17; 20) '[9]': [i32;_] |
@@ -4822,9 +4778,9 @@ fn main() { | |||
4822 | } | 4778 | } |
4823 | "#), | 4779 | "#), |
4824 | @r###" | 4780 | @r###" |
4825 | ![0; 1) '6': i32 | 4781 | ![0; 1) '6': i32 |
4826 | [64; 88) '{ ...!(); }': () | 4782 | [64; 88) '{ ...!(); }': () |
4827 | [74; 75) 'x': i32 | 4783 | [74; 75) 'x': i32 |
4828 | "### | 4784 | "### |
4829 | ); | 4785 | ); |
4830 | } | 4786 | } |
diff --git a/crates/ra_hir/src/ty/traits/chalk.rs b/crates/ra_hir/src/ty/traits/chalk.rs index 75351c17d..68304b950 100644 --- a/crates/ra_hir/src/ty/traits/chalk.rs +++ b/crates/ra_hir/src/ty/traits/chalk.rs | |||
@@ -191,11 +191,11 @@ impl ToChalk for Impl { | |||
191 | type Chalk = chalk_ir::ImplId; | 191 | type Chalk = chalk_ir::ImplId; |
192 | 192 | ||
193 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::ImplId { | 193 | fn to_chalk(self, db: &impl HirDatabase) -> chalk_ir::ImplId { |
194 | db.intern_impl(self).into() | 194 | db.intern_chalk_impl(self).into() |
195 | } | 195 | } |
196 | 196 | ||
197 | fn from_chalk(db: &impl HirDatabase, impl_id: chalk_ir::ImplId) -> Impl { | 197 | fn from_chalk(db: &impl HirDatabase, impl_id: chalk_ir::ImplId) -> Impl { |
198 | db.lookup_intern_impl(impl_id.into()) | 198 | db.lookup_intern_chalk_impl(impl_id.into()) |
199 | } | 199 | } |
200 | } | 200 | } |
201 | 201 | ||
@@ -630,7 +630,7 @@ fn impl_block_datum( | |||
630 | .target_trait_ref(db) | 630 | .target_trait_ref(db) |
631 | .expect("FIXME handle unresolved impl block trait ref") | 631 | .expect("FIXME handle unresolved impl block trait ref") |
632 | .subst(&bound_vars); | 632 | .subst(&bound_vars); |
633 | let impl_type = if impl_block.module().krate() == krate { | 633 | let impl_type = if impl_block.krate(db) == krate { |
634 | chalk_rust_ir::ImplType::Local | 634 | chalk_rust_ir::ImplType::Local |
635 | } else { | 635 | } else { |
636 | chalk_rust_ir::ImplType::External | 636 | chalk_rust_ir::ImplType::External |