aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ty')
-rw-r--r--crates/ra_hir/src/ty/method_resolution.rs30
-rw-r--r--crates/ra_hir/src/ty/tests.rs9
2 files changed, 12 insertions, 27 deletions
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs
index a7d4517ee..da7587f01 100644
--- a/crates/ra_hir/src/ty/method_resolution.rs
+++ b/crates/ra_hir/src/ty/method_resolution.rs
@@ -46,18 +46,13 @@ impl CrateImplBlocks {
46 ty: &Ty, 46 ty: &Ty,
47 ) -> impl Iterator<Item = (Module, ImplBlock)> + 'a { 47 ) -> impl Iterator<Item = (Module, ImplBlock)> + 'a {
48 let fingerprint = TyFingerprint::for_impl(ty); 48 let fingerprint = TyFingerprint::for_impl(ty);
49 fingerprint 49 fingerprint.and_then(|f| self.impls.get(&f)).into_iter().flat_map(|i| i.iter()).map(
50 .and_then(|f| self.impls.get(&f)) 50 move |(module_id, impl_id)| {
51 .into_iter() 51 let module = Module { krate: self.krate, module_id: *module_id };
52 .flat_map(|i| i.iter())
53 .map(move |(module_id, impl_id)| {
54 let module = Module {
55 krate: self.krate,
56 module_id: *module_id,
57 };
58 let module_impl_blocks = db.impls_in_module(module); 52 let module_impl_blocks = db.impls_in_module(module);
59 (module, ImplBlock::from_id(module_impl_blocks, *impl_id)) 53 (module, ImplBlock::from_id(module_impl_blocks, *impl_id))
60 }) 54 },
55 )
61 } 56 }
62 57
63 pub fn lookup_impl_blocks_for_trait<'a>( 58 pub fn lookup_impl_blocks_for_trait<'a>(
@@ -66,18 +61,13 @@ impl CrateImplBlocks {
66 tr: &Trait, 61 tr: &Trait,
67 ) -> impl Iterator<Item = (Module, ImplBlock)> + 'a { 62 ) -> impl Iterator<Item = (Module, ImplBlock)> + 'a {
68 let id = tr.id; 63 let id = tr.id;
69 self.impls_by_trait 64 self.impls_by_trait.get(&id).into_iter().flat_map(|i| i.iter()).map(
70 .get(&id) 65 move |(module_id, impl_id)| {
71 .into_iter() 66 let module = Module { krate: self.krate, module_id: *module_id };
72 .flat_map(|i| i.iter())
73 .map(move |(module_id, impl_id)| {
74 let module = Module {
75 krate: self.krate,
76 module_id: *module_id,
77 };
78 let module_impl_blocks = db.impls_in_module(module); 67 let module_impl_blocks = db.impls_in_module(module);
79 (module, ImplBlock::from_id(module_impl_blocks, *impl_id)) 68 (module, ImplBlock::from_id(module_impl_blocks, *impl_id))
80 }) 69 },
70 )
81 } 71 }
82 72
83 fn collect_recursive(&mut self, db: &impl HirDatabase, module: &Module) { 73 fn collect_recursive(&mut self, db: &impl HirDatabase, module: &Module) {
diff --git a/crates/ra_hir/src/ty/tests.rs b/crates/ra_hir/src/ty/tests.rs
index 30da8fc23..2621d1b55 100644
--- a/crates/ra_hir/src/ty/tests.rs
+++ b/crates/ra_hir/src/ty/tests.rs
@@ -634,11 +634,7 @@ fn infer(content: &str) -> String {
634 let (db, _, file_id) = MockDatabase::with_single_file(content); 634 let (db, _, file_id) = MockDatabase::with_single_file(content);
635 let source_file = db.parse(file_id); 635 let source_file = db.parse(file_id);
636 let mut acc = String::new(); 636 let mut acc = String::new();
637 for fn_def in source_file 637 for fn_def in source_file.syntax().descendants().filter_map(ast::FnDef::cast) {
638 .syntax()
639 .descendants()
640 .filter_map(ast::FnDef::cast)
641 {
642 let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap(); 638 let func = source_binder::function_from_source(&db, file_id, fn_def).unwrap();
643 let inference_result = func.infer(&db); 639 let inference_result = func.infer(&db);
644 let body_syntax_mapping = func.body_syntax_mapping(&db); 640 let body_syntax_mapping = func.body_syntax_mapping(&db);
@@ -725,8 +721,7 @@ fn typing_whitespace_inside_a_function_should_not_invalidate_types() {
725 " 721 "
726 .to_string(); 722 .to_string();
727 723
728 db.query_mut(ra_db::FileTextQuery) 724 db.query_mut(ra_db::FileTextQuery).set(pos.file_id, Arc::new(new_text));
729 .set(pos.file_id, Arc::new(new_text));
730 725
731 { 726 {
732 let events = db.log_executed(|| { 727 let events = db.log_executed(|| {