diff options
author | Kirill Bulatov <[email protected]> | 2020-02-18 13:32:19 +0000 |
---|---|---|
committer | Kirill Bulatov <[email protected]> | 2020-02-18 14:12:37 +0000 |
commit | eceaf94f1936436e33ae235ca65bf2a6d4f77da5 (patch) | |
tree | 83d42e6f014f80b84f9193e6b5c7c1e2aded9fa7 /crates/ra_project_model/src | |
parent | b8ddcb0652f3ec8683023afc1e1f5166d6a712f4 (diff) |
More manual clippy fixes
Diffstat (limited to 'crates/ra_project_model/src')
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 2 | ||||
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 67 |
2 files changed, 39 insertions, 30 deletions
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index 34fd73bb7..4fea459d5 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -197,7 +197,7 @@ impl CargoWorkspace { | |||
197 | let pkg_data = &mut packages[pkg]; | 197 | let pkg_data = &mut packages[pkg]; |
198 | pkg_by_id.insert(id, pkg); | 198 | pkg_by_id.insert(id, pkg); |
199 | for meta_tgt in meta_pkg.targets { | 199 | for meta_tgt in meta_pkg.targets { |
200 | let is_proc_macro = meta_tgt.kind.as_slice() == &["proc-macro"]; | 200 | let is_proc_macro = meta_tgt.kind.as_slice() == ["proc-macro"]; |
201 | let tgt = targets.alloc(TargetData { | 201 | let tgt = targets.alloc(TargetData { |
202 | pkg, | 202 | pkg, |
203 | name: meta_tgt.name, | 203 | name: meta_tgt.name, |
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index 9e67d2498..e35f7fbbc 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -197,8 +197,9 @@ impl ProjectWorkspace { | |||
197 | if let (Some(&from), Some(&to)) = | 197 | if let (Some(&from), Some(&to)) = |
198 | (crates.get(&from_crate_id), crates.get(&to_crate_id)) | 198 | (crates.get(&from_crate_id), crates.get(&to_crate_id)) |
199 | { | 199 | { |
200 | if let Err(_) = | 200 | if crate_graph |
201 | crate_graph.add_dep(from, CrateName::new(&dep.name).unwrap(), to) | 201 | .add_dep(from, CrateName::new(&dep.name).unwrap(), to) |
202 | .is_err() | ||
202 | { | 203 | { |
203 | log::error!( | 204 | log::error!( |
204 | "cyclic dependency {:?} -> {:?}", | 205 | "cyclic dependency {:?} -> {:?}", |
@@ -237,8 +238,7 @@ impl ProjectWorkspace { | |||
237 | if let (Some(&from), Some(&to)) = | 238 | if let (Some(&from), Some(&to)) = |
238 | (sysroot_crates.get(&from), sysroot_crates.get(&to)) | 239 | (sysroot_crates.get(&from), sysroot_crates.get(&to)) |
239 | { | 240 | { |
240 | if let Err(_) = | 241 | if crate_graph.add_dep(from, CrateName::new(name).unwrap(), to).is_err() |
241 | crate_graph.add_dep(from, CrateName::new(name).unwrap(), to) | ||
242 | { | 242 | { |
243 | log::error!("cyclic dependency between sysroot crates") | 243 | log::error!("cyclic dependency between sysroot crates") |
244 | } | 244 | } |
@@ -279,11 +279,14 @@ impl ProjectWorkspace { | |||
279 | } | 279 | } |
280 | if tgt.is_proc_macro(&cargo) { | 280 | if tgt.is_proc_macro(&cargo) { |
281 | if let Some(proc_macro) = libproc_macro { | 281 | if let Some(proc_macro) = libproc_macro { |
282 | if let Err(_) = crate_graph.add_dep( | 282 | if crate_graph |
283 | crate_id, | 283 | .add_dep( |
284 | CrateName::new("proc_macro").unwrap(), | 284 | crate_id, |
285 | proc_macro, | 285 | CrateName::new("proc_macro").unwrap(), |
286 | ) { | 286 | proc_macro, |
287 | ) | ||
288 | .is_err() | ||
289 | { | ||
287 | log::error!( | 290 | log::error!( |
288 | "cyclic dependency on proc_macro for {}", | 291 | "cyclic dependency on proc_macro for {}", |
289 | pkg.name(&cargo) | 292 | pkg.name(&cargo) |
@@ -299,15 +302,19 @@ impl ProjectWorkspace { | |||
299 | // Set deps to the core, std and to the lib target of the current package | 302 | // Set deps to the core, std and to the lib target of the current package |
300 | for &from in pkg_crates.get(&pkg).into_iter().flatten() { | 303 | for &from in pkg_crates.get(&pkg).into_iter().flatten() { |
301 | if let Some(to) = lib_tgt { | 304 | if let Some(to) = lib_tgt { |
302 | if to != from { | 305 | if to != from |
303 | if let Err(_) = crate_graph.add_dep( | 306 | && crate_graph |
304 | from, | 307 | .add_dep( |
305 | // For root projects with dashes in their name, | 308 | from, |
306 | // cargo metadata does not do any normalization, | 309 | // For root projects with dashes in their name, |
307 | // so we do it ourselves currently | 310 | // cargo metadata does not do any normalization, |
308 | CrateName::normalize_dashes(pkg.name(&cargo)), | 311 | // so we do it ourselves currently |
309 | to, | 312 | CrateName::normalize_dashes(pkg.name(&cargo)), |
310 | ) { | 313 | to, |
314 | ) | ||
315 | .is_err() | ||
316 | { | ||
317 | { | ||
311 | log::error!( | 318 | log::error!( |
312 | "cyclic dependency between targets of {}", | 319 | "cyclic dependency between targets of {}", |
313 | pkg.name(&cargo) | 320 | pkg.name(&cargo) |
@@ -318,22 +325,25 @@ impl ProjectWorkspace { | |||
318 | // core is added as a dependency before std in order to | 325 | // core is added as a dependency before std in order to |
319 | // mimic rustcs dependency order | 326 | // mimic rustcs dependency order |
320 | if let Some(core) = libcore { | 327 | if let Some(core) = libcore { |
321 | if let Err(_) = | 328 | if crate_graph |
322 | crate_graph.add_dep(from, CrateName::new("core").unwrap(), core) | 329 | .add_dep(from, CrateName::new("core").unwrap(), core) |
330 | .is_err() | ||
323 | { | 331 | { |
324 | log::error!("cyclic dependency on core for {}", pkg.name(&cargo)) | 332 | log::error!("cyclic dependency on core for {}", pkg.name(&cargo)) |
325 | } | 333 | } |
326 | } | 334 | } |
327 | if let Some(alloc) = liballoc { | 335 | if let Some(alloc) = liballoc { |
328 | if let Err(_) = | 336 | if crate_graph |
329 | crate_graph.add_dep(from, CrateName::new("alloc").unwrap(), alloc) | 337 | .add_dep(from, CrateName::new("alloc").unwrap(), alloc) |
338 | .is_err() | ||
330 | { | 339 | { |
331 | log::error!("cyclic dependency on alloc for {}", pkg.name(&cargo)) | 340 | log::error!("cyclic dependency on alloc for {}", pkg.name(&cargo)) |
332 | } | 341 | } |
333 | } | 342 | } |
334 | if let Some(std) = libstd { | 343 | if let Some(std) = libstd { |
335 | if let Err(_) = | 344 | if crate_graph |
336 | crate_graph.add_dep(from, CrateName::new("std").unwrap(), std) | 345 | .add_dep(from, CrateName::new("std").unwrap(), std) |
346 | .is_err() | ||
337 | { | 347 | { |
338 | log::error!("cyclic dependency on std for {}", pkg.name(&cargo)) | 348 | log::error!("cyclic dependency on std for {}", pkg.name(&cargo)) |
339 | } | 349 | } |
@@ -347,11 +357,10 @@ impl ProjectWorkspace { | |||
347 | for dep in pkg.dependencies(&cargo) { | 357 | for dep in pkg.dependencies(&cargo) { |
348 | if let Some(&to) = pkg_to_lib_crate.get(&dep.pkg) { | 358 | if let Some(&to) = pkg_to_lib_crate.get(&dep.pkg) { |
349 | for &from in pkg_crates.get(&pkg).into_iter().flatten() { | 359 | for &from in pkg_crates.get(&pkg).into_iter().flatten() { |
350 | if let Err(_) = crate_graph.add_dep( | 360 | if crate_graph |
351 | from, | 361 | .add_dep(from, CrateName::new(&dep.name).unwrap(), to) |
352 | CrateName::new(&dep.name).unwrap(), | 362 | .is_err() |
353 | to, | 363 | { |
354 | ) { | ||
355 | log::error!( | 364 | log::error!( |
356 | "cyclic dependency {} -> {}", | 365 | "cyclic dependency {} -> {}", |
357 | pkg.name(&cargo), | 366 | pkg.name(&cargo), |