From eceaf94f1936436e33ae235ca65bf2a6d4f77da5 Mon Sep 17 00:00:00 2001 From: Kirill Bulatov Date: Tue, 18 Feb 2020 15:32:19 +0200 Subject: More manual clippy fixes --- crates/ra_project_model/src/cargo_workspace.rs | 2 +- crates/ra_project_model/src/lib.rs | 67 +++++++++++++++----------- 2 files changed, 39 insertions(+), 30 deletions(-) (limited to 'crates/ra_project_model/src') 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 { let pkg_data = &mut packages[pkg]; pkg_by_id.insert(id, pkg); for meta_tgt in meta_pkg.targets { - let is_proc_macro = meta_tgt.kind.as_slice() == &["proc-macro"]; + let is_proc_macro = meta_tgt.kind.as_slice() == ["proc-macro"]; let tgt = targets.alloc(TargetData { pkg, 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 { if let (Some(&from), Some(&to)) = (crates.get(&from_crate_id), crates.get(&to_crate_id)) { - if let Err(_) = - crate_graph.add_dep(from, CrateName::new(&dep.name).unwrap(), to) + if crate_graph + .add_dep(from, CrateName::new(&dep.name).unwrap(), to) + .is_err() { log::error!( "cyclic dependency {:?} -> {:?}", @@ -237,8 +238,7 @@ impl ProjectWorkspace { if let (Some(&from), Some(&to)) = (sysroot_crates.get(&from), sysroot_crates.get(&to)) { - if let Err(_) = - crate_graph.add_dep(from, CrateName::new(name).unwrap(), to) + if crate_graph.add_dep(from, CrateName::new(name).unwrap(), to).is_err() { log::error!("cyclic dependency between sysroot crates") } @@ -279,11 +279,14 @@ impl ProjectWorkspace { } if tgt.is_proc_macro(&cargo) { if let Some(proc_macro) = libproc_macro { - if let Err(_) = crate_graph.add_dep( - crate_id, - CrateName::new("proc_macro").unwrap(), - proc_macro, - ) { + if crate_graph + .add_dep( + crate_id, + CrateName::new("proc_macro").unwrap(), + proc_macro, + ) + .is_err() + { log::error!( "cyclic dependency on proc_macro for {}", pkg.name(&cargo) @@ -299,15 +302,19 @@ impl ProjectWorkspace { // Set deps to the core, std and to the lib target of the current package for &from in pkg_crates.get(&pkg).into_iter().flatten() { if let Some(to) = lib_tgt { - if to != from { - if let Err(_) = crate_graph.add_dep( - from, - // For root projects with dashes in their name, - // cargo metadata does not do any normalization, - // so we do it ourselves currently - CrateName::normalize_dashes(pkg.name(&cargo)), - to, - ) { + if to != from + && crate_graph + .add_dep( + from, + // For root projects with dashes in their name, + // cargo metadata does not do any normalization, + // so we do it ourselves currently + CrateName::normalize_dashes(pkg.name(&cargo)), + to, + ) + .is_err() + { + { log::error!( "cyclic dependency between targets of {}", pkg.name(&cargo) @@ -318,22 +325,25 @@ impl ProjectWorkspace { // core is added as a dependency before std in order to // mimic rustcs dependency order if let Some(core) = libcore { - if let Err(_) = - crate_graph.add_dep(from, CrateName::new("core").unwrap(), core) + if crate_graph + .add_dep(from, CrateName::new("core").unwrap(), core) + .is_err() { log::error!("cyclic dependency on core for {}", pkg.name(&cargo)) } } if let Some(alloc) = liballoc { - if let Err(_) = - crate_graph.add_dep(from, CrateName::new("alloc").unwrap(), alloc) + if crate_graph + .add_dep(from, CrateName::new("alloc").unwrap(), alloc) + .is_err() { log::error!("cyclic dependency on alloc for {}", pkg.name(&cargo)) } } if let Some(std) = libstd { - if let Err(_) = - crate_graph.add_dep(from, CrateName::new("std").unwrap(), std) + if crate_graph + .add_dep(from, CrateName::new("std").unwrap(), std) + .is_err() { log::error!("cyclic dependency on std for {}", pkg.name(&cargo)) } @@ -347,11 +357,10 @@ impl ProjectWorkspace { for dep in pkg.dependencies(&cargo) { if let Some(&to) = pkg_to_lib_crate.get(&dep.pkg) { for &from in pkg_crates.get(&pkg).into_iter().flatten() { - if let Err(_) = crate_graph.add_dep( - from, - CrateName::new(&dep.name).unwrap(), - to, - ) { + if crate_graph + .add_dep(from, CrateName::new(&dep.name).unwrap(), to) + .is_err() + { log::error!( "cyclic dependency {} -> {}", pkg.name(&cargo), -- cgit v1.2.3