diff options
-rw-r--r-- | crates/hir_expand/src/eager.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/coerce.rs | 12 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 11 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/pat.rs | 9 | ||||
-rw-r--r-- | crates/ide_assists/src/handlers/expand_glob_import.rs | 2 | ||||
-rw-r--r-- | crates/project_model/src/build_data.rs | 6 | ||||
-rw-r--r-- | crates/project_model/src/cargo_workspace.rs | 7 |
7 files changed, 22 insertions, 27 deletions
diff --git a/crates/hir_expand/src/eager.rs b/crates/hir_expand/src/eager.rs index e165b9c5f..1464320ba 100644 --- a/crates/hir_expand/src/eager.rs +++ b/crates/hir_expand/src/eager.rs | |||
@@ -197,7 +197,7 @@ fn eager_macro_recur( | |||
197 | macro_resolver: &dyn Fn(ast::Path) -> Option<MacroDefId>, | 197 | macro_resolver: &dyn Fn(ast::Path) -> Option<MacroDefId>, |
198 | mut diagnostic_sink: &mut dyn FnMut(mbe::ExpandError), | 198 | mut diagnostic_sink: &mut dyn FnMut(mbe::ExpandError), |
199 | ) -> Result<SyntaxNode, ErrorEmitted> { | 199 | ) -> Result<SyntaxNode, ErrorEmitted> { |
200 | let original = curr.value.clone().clone_for_update(); | 200 | let original = curr.value.clone_for_update(); |
201 | 201 | ||
202 | let children = original.descendants().filter_map(ast::MacroCall::cast); | 202 | let children = original.descendants().filter_map(ast::MacroCall::cast); |
203 | let mut replacements = Vec::new(); | 203 | let mut replacements = Vec::new(); |
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs index 765a02b1c..03b97e7db 100644 --- a/crates/hir_ty/src/infer/coerce.rs +++ b/crates/hir_ty/src/infer/coerce.rs | |||
@@ -76,17 +76,17 @@ impl<'a> InferenceContext<'a> { | |||
76 | // way around first would mean we make the type variable `!`, instead of | 76 | // way around first would mean we make the type variable `!`, instead of |
77 | // just marking it as possibly diverging. | 77 | // just marking it as possibly diverging. |
78 | if self.coerce(&ty2, &ty1) { | 78 | if self.coerce(&ty2, &ty1) { |
79 | ty1.clone() | 79 | ty1 |
80 | } else if self.coerce(&ty1, &ty2) { | 80 | } else if self.coerce(&ty1, &ty2) { |
81 | ty2.clone() | 81 | ty2 |
82 | } else { | 82 | } else { |
83 | if let Some(id) = id { | 83 | if let Some(id) = id { |
84 | self.result | 84 | self.result |
85 | .type_mismatches | 85 | .type_mismatches |
86 | .insert(id.into(), TypeMismatch { expected: ty1.clone(), actual: ty2.clone() }); | 86 | .insert(id.into(), TypeMismatch { expected: ty1.clone(), actual: ty2 }); |
87 | } | 87 | } |
88 | cov_mark::hit!(coerce_merge_fail_fallback); | 88 | cov_mark::hit!(coerce_merge_fail_fallback); |
89 | ty1.clone() | 89 | ty1 |
90 | } | 90 | } |
91 | } | 91 | } |
92 | 92 | ||
@@ -183,7 +183,7 @@ impl<'a> InferenceContext<'a> { | |||
183 | // details of coercion errors though, so I think it's useful to leave | 183 | // details of coercion errors though, so I think it's useful to leave |
184 | // the structure like it is. | 184 | // the structure like it is. |
185 | 185 | ||
186 | let canonicalized = self.canonicalize(from_ty.clone()); | 186 | let canonicalized = self.canonicalize(from_ty); |
187 | let autoderef = autoderef::autoderef( | 187 | let autoderef = autoderef::autoderef( |
188 | self.db, | 188 | self.db, |
189 | self.resolver.krate(), | 189 | self.resolver.krate(), |
@@ -389,7 +389,7 @@ impl<'a> InferenceContext<'a> { | |||
389 | // The CoerceUnsized trait should have two generic params: Self and T. | 389 | // The CoerceUnsized trait should have two generic params: Self and T. |
390 | return Err(TypeError); | 390 | return Err(TypeError); |
391 | } | 391 | } |
392 | b.push(coerce_from.clone()).push(to_ty.clone()).build() | 392 | b.push(coerce_from).push(to_ty.clone()).build() |
393 | }; | 393 | }; |
394 | 394 | ||
395 | let goal: InEnvironment<DomainGoal> = | 395 | let goal: InEnvironment<DomainGoal> = |
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 79a732106..97507305c 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -44,7 +44,7 @@ impl<'a> InferenceContext<'a> { | |||
44 | if !could_unify { | 44 | if !could_unify { |
45 | self.result.type_mismatches.insert( | 45 | self.result.type_mismatches.insert( |
46 | tgt_expr.into(), | 46 | tgt_expr.into(), |
47 | TypeMismatch { expected: expected_ty.clone(), actual: ty.clone() }, | 47 | TypeMismatch { expected: expected_ty, actual: ty.clone() }, |
48 | ); | 48 | ); |
49 | } | 49 | } |
50 | } | 50 | } |
@@ -57,15 +57,14 @@ impl<'a> InferenceContext<'a> { | |||
57 | let ty = self.infer_expr_inner(expr, &expected); | 57 | let ty = self.infer_expr_inner(expr, &expected); |
58 | let ty = if let Some(target) = expected.only_has_type(&mut self.table) { | 58 | let ty = if let Some(target) = expected.only_has_type(&mut self.table) { |
59 | if !self.coerce(&ty, &target) { | 59 | if !self.coerce(&ty, &target) { |
60 | self.result.type_mismatches.insert( | 60 | self.result |
61 | expr.into(), | 61 | .type_mismatches |
62 | TypeMismatch { expected: target.clone(), actual: ty.clone() }, | 62 | .insert(expr.into(), TypeMismatch { expected: target, actual: ty.clone() }); |
63 | ); | ||
64 | // Return actual type when type mismatch. | 63 | // Return actual type when type mismatch. |
65 | // This is needed for diagnostic when return type mismatch. | 64 | // This is needed for diagnostic when return type mismatch. |
66 | ty | 65 | ty |
67 | } else { | 66 | } else { |
68 | target.clone() | 67 | target |
69 | } | 68 | } |
70 | } else { | 69 | } else { |
71 | ty | 70 | ty |
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 9c8e3b6ae..83e0a7a9e 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs | |||
@@ -196,7 +196,7 @@ impl<'a> InferenceContext<'a> { | |||
196 | let inner_ty = if let Some(subpat) = subpat { | 196 | let inner_ty = if let Some(subpat) = subpat { |
197 | self.infer_pat(*subpat, &expected, default_bm) | 197 | self.infer_pat(*subpat, &expected, default_bm) |
198 | } else { | 198 | } else { |
199 | expected.clone() | 199 | expected |
200 | }; | 200 | }; |
201 | let inner_ty = self.insert_type_vars_shallow(inner_ty); | 201 | let inner_ty = self.insert_type_vars_shallow(inner_ty); |
202 | 202 | ||
@@ -266,10 +266,9 @@ impl<'a> InferenceContext<'a> { | |||
266 | // use a new type variable if we got error type here | 266 | // use a new type variable if we got error type here |
267 | let ty = self.insert_type_vars_shallow(ty); | 267 | let ty = self.insert_type_vars_shallow(ty); |
268 | if !self.unify(&ty, &expected) { | 268 | if !self.unify(&ty, &expected) { |
269 | self.result.type_mismatches.insert( | 269 | self.result |
270 | pat.into(), | 270 | .type_mismatches |
271 | TypeMismatch { expected: expected.clone(), actual: ty.clone() }, | 271 | .insert(pat.into(), TypeMismatch { expected: expected, actual: ty.clone() }); |
272 | ); | ||
273 | } | 272 | } |
274 | self.write_pat_ty(pat, ty.clone()); | 273 | self.write_pat_ty(pat, ty.clone()); |
275 | ty | 274 | ty |
diff --git a/crates/ide_assists/src/handlers/expand_glob_import.rs b/crates/ide_assists/src/handlers/expand_glob_import.rs index 79cb08d69..6da880b52 100644 --- a/crates/ide_assists/src/handlers/expand_glob_import.rs +++ b/crates/ide_assists/src/handlers/expand_glob_import.rs | |||
@@ -55,7 +55,7 @@ pub(crate) fn expand_glob_import(acc: &mut Assists, ctx: &AssistContext) -> Opti | |||
55 | let refs_in_target = find_refs_in_mod(ctx, target_module, Some(current_module))?; | 55 | let refs_in_target = find_refs_in_mod(ctx, target_module, Some(current_module))?; |
56 | let imported_defs = find_imported_defs(ctx, star)?; | 56 | let imported_defs = find_imported_defs(ctx, star)?; |
57 | 57 | ||
58 | let target = parent.clone().either(|n| n.syntax().clone(), |n| n.syntax().clone()); | 58 | let target = parent.either(|n| n.syntax().clone(), |n| n.syntax().clone()); |
59 | acc.add( | 59 | acc.add( |
60 | AssistId("expand_glob_import", AssistKind::RefactorRewrite), | 60 | AssistId("expand_glob_import", AssistKind::RefactorRewrite), |
61 | "Expand glob import", | 61 | "Expand glob import", |
diff --git a/crates/project_model/src/build_data.rs b/crates/project_model/src/build_data.rs index 3aa546980..33a4f8168 100644 --- a/crates/project_model/src/build_data.rs +++ b/crates/project_model/src/build_data.rs | |||
@@ -214,7 +214,7 @@ impl WorkspaceBuildData { | |||
214 | acc | 214 | acc |
215 | }; | 215 | }; |
216 | let package_build_data = | 216 | let package_build_data = |
217 | res.per_package.entry(package_id.repr.clone()).or_default(); | 217 | res.per_package.entry(package_id.repr).or_default(); |
218 | // cargo_metadata crate returns default (empty) path for | 218 | // cargo_metadata crate returns default (empty) path for |
219 | // older cargos, which is not absolute, so work around that. | 219 | // older cargos, which is not absolute, so work around that. |
220 | if !out_dir.as_str().is_empty() { | 220 | if !out_dir.as_str().is_empty() { |
@@ -237,13 +237,13 @@ impl WorkspaceBuildData { | |||
237 | { | 237 | { |
238 | let filename = AbsPathBuf::assert(PathBuf::from(&filename)); | 238 | let filename = AbsPathBuf::assert(PathBuf::from(&filename)); |
239 | let package_build_data = | 239 | let package_build_data = |
240 | res.per_package.entry(package_id.repr.clone()).or_default(); | 240 | res.per_package.entry(package_id.repr).or_default(); |
241 | package_build_data.proc_macro_dylib_path = Some(filename); | 241 | package_build_data.proc_macro_dylib_path = Some(filename); |
242 | } | 242 | } |
243 | } | 243 | } |
244 | } | 244 | } |
245 | Message::CompilerMessage(message) => { | 245 | Message::CompilerMessage(message) => { |
246 | progress(message.target.name.clone()); | 246 | progress(message.target.name); |
247 | } | 247 | } |
248 | Message::BuildFinished(_) => {} | 248 | Message::BuildFinished(_) => {} |
249 | Message::TextLine(_) => {} | 249 | Message::TextLine(_) => {} |
diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs index a8fee4f08..b8ad08364 100644 --- a/crates/project_model/src/cargo_workspace.rs +++ b/crates/project_model/src/cargo_workspace.rs | |||
@@ -346,11 +346,8 @@ impl CargoWorkspace { | |||
346 | 346 | ||
347 | let workspace_root = | 347 | let workspace_root = |
348 | AbsPathBuf::assert(PathBuf::from(meta.workspace_root.into_os_string())); | 348 | AbsPathBuf::assert(PathBuf::from(meta.workspace_root.into_os_string())); |
349 | let build_data_config = BuildDataConfig::new( | 349 | let build_data_config = |
350 | cargo_toml.to_path_buf(), | 350 | BuildDataConfig::new(cargo_toml.to_path_buf(), config.clone(), Arc::new(meta.packages)); |
351 | config.clone(), | ||
352 | Arc::new(meta.packages.clone()), | ||
353 | ); | ||
354 | 351 | ||
355 | Ok(CargoWorkspace { packages, targets, workspace_root, build_data_config }) | 352 | Ok(CargoWorkspace { packages, targets, workspace_root, build_data_config }) |
356 | } | 353 | } |