diff options
Diffstat (limited to 'crates/ra_hir')
-rw-r--r-- | crates/ra_hir/src/expr.rs | 6 | ||||
-rw-r--r-- | crates/ra_hir/src/expr/scope.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/impl_block.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/lib.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir/src/mock.rs | 12 | ||||
-rw-r--r-- | crates/ra_hir/src/resolve.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 2 |
8 files changed, 19 insertions, 20 deletions
diff --git a/crates/ra_hir/src/expr.rs b/crates/ra_hir/src/expr.rs index f9f702ae2..6826e966b 100644 --- a/crates/ra_hir/src/expr.rs +++ b/crates/ra_hir/src/expr.rs | |||
@@ -805,7 +805,7 @@ impl ExprCollector { | |||
805 | let lit = match child.flavor() { | 805 | let lit = match child.flavor() { |
806 | LiteralFlavor::IntNumber { suffix } => { | 806 | LiteralFlavor::IntNumber { suffix } => { |
807 | let known_name = suffix | 807 | let known_name = suffix |
808 | .map(|s| Name::new(s)) | 808 | .map(Name::new) |
809 | .and_then(|name| UncertainIntTy::from_name(&name)); | 809 | .and_then(|name| UncertainIntTy::from_name(&name)); |
810 | 810 | ||
811 | Literal::Int( | 811 | Literal::Int( |
@@ -815,7 +815,7 @@ impl ExprCollector { | |||
815 | } | 815 | } |
816 | LiteralFlavor::FloatNumber { suffix } => { | 816 | LiteralFlavor::FloatNumber { suffix } => { |
817 | let known_name = suffix | 817 | let known_name = suffix |
818 | .map(|s| Name::new(s)) | 818 | .map(Name::new) |
819 | .and_then(|name| UncertainFloatTy::from_name(&name)); | 819 | .and_then(|name| UncertainFloatTy::from_name(&name)); |
820 | 820 | ||
821 | Literal::Float( | 821 | Literal::Float( |
@@ -910,7 +910,7 @@ impl ExprCollector { | |||
910 | } | 910 | } |
911 | ast::PatKind::PathPat(p) => { | 911 | ast::PatKind::PathPat(p) => { |
912 | let path = p.path().and_then(Path::from_ast); | 912 | let path = p.path().and_then(Path::from_ast); |
913 | path.map(|path| Pat::Path(path)).unwrap_or(Pat::Missing) | 913 | path.map(Pat::Path).unwrap_or(Pat::Missing) |
914 | } | 914 | } |
915 | ast::PatKind::TuplePat(p) => { | 915 | ast::PatKind::TuplePat(p) => { |
916 | let args = p.args().map(|p| self.collect_pat(p)).collect(); | 916 | let args = p.args().map(|p| self.collect_pat(p)).collect(); |
diff --git a/crates/ra_hir/src/expr/scope.rs b/crates/ra_hir/src/expr/scope.rs index 9202e3671..368994bf7 100644 --- a/crates/ra_hir/src/expr/scope.rs +++ b/crates/ra_hir/src/expr/scope.rs | |||
@@ -105,7 +105,7 @@ impl ExprScopes { | |||
105 | fn add_params_bindings(&mut self, scope: ScopeId, params: &[PatId]) { | 105 | fn add_params_bindings(&mut self, scope: ScopeId, params: &[PatId]) { |
106 | let body = Arc::clone(&self.body); | 106 | let body = Arc::clone(&self.body); |
107 | params | 107 | params |
108 | .into_iter() | 108 | .iter() |
109 | .for_each(|pat| self.add_bindings(&body, scope, *pat)); | 109 | .for_each(|pat| self.add_bindings(&body, scope, *pat)); |
110 | } | 110 | } |
111 | 111 | ||
@@ -147,7 +147,7 @@ impl ScopesWithSyntaxMapping { | |||
147 | }) | 147 | }) |
148 | } | 148 | } |
149 | 149 | ||
150 | pub fn scope_for_offset<'a>(&'a self, offset: TextUnit) -> Option<ScopeId> { | 150 | pub fn scope_for_offset(&self, offset: TextUnit) -> Option<ScopeId> { |
151 | self.scopes | 151 | self.scopes |
152 | .scope_for | 152 | .scope_for |
153 | .iter() | 153 | .iter() |
diff --git a/crates/ra_hir/src/impl_block.rs b/crates/ra_hir/src/impl_block.rs index 738c58fbe..094dbedb3 100644 --- a/crates/ra_hir/src/impl_block.rs +++ b/crates/ra_hir/src/impl_block.rs | |||
@@ -72,7 +72,7 @@ impl ImplBlock { | |||
72 | } | 72 | } |
73 | 73 | ||
74 | pub fn module(&self) -> Module { | 74 | pub fn module(&self) -> Module { |
75 | self.module_impl_blocks.module.clone() | 75 | self.module_impl_blocks.module |
76 | } | 76 | } |
77 | 77 | ||
78 | pub fn target_trait_ref(&self) -> Option<&TypeRef> { | 78 | pub fn target_trait_ref(&self) -> Option<&TypeRef> { |
diff --git a/crates/ra_hir/src/lib.rs b/crates/ra_hir/src/lib.rs index 54da55598..a9cd955cf 100644 --- a/crates/ra_hir/src/lib.rs +++ b/crates/ra_hir/src/lib.rs | |||
@@ -18,8 +18,7 @@ macro_rules! impl_froms { | |||
18 | } | 18 | } |
19 | 19 | ||
20 | pub mod db; | 20 | pub mod db; |
21 | #[cfg(test)] | 21 | pub mod mock; |
22 | mod mock; | ||
23 | mod query_definitions; | 22 | mod query_definitions; |
24 | mod path; | 23 | mod path; |
25 | pub mod source_binder; | 24 | pub mod source_binder; |
diff --git a/crates/ra_hir/src/mock.rs b/crates/ra_hir/src/mock.rs index 00a07d1a1..87095fb21 100644 --- a/crates/ra_hir/src/mock.rs +++ b/crates/ra_hir/src/mock.rs | |||
@@ -17,7 +17,7 @@ pub const WORKSPACE: SourceRootId = SourceRootId(0); | |||
17 | db::PersistentHirDatabaseStorage | 17 | db::PersistentHirDatabaseStorage |
18 | )] | 18 | )] |
19 | #[derive(Debug)] | 19 | #[derive(Debug)] |
20 | pub(crate) struct MockDatabase { | 20 | pub struct MockDatabase { |
21 | events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>, | 21 | events: Mutex<Option<Vec<salsa::Event<MockDatabase>>>>, |
22 | runtime: salsa::Runtime<MockDatabase>, | 22 | runtime: salsa::Runtime<MockDatabase>, |
23 | interner: Arc<HirInterner>, | 23 | interner: Arc<HirInterner>, |
@@ -27,13 +27,13 @@ pub(crate) struct MockDatabase { | |||
27 | impl panic::RefUnwindSafe for MockDatabase {} | 27 | impl panic::RefUnwindSafe for MockDatabase {} |
28 | 28 | ||
29 | impl MockDatabase { | 29 | impl MockDatabase { |
30 | pub(crate) fn with_files(fixture: &str) -> (MockDatabase, SourceRoot) { | 30 | pub fn with_files(fixture: &str) -> (MockDatabase, SourceRoot) { |
31 | let (db, source_root, position) = MockDatabase::from_fixture(fixture); | 31 | let (db, source_root, position) = MockDatabase::from_fixture(fixture); |
32 | assert!(position.is_none()); | 32 | assert!(position.is_none()); |
33 | (db, source_root) | 33 | (db, source_root) |
34 | } | 34 | } |
35 | 35 | ||
36 | pub(crate) fn with_single_file(text: &str) -> (MockDatabase, SourceRoot, FileId) { | 36 | pub fn with_single_file(text: &str) -> (MockDatabase, SourceRoot, FileId) { |
37 | let mut db = MockDatabase::default(); | 37 | let mut db = MockDatabase::default(); |
38 | let mut source_root = SourceRoot::default(); | 38 | let mut source_root = SourceRoot::default(); |
39 | let file_id = db.add_file(WORKSPACE, &mut source_root, "/main.rs", text); | 39 | let file_id = db.add_file(WORKSPACE, &mut source_root, "/main.rs", text); |
@@ -41,7 +41,7 @@ impl MockDatabase { | |||
41 | (db, source_root, file_id) | 41 | (db, source_root, file_id) |
42 | } | 42 | } |
43 | 43 | ||
44 | pub(crate) fn with_position(fixture: &str) -> (MockDatabase, FilePosition) { | 44 | pub fn with_position(fixture: &str) -> (MockDatabase, FilePosition) { |
45 | let (db, _, position) = MockDatabase::from_fixture(fixture); | 45 | let (db, _, position) = MockDatabase::from_fixture(fixture); |
46 | let position = position.expect("expected a marker ( <|> )"); | 46 | let position = position.expect("expected a marker ( <|> )"); |
47 | (db, position) | 47 | (db, position) |
@@ -166,13 +166,13 @@ impl AsRef<HirInterner> for MockDatabase { | |||
166 | } | 166 | } |
167 | 167 | ||
168 | impl MockDatabase { | 168 | impl MockDatabase { |
169 | pub(crate) fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<MockDatabase>> { | 169 | pub fn log(&self, f: impl FnOnce()) -> Vec<salsa::Event<MockDatabase>> { |
170 | *self.events.lock() = Some(Vec::new()); | 170 | *self.events.lock() = Some(Vec::new()); |
171 | f(); | 171 | f(); |
172 | self.events.lock().take().unwrap() | 172 | self.events.lock().take().unwrap() |
173 | } | 173 | } |
174 | 174 | ||
175 | pub(crate) fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { | 175 | pub fn log_executed(&self, f: impl FnOnce()) -> Vec<String> { |
176 | let events = self.log(f); | 176 | let events = self.log(f); |
177 | events | 177 | events |
178 | .into_iter() | 178 | .into_iter() |
diff --git a/crates/ra_hir/src/resolve.rs b/crates/ra_hir/src/resolve.rs index 5ca7bacb5..0f60d4742 100644 --- a/crates/ra_hir/src/resolve.rs +++ b/crates/ra_hir/src/resolve.rs | |||
@@ -78,7 +78,7 @@ impl Resolver { | |||
78 | _ => return PerNs::none(), | 78 | _ => return PerNs::none(), |
79 | }; | 79 | }; |
80 | let module_res = item_map.resolve_path(db, module, path); | 80 | let module_res = item_map.resolve_path(db, module, path); |
81 | module_res.map(|def| Resolution::Def(def)) | 81 | module_res.map(Resolution::Def) |
82 | } | 82 | } |
83 | } | 83 | } |
84 | 84 | ||
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index cc5afad75..86a7f8b83 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -1225,7 +1225,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1225 | Ty::Tuple(ref tuple_args) => &**tuple_args, | 1225 | Ty::Tuple(ref tuple_args) => &**tuple_args, |
1226 | _ => &[], | 1226 | _ => &[], |
1227 | }; | 1227 | }; |
1228 | let expectations_iter = expectations.into_iter().chain(repeat(&Ty::Unknown)); | 1228 | let expectations_iter = expectations.iter().chain(repeat(&Ty::Unknown)); |
1229 | 1229 | ||
1230 | let inner_tys = args | 1230 | let inner_tys = args |
1231 | .iter() | 1231 | .iter() |
@@ -1398,10 +1398,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1398 | let method_ty = self.insert_type_vars(method_ty); | 1398 | let method_ty = self.insert_type_vars(method_ty); |
1399 | let (expected_receiver_ty, param_tys, ret_ty) = match &method_ty { | 1399 | let (expected_receiver_ty, param_tys, ret_ty) = match &method_ty { |
1400 | Ty::FnPtr(sig) => { | 1400 | Ty::FnPtr(sig) => { |
1401 | if sig.input.len() > 0 { | 1401 | if !sig.input.is_empty() { |
1402 | ( | 1402 | ( |
1403 | sig.input[0].clone(), | 1403 | sig.input[0].clone(), |
1404 | sig.input[1..].iter().cloned().collect(), | 1404 | sig.input[1..].to_vec(), |
1405 | sig.output.clone(), | 1405 | sig.output.clone(), |
1406 | ) | 1406 | ) |
1407 | } else { | 1407 | } else { |
@@ -1411,7 +1411,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
1411 | Ty::FnDef { substs, sig, .. } => { | 1411 | Ty::FnDef { substs, sig, .. } => { |
1412 | let ret_ty = sig.output.clone().subst(&substs); | 1412 | let ret_ty = sig.output.clone().subst(&substs); |
1413 | 1413 | ||
1414 | if sig.input.len() > 0 { | 1414 | if !sig.input.is_empty() { |
1415 | let mut arg_iter = sig.input.iter().map(|ty| ty.clone().subst(&substs)); | 1415 | let mut arg_iter = sig.input.iter().map(|ty| ty.clone().subst(&substs)); |
1416 | let receiver_ty = arg_iter.next().unwrap(); | 1416 | let receiver_ty = arg_iter.next().unwrap(); |
1417 | (receiver_ty, arg_iter.collect(), ret_ty) | 1417 | (receiver_ty, arg_iter.collect(), ret_ty) |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 2282286b0..a7d4517ee 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -113,7 +113,7 @@ impl CrateImplBlocks { | |||
113 | krate: Crate, | 113 | krate: Crate, |
114 | ) -> Arc<CrateImplBlocks> { | 114 | ) -> Arc<CrateImplBlocks> { |
115 | let mut crate_impl_blocks = CrateImplBlocks { | 115 | let mut crate_impl_blocks = CrateImplBlocks { |
116 | krate: krate.clone(), | 116 | krate, |
117 | impls: FxHashMap::default(), | 117 | impls: FxHashMap::default(), |
118 | impls_by_trait: FxHashMap::default(), | 118 | impls_by_trait: FxHashMap::default(), |
119 | }; | 119 | }; |