diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_assists/src/merge_match_arms.rs | 2 | ||||
-rw-r--r-- | crates/ra_cli/src/main.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/adt.rs | 11 | ||||
-rw-r--r-- | crates/ra_hir/src/code_model.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/from_source.rs | 8 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/collector.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/nameres/raw.rs | 5 | ||||
-rw-r--r-- | crates/ra_hir/src/source_binder.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/infer.rs | 4 | ||||
-rw-r--r-- | crates/ra_hir/src/ty/method_resolution.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/completion_context.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/presentation.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/diagnostics.rs | 2 | ||||
-rw-r--r-- | crates/ra_ide_api/src/display/navigation_target.rs | 4 |
15 files changed, 22 insertions, 30 deletions
diff --git a/crates/ra_assists/src/merge_match_arms.rs b/crates/ra_assists/src/merge_match_arms.rs index 225a48d3a..3b6a99895 100644 --- a/crates/ra_assists/src/merge_match_arms.rs +++ b/crates/ra_assists/src/merge_match_arms.rs | |||
@@ -8,7 +8,7 @@ pub(crate) fn merge_match_arms(mut ctx: AssistCtx<impl HirDatabase>) -> Option<A | |||
8 | // We check if the following match arm matches this one. We could, but don't, | 8 | // We check if the following match arm matches this one. We could, but don't, |
9 | // compare to the previous match arm as well. | 9 | // compare to the previous match arm as well. |
10 | let next = current_arm.syntax().next_sibling(); | 10 | let next = current_arm.syntax().next_sibling(); |
11 | let next_arm = MatchArm::cast(next?.clone())?; | 11 | let next_arm = MatchArm::cast(next?)?; |
12 | 12 | ||
13 | // Don't try to handle arms with guards for now - can add support for this later | 13 | // Don't try to handle arms with guards for now - can add support for this later |
14 | if current_arm.guard().is_some() || next_arm.guard().is_some() { | 14 | if current_arm.guard().is_some() || next_arm.guard().is_some() { |
diff --git a/crates/ra_cli/src/main.rs b/crates/ra_cli/src/main.rs index 7aacf515d..8b91ba3e9 100644 --- a/crates/ra_cli/src/main.rs +++ b/crates/ra_cli/src/main.rs | |||
@@ -93,7 +93,7 @@ fn main() -> Result<()> { | |||
93 | (true, true) => Err("Invalid flags: -q conflicts with -v")?, | 93 | (true, true) => Err("Invalid flags: -q conflicts with -v")?, |
94 | }; | 94 | }; |
95 | let memory_usage = matches.contains("--memory-usage"); | 95 | let memory_usage = matches.contains("--memory-usage"); |
96 | let only = matches.value_from_str(["-o", "--only"])?.map(|v: String| v.to_owned()); | 96 | let only: Option<String> = matches.value_from_str(["-o", "--only"])?; |
97 | let path = { | 97 | let path = { |
98 | let mut trailing = matches.free()?; | 98 | let mut trailing = matches.free()?; |
99 | if trailing.len() != 1 { | 99 | if trailing.len() != 1 { |
diff --git a/crates/ra_hir/src/adt.rs b/crates/ra_hir/src/adt.rs index 56f2b7aa3..fbb4ff4d8 100644 --- a/crates/ra_hir/src/adt.rs +++ b/crates/ra_hir/src/adt.rs | |||
@@ -56,8 +56,7 @@ impl EnumVariant { | |||
56 | .zip(db.enum_data(self.parent).variants.iter()) | 56 | .zip(db.enum_data(self.parent).variants.iter()) |
57 | .find(|(_syntax, (id, _))| *id == self.id) | 57 | .find(|(_syntax, (id, _))| *id == self.id) |
58 | .unwrap() | 58 | .unwrap() |
59 | .0 | 59 | .0; |
60 | .to_owned(); | ||
61 | Source { file_id: src.file_id, ast } | 60 | Source { file_id: src.file_id, ast } |
62 | } | 61 | } |
63 | pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { | 62 | pub(crate) fn variant_data(self, db: &impl DefDatabase) -> Arc<VariantData> { |
@@ -203,12 +202,8 @@ impl StructField { | |||
203 | }; | 202 | }; |
204 | 203 | ||
205 | let field_sources = match struct_kind { | 204 | let field_sources = match struct_kind { |
206 | ast::StructKind::Tuple(fl) => { | 205 | ast::StructKind::Tuple(fl) => fl.fields().map(|it| FieldSource::Pos(it)).collect(), |
207 | fl.fields().map(|it| FieldSource::Pos(it.to_owned())).collect() | 206 | ast::StructKind::Named(fl) => fl.fields().map(|it| FieldSource::Named(it)).collect(), |
208 | } | ||
209 | ast::StructKind::Named(fl) => { | ||
210 | fl.fields().map(|it| FieldSource::Named(it.to_owned())).collect() | ||
211 | } | ||
212 | ast::StructKind::Unit => Vec::new(), | 207 | ast::StructKind::Unit => Vec::new(), |
213 | }; | 208 | }; |
214 | let ast = field_sources | 209 | let ast = field_sources |
diff --git a/crates/ra_hir/src/code_model.rs b/crates/ra_hir/src/code_model.rs index 99c247a0b..9fecba63d 100644 --- a/crates/ra_hir/src/code_model.rs +++ b/crates/ra_hir/src/code_model.rs | |||
@@ -161,7 +161,7 @@ impl ModuleSource { | |||
161 | ) -> ModuleSource { | 161 | ) -> ModuleSource { |
162 | match (file_id, decl_id) { | 162 | match (file_id, decl_id) { |
163 | (Some(file_id), _) => { | 163 | (Some(file_id), _) => { |
164 | let source_file = db.parse(file_id).tree().to_owned(); | 164 | let source_file = db.parse(file_id).tree(); |
165 | ModuleSource::SourceFile(source_file) | 165 | ModuleSource::SourceFile(source_file) |
166 | } | 166 | } |
167 | (None, Some(item_id)) => { | 167 | (None, Some(item_id)) => { |
diff --git a/crates/ra_hir/src/from_source.rs b/crates/ra_hir/src/from_source.rs index f3194595f..7b6d9b240 100644 --- a/crates/ra_hir/src/from_source.rs +++ b/crates/ra_hir/src/from_source.rs | |||
@@ -137,7 +137,7 @@ impl ModuleSource { | |||
137 | match &find_node_at_offset::<ast::Module>(parse.tree().syntax(), position.offset) { | 137 | match &find_node_at_offset::<ast::Module>(parse.tree().syntax(), position.offset) { |
138 | Some(m) if !m.has_semi() => ModuleSource::Module(m.clone()), | 138 | Some(m) if !m.has_semi() => ModuleSource::Module(m.clone()), |
139 | _ => { | 139 | _ => { |
140 | let source_file = parse.tree().to_owned(); | 140 | let source_file = parse.tree(); |
141 | ModuleSource::SourceFile(source_file) | 141 | ModuleSource::SourceFile(source_file) |
142 | } | 142 | } |
143 | } | 143 | } |
@@ -149,15 +149,15 @@ impl ModuleSource { | |||
149 | child: &SyntaxNode, | 149 | child: &SyntaxNode, |
150 | ) -> ModuleSource { | 150 | ) -> ModuleSource { |
151 | if let Some(m) = child.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) { | 151 | if let Some(m) = child.ancestors().filter_map(ast::Module::cast).find(|it| !it.has_semi()) { |
152 | ModuleSource::Module(m.clone()) | 152 | ModuleSource::Module(m) |
153 | } else { | 153 | } else { |
154 | let source_file = db.parse(file_id).tree().to_owned(); | 154 | let source_file = db.parse(file_id).tree(); |
155 | ModuleSource::SourceFile(source_file) | 155 | ModuleSource::SourceFile(source_file) |
156 | } | 156 | } |
157 | } | 157 | } |
158 | 158 | ||
159 | pub fn from_file_id(db: &(impl DefDatabase + AstDatabase), file_id: FileId) -> ModuleSource { | 159 | pub fn from_file_id(db: &(impl DefDatabase + AstDatabase), file_id: FileId) -> ModuleSource { |
160 | let source_file = db.parse(file_id).tree().to_owned(); | 160 | let source_file = db.parse(file_id).tree(); |
161 | ModuleSource::SourceFile(source_file) | 161 | ModuleSource::SourceFile(source_file) |
162 | } | 162 | } |
163 | } | 163 | } |
diff --git a/crates/ra_hir/src/nameres/collector.rs b/crates/ra_hir/src/nameres/collector.rs index 6b253ac40..ef7dc6ebe 100644 --- a/crates/ra_hir/src/nameres/collector.rs +++ b/crates/ra_hir/src/nameres/collector.rs | |||
@@ -166,7 +166,7 @@ where | |||
166 | // In Rust, `#[macro_export]` macros are unconditionally visible at the | 166 | // In Rust, `#[macro_export]` macros are unconditionally visible at the |
167 | // crate root, even if the parent modules is **not** visible. | 167 | // crate root, even if the parent modules is **not** visible. |
168 | if export { | 168 | if export { |
169 | self.update(self.def_map.root, None, &[(name.clone(), Resolution::from_macro(macro_))]); | 169 | self.update(self.def_map.root, None, &[(name, Resolution::from_macro(macro_))]); |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
diff --git a/crates/ra_hir/src/nameres/raw.rs b/crates/ra_hir/src/nameres/raw.rs index 8bf883ac2..29aaddbf1 100644 --- a/crates/ra_hir/src/nameres/raw.rs +++ b/crates/ra_hir/src/nameres/raw.rs | |||
@@ -36,10 +36,7 @@ type ImportSource = Either<ast::UseTree, ast::ExternCrateItem>; | |||
36 | 36 | ||
37 | impl ImportSourcePtr { | 37 | impl ImportSourcePtr { |
38 | fn to_node(self, file: &SourceFile) -> ImportSource { | 38 | fn to_node(self, file: &SourceFile) -> ImportSource { |
39 | self.map( | 39 | self.map(|ptr| ptr.to_node(file.syntax()), |ptr| ptr.to_node(file.syntax())) |
40 | |ptr| ptr.to_node(file.syntax()).to_owned(), | ||
41 | |ptr| ptr.to_node(file.syntax()).to_owned(), | ||
42 | ) | ||
43 | } | 40 | } |
44 | } | 41 | } |
45 | 42 | ||
diff --git a/crates/ra_hir/src/source_binder.rs b/crates/ra_hir/src/source_binder.rs index 296acc364..bd4be8430 100644 --- a/crates/ra_hir/src/source_binder.rs +++ b/crates/ra_hir/src/source_binder.rs | |||
@@ -73,7 +73,7 @@ fn def_with_body_from_child_node( | |||
73 | if let Some(def) = ast::ConstDef::cast(node.clone()) { | 73 | if let Some(def) = ast::ConstDef::cast(node.clone()) { |
74 | return Some(Const { id: ctx.to_def(&def) }.into()); | 74 | return Some(Const { id: ctx.to_def(&def) }.into()); |
75 | } | 75 | } |
76 | if let Some(def) = ast::StaticDef::cast(node.clone()) { | 76 | if let Some(def) = ast::StaticDef::cast(node) { |
77 | return Some(Static { id: ctx.to_def(&def) }.into()); | 77 | return Some(Static { id: ctx.to_def(&def) }.into()); |
78 | } | 78 | } |
79 | None | 79 | None |
diff --git a/crates/ra_hir/src/ty.rs b/crates/ra_hir/src/ty.rs index e6ecbe1ea..fae9c1e22 100644 --- a/crates/ra_hir/src/ty.rs +++ b/crates/ra_hir/src/ty.rs | |||
@@ -223,7 +223,7 @@ impl Substs { | |||
223 | } | 223 | } |
224 | 224 | ||
225 | pub fn prefix(&self, n: usize) -> Substs { | 225 | pub fn prefix(&self, n: usize) -> Substs { |
226 | Substs(self.0.iter().cloned().take(n).collect::<Vec<_>>().into()) | 226 | Substs(self.0[..std::cmp::min(self.0.len(), n)].into()) |
227 | } | 227 | } |
228 | 228 | ||
229 | pub fn walk(&self, f: &mut impl FnMut(&Ty)) { | 229 | pub fn walk(&self, f: &mut impl FnMut(&Ty)) { |
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs index 378d2f829..76b4b6faa 100644 --- a/crates/ra_hir/src/ty/infer.rs +++ b/crates/ra_hir/src/ty/infer.rs | |||
@@ -436,7 +436,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
436 | 436 | ||
437 | fn normalize_projection_ty(&mut self, proj_ty: ProjectionTy) -> Ty { | 437 | fn normalize_projection_ty(&mut self, proj_ty: ProjectionTy) -> Ty { |
438 | let var = self.new_type_var(); | 438 | let var = self.new_type_var(); |
439 | let predicate = ProjectionPredicate { projection_ty: proj_ty.clone(), ty: var.clone() }; | 439 | let predicate = ProjectionPredicate { projection_ty: proj_ty, ty: var.clone() }; |
440 | let obligation = Obligation::Projection(predicate); | 440 | let obligation = Obligation::Projection(predicate); |
441 | self.obligations.push(obligation); | 441 | self.obligations.push(obligation); |
442 | var | 442 | var |
@@ -953,7 +953,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> { | |||
953 | arm_tys.push(self.infer_expr_inner(arm.expr, &expected)); | 953 | arm_tys.push(self.infer_expr_inner(arm.expr, &expected)); |
954 | } | 954 | } |
955 | 955 | ||
956 | let lub_ty = calculate_least_upper_bound(expected.ty.clone(), &arm_tys); | 956 | let lub_ty = calculate_least_upper_bound(expected.ty, &arm_tys); |
957 | 957 | ||
958 | for arm_ty in &arm_tys { | 958 | for arm_ty in &arm_tys { |
959 | self.coerce(arm_ty, &lub_ty); | 959 | self.coerce(arm_ty, &lub_ty); |
diff --git a/crates/ra_hir/src/ty/method_resolution.rs b/crates/ra_hir/src/ty/method_resolution.rs index 7ec96debb..4b71b376f 100644 --- a/crates/ra_hir/src/ty/method_resolution.rs +++ b/crates/ra_hir/src/ty/method_resolution.rs | |||
@@ -293,7 +293,7 @@ pub(crate) fn implements_trait( | |||
293 | return true; | 293 | return true; |
294 | } | 294 | } |
295 | let env = lower::trait_env(db, resolver); | 295 | let env = lower::trait_env(db, resolver); |
296 | let goal = generic_implements_goal(db, env.clone(), trait_, ty.clone()); | 296 | let goal = generic_implements_goal(db, env, trait_, ty.clone()); |
297 | let solution = db.trait_solve(krate, goal); | 297 | let solution = db.trait_solve(krate, goal); |
298 | 298 | ||
299 | solution.is_some() | 299 | solution.is_some() |
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index 59bd3689b..57542152f 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs | |||
@@ -94,7 +94,7 @@ impl<'a> CompletionContext<'a> { | |||
94 | // actual completion. | 94 | // actual completion. |
95 | let file = { | 95 | let file = { |
96 | let edit = AtomTextEdit::insert(offset, "intellijRulezz".to_string()); | 96 | let edit = AtomTextEdit::insert(offset, "intellijRulezz".to_string()); |
97 | original_parse.reparse(&edit).tree().to_owned() | 97 | original_parse.reparse(&edit).tree() |
98 | }; | 98 | }; |
99 | 99 | ||
100 | // First, let's try to complete a reference to some declaration. | 100 | // First, let's try to complete a reference to some declaration. |
diff --git a/crates/ra_ide_api/src/completion/presentation.rs b/crates/ra_ide_api/src/completion/presentation.rs index ad414412b..b8aa433c1 100644 --- a/crates/ra_ide_api/src/completion/presentation.rs +++ b/crates/ra_ide_api/src/completion/presentation.rs | |||
@@ -76,7 +76,7 @@ impl Completions { | |||
76 | None, | 76 | None, |
77 | ), | 77 | ), |
78 | ScopeDef::MacroDef(mac) => { | 78 | ScopeDef::MacroDef(mac) => { |
79 | self.add_macro(ctx, Some(local_name.clone()), *mac); | 79 | self.add_macro(ctx, Some(local_name), *mac); |
80 | return; | 80 | return; |
81 | } | 81 | } |
82 | ScopeDef::Unknown => { | 82 | ScopeDef::Unknown => { |
diff --git a/crates/ra_ide_api/src/diagnostics.rs b/crates/ra_ide_api/src/diagnostics.rs index 1ae152e5b..93e1e7c2d 100644 --- a/crates/ra_ide_api/src/diagnostics.rs +++ b/crates/ra_ide_api/src/diagnostics.rs | |||
@@ -86,7 +86,7 @@ pub(crate) fn diagnostics(db: &RootDatabase, file_id: FileId) -> Vec<Diagnostic> | |||
86 | fix: Some(fix), | 86 | fix: Some(fix), |
87 | }) | 87 | }) |
88 | }); | 88 | }); |
89 | let source_file = db.parse(file_id).tree().to_owned(); | 89 | let source_file = db.parse(file_id).tree(); |
90 | let src = | 90 | let src = |
91 | hir::Source { file_id: file_id.into(), ast: hir::ModuleSource::SourceFile(source_file) }; | 91 | hir::Source { file_id: file_id.into(), ast: hir::ModuleSource::SourceFile(source_file) }; |
92 | if let Some(m) = hir::Module::from_definition(db, src) { | 92 | if let Some(m) = hir::Module::from_definition(db, src) { |
diff --git a/crates/ra_ide_api/src/display/navigation_target.rs b/crates/ra_ide_api/src/display/navigation_target.rs index 11f73ccfd..d3e774bd0 100644 --- a/crates/ra_ide_api/src/display/navigation_target.rs +++ b/crates/ra_ide_api/src/display/navigation_target.rs | |||
@@ -304,7 +304,7 @@ impl NavigationTarget { | |||
304 | 304 | ||
305 | pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> { | 305 | pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> { |
306 | let parse = db.parse(symbol.file_id); | 306 | let parse = db.parse(symbol.file_id); |
307 | let node = symbol.ptr.to_node(parse.tree().syntax()).to_owned(); | 307 | let node = symbol.ptr.to_node(parse.tree().syntax()); |
308 | 308 | ||
309 | visitor() | 309 | visitor() |
310 | .visit(|it: ast::FnDef| it.doc_comment_text()) | 310 | .visit(|it: ast::FnDef| it.doc_comment_text()) |
@@ -326,7 +326,7 @@ pub(crate) fn docs_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option | |||
326 | /// e.g. `struct Name`, `enum Name`, `fn Name` | 326 | /// e.g. `struct Name`, `enum Name`, `fn Name` |
327 | pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> { | 327 | pub(crate) fn description_from_symbol(db: &RootDatabase, symbol: &FileSymbol) -> Option<String> { |
328 | let parse = db.parse(symbol.file_id); | 328 | let parse = db.parse(symbol.file_id); |
329 | let node = symbol.ptr.to_node(parse.tree().syntax()).to_owned(); | 329 | let node = symbol.ptr.to_node(parse.tree().syntax()); |
330 | 330 | ||
331 | visitor() | 331 | visitor() |
332 | .visit(|node: ast::FnDef| node.short_label()) | 332 | .visit(|node: ast::FnDef| node.short_label()) |