mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-25 11:14:46 +00:00
clippy fixes
This commit is contained in:
parent
258c89644c
commit
6694fdb677
@ -442,7 +442,7 @@ impl Package {
|
||||
} else {
|
||||
registry_path.join(&file)
|
||||
};
|
||||
let prev = fs::read_to_string(&dst).unwrap_or(String::new());
|
||||
let prev = fs::read_to_string(&dst).unwrap_or_default();
|
||||
t!(fs::create_dir_all(dst.parent().unwrap()));
|
||||
t!(fs::write(&dst, prev + &line[..] + "\n"));
|
||||
|
||||
|
@ -206,7 +206,7 @@ fn parse_edge_kinds(config: &Config, args: &ArgMatches<'_>) -> CargoResult<HashS
|
||||
.warn("the --no-dev-dependencies flag has changed to -e=no-dev")?;
|
||||
kinds.push("no-dev");
|
||||
}
|
||||
if kinds.len() == 0 {
|
||||
if kinds.is_empty() {
|
||||
kinds.extend(&["normal", "build", "dev"]);
|
||||
}
|
||||
|
||||
|
@ -448,7 +448,7 @@ fn env_args(
|
||||
// This means that, e.g., even if the specified --target is the
|
||||
// same as the host, build scripts in plugins won't get
|
||||
// RUSTFLAGS.
|
||||
if requested_kinds != &[CompileKind::Host] && kind.is_host() {
|
||||
if requested_kinds != [CompileKind::Host] && kind.is_host() {
|
||||
// This is probably a build script or plugin and we're
|
||||
// compiling with --target. In this scenario there are
|
||||
// no rustflags we can apply.
|
||||
|
@ -55,7 +55,7 @@ impl CompileKind {
|
||||
if targets.len() > 1 && !config.cli_unstable().multitarget {
|
||||
bail!("specifying multiple `--target` flags requires `-Zmultitarget`")
|
||||
}
|
||||
if targets.len() != 0 {
|
||||
if !targets.is_empty() {
|
||||
return Ok(targets
|
||||
.iter()
|
||||
.map(|value| Ok(CompileKind::Target(CompileTarget::new(value)?)))
|
||||
|
@ -161,7 +161,7 @@ pub fn generate_std_roots(
|
||||
let features = std_features.activated_features(pkg.package_id(), FeaturesFor::NormalOrDev);
|
||||
|
||||
for kind in kinds {
|
||||
let list = ret.entry(*kind).or_insert(Vec::new());
|
||||
let list = ret.entry(*kind).or_insert_with(Vec::new);
|
||||
list.push(interner.intern(
|
||||
pkg,
|
||||
lib,
|
||||
@ -173,7 +173,7 @@ pub fn generate_std_roots(
|
||||
));
|
||||
}
|
||||
}
|
||||
return Ok(ret);
|
||||
Ok(ret)
|
||||
}
|
||||
|
||||
fn detect_sysroot_src_path(target_data: &RustcTargetData) -> CargoResult<PathBuf> {
|
||||
|
@ -204,6 +204,6 @@ impl UnitInterner {
|
||||
}
|
||||
let item = Rc::new(item.clone());
|
||||
me.cache.insert(item.clone());
|
||||
return item;
|
||||
item
|
||||
}
|
||||
}
|
||||
|
@ -113,6 +113,6 @@ pub fn emit_serialized_unit_graph(root_units: &[Unit], unit_graph: &UnitGraph) -
|
||||
let stdout = std::io::stdout();
|
||||
let mut lock = stdout.lock();
|
||||
serde_json::to_writer(&mut lock, &s)?;
|
||||
write!(lock, "\n")?;
|
||||
writeln!(lock)?;
|
||||
Ok(())
|
||||
}
|
||||
|
@ -669,7 +669,7 @@ impl Target {
|
||||
.set_name(name)
|
||||
.set_doctest(true)
|
||||
.set_doc(true);
|
||||
return target;
|
||||
target
|
||||
}
|
||||
|
||||
pub fn bin_target(
|
||||
@ -684,7 +684,7 @@ impl Target {
|
||||
.set_name(name)
|
||||
.set_required_features(required_features)
|
||||
.set_doc(true);
|
||||
return target;
|
||||
target
|
||||
}
|
||||
|
||||
/// Builds a `Target` corresponding to the `build = "build.rs"` entry.
|
||||
@ -696,7 +696,7 @@ impl Target {
|
||||
.set_for_host(true)
|
||||
.set_benched(false)
|
||||
.set_tested(false);
|
||||
return target;
|
||||
target
|
||||
}
|
||||
|
||||
pub fn metabuild_target(name: &str) -> Target {
|
||||
@ -707,7 +707,7 @@ impl Target {
|
||||
.set_for_host(true)
|
||||
.set_benched(false)
|
||||
.set_tested(false);
|
||||
return target;
|
||||
target
|
||||
}
|
||||
|
||||
pub fn example_target(
|
||||
@ -733,7 +733,7 @@ impl Target {
|
||||
.set_required_features(required_features)
|
||||
.set_tested(false)
|
||||
.set_benched(false);
|
||||
return target;
|
||||
target
|
||||
}
|
||||
|
||||
pub fn test_target(
|
||||
@ -748,7 +748,7 @@ impl Target {
|
||||
.set_name(name)
|
||||
.set_required_features(required_features)
|
||||
.set_benched(false);
|
||||
return target;
|
||||
target
|
||||
}
|
||||
|
||||
pub fn bench_target(
|
||||
@ -763,7 +763,7 @@ impl Target {
|
||||
.set_name(name)
|
||||
.set_required_features(required_features)
|
||||
.set_tested(false);
|
||||
return target;
|
||||
target
|
||||
}
|
||||
|
||||
pub fn name(&self) -> &str {
|
||||
|
@ -622,7 +622,7 @@ fn lock(
|
||||
|
||||
// Lock the summary's ID if possible
|
||||
let summary = match pair {
|
||||
Some((precise, _)) => summary.override_id(precise.clone()),
|
||||
Some((precise, _)) => summary.override_id(*precise),
|
||||
None => summary,
|
||||
};
|
||||
summary.map_dependencies(|dep| {
|
||||
|
@ -213,7 +213,7 @@ impl ConflictCache {
|
||||
|
||||
for c in con.keys() {
|
||||
self.dep_from_pid
|
||||
.entry(c.clone())
|
||||
.entry(*c)
|
||||
.or_insert_with(HashSet::new)
|
||||
.insert(dep.clone());
|
||||
}
|
||||
|
@ -260,7 +260,7 @@ impl EncodableResolve {
|
||||
let mut g = Graph::new();
|
||||
|
||||
for &(ref id, _) in live_pkgs.values() {
|
||||
g.add(id.clone());
|
||||
g.add(*id);
|
||||
}
|
||||
|
||||
for &(ref id, pkg) in live_pkgs.values() {
|
||||
@ -271,7 +271,7 @@ impl EncodableResolve {
|
||||
|
||||
for edge in deps.iter() {
|
||||
if let Some(to_depend_on) = lookup_id(edge) {
|
||||
g.link(id.clone(), to_depend_on);
|
||||
g.link(*id, to_depend_on);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -282,7 +282,7 @@ impl EncodableResolve {
|
||||
if let Some(ref replace) = pkg.replace {
|
||||
assert!(pkg.dependencies.is_none());
|
||||
if let Some(replace_id) = lookup_id(replace) {
|
||||
replacements.insert(id.clone(), replace_id);
|
||||
replacements.insert(*id, replace_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ pub fn display_error(err: &Error, shell: &mut Shell) {
|
||||
/// and context.
|
||||
pub fn display_warning_with_error(warning: &str, err: &Error, shell: &mut Shell) {
|
||||
drop(shell.warn(warning));
|
||||
drop(writeln!(shell.err(), ""));
|
||||
drop(writeln!(shell.err()));
|
||||
_display_error(err, shell, false);
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ pub fn fetch<'a>(
|
||||
deps.iter().any(|d| {
|
||||
// If no target was specified then all dependencies are
|
||||
// fetched.
|
||||
if options.targets.len() == 0 {
|
||||
if options.targets.is_empty() {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -176,7 +176,7 @@ fn build_resolve_graph_r(
|
||||
let deps: Vec<Dep> = resolve
|
||||
.deps(pkg_id)
|
||||
.filter(|(_dep_id, deps)| {
|
||||
if requested_kinds == &[CompileKind::Host] {
|
||||
if requested_kinds == [CompileKind::Host] {
|
||||
true
|
||||
} else {
|
||||
requested_kinds.iter().any(|kind| {
|
||||
|
@ -378,7 +378,7 @@ fn registry(
|
||||
token: token_config,
|
||||
index: index_config,
|
||||
} = registry_configuration(config, registry.clone())?;
|
||||
let opt_index = index_config.as_ref().or(index.as_ref());
|
||||
let opt_index = index_config.as_ref().or_else(|| index.as_ref());
|
||||
let sid = get_source_id(config, opt_index, registry.as_ref())?;
|
||||
if !sid.is_remote_registry() {
|
||||
bail!(
|
||||
|
@ -35,7 +35,7 @@ fn simple_build() {
|
||||
.masquerade_as_nightly_cargo()
|
||||
.run();
|
||||
|
||||
assert!(p.target_bin(&t1, "foo").is_file());
|
||||
assert!(p.target_bin(t1, "foo").is_file());
|
||||
assert!(p.target_bin(&t2, "foo").is_file());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user