mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Resolve 2 needless_pass_by_value lint warnings
TIL Rust doesn't have equational reasoning.. :-/ (can't inline the new "exec" bindings)
This commit is contained in:
parent
9c3f808c7d
commit
689f412c2f
@ -35,7 +35,7 @@ impl Summary {
|
|||||||
pub fn new<K>(
|
pub fn new<K>(
|
||||||
pkg_id: PackageId,
|
pkg_id: PackageId,
|
||||||
dependencies: Vec<Dependency>,
|
dependencies: Vec<Dependency>,
|
||||||
features: BTreeMap<K, Vec<impl AsRef<str>>>,
|
features: &BTreeMap<K, Vec<impl AsRef<str>>>,
|
||||||
links: Option<impl AsRef<str>>,
|
links: Option<impl AsRef<str>>,
|
||||||
namespaced_features: bool,
|
namespaced_features: bool,
|
||||||
) -> CargoResult<Summary>
|
) -> CargoResult<Summary>
|
||||||
|
@ -185,7 +185,8 @@ pub fn compile<'a>(
|
|||||||
ws: &Workspace<'a>,
|
ws: &Workspace<'a>,
|
||||||
options: &CompileOptions<'a>,
|
options: &CompileOptions<'a>,
|
||||||
) -> CargoResult<Compilation<'a>> {
|
) -> CargoResult<Compilation<'a>> {
|
||||||
compile_with_exec(ws, options, Arc::new(DefaultExecutor))
|
let exec: Arc<Executor> = Arc::new(DefaultExecutor);
|
||||||
|
compile_with_exec(ws, options, &exec)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like `compile` but allows specifying a custom `Executor` that will be able to intercept build
|
/// Like `compile` but allows specifying a custom `Executor` that will be able to intercept build
|
||||||
@ -193,7 +194,7 @@ pub fn compile<'a>(
|
|||||||
pub fn compile_with_exec<'a>(
|
pub fn compile_with_exec<'a>(
|
||||||
ws: &Workspace<'a>,
|
ws: &Workspace<'a>,
|
||||||
options: &CompileOptions<'a>,
|
options: &CompileOptions<'a>,
|
||||||
exec: Arc<Executor>,
|
exec: &Arc<Executor>,
|
||||||
) -> CargoResult<Compilation<'a>> {
|
) -> CargoResult<Compilation<'a>> {
|
||||||
ws.emit_warnings()?;
|
ws.emit_warnings()?;
|
||||||
compile_ws(ws, None, options, exec)
|
compile_ws(ws, None, options, exec)
|
||||||
@ -203,7 +204,7 @@ pub fn compile_ws<'a>(
|
|||||||
ws: &Workspace<'a>,
|
ws: &Workspace<'a>,
|
||||||
source: Option<Box<Source + 'a>>,
|
source: Option<Box<Source + 'a>>,
|
||||||
options: &CompileOptions<'a>,
|
options: &CompileOptions<'a>,
|
||||||
exec: Arc<Executor>,
|
exec: &Arc<Executor>,
|
||||||
) -> CargoResult<Compilation<'a>> {
|
) -> CargoResult<Compilation<'a>> {
|
||||||
let CompileOptions {
|
let CompileOptions {
|
||||||
config,
|
config,
|
||||||
|
@ -12,7 +12,7 @@ use toml;
|
|||||||
|
|
||||||
use core::{Dependency, Edition, Package, PackageIdSpec, Source, SourceId};
|
use core::{Dependency, Edition, Package, PackageIdSpec, Source, SourceId};
|
||||||
use core::{PackageId, Workspace};
|
use core::{PackageId, Workspace};
|
||||||
use core::compiler::DefaultExecutor;
|
use core::compiler::{DefaultExecutor, Executor};
|
||||||
use ops::{self, CompileFilter};
|
use ops::{self, CompileFilter};
|
||||||
use sources::{GitSource, PathSource, SourceConfigMap};
|
use sources::{GitSource, PathSource, SourceConfigMap};
|
||||||
use util::{internal, Config};
|
use util::{internal, Config};
|
||||||
@ -262,8 +262,9 @@ fn install_one(
|
|||||||
check_overwrites(&dst, pkg, &opts.filter, &list, force)?;
|
check_overwrites(&dst, pkg, &opts.filter, &list, force)?;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let exec: Arc<Executor> = Arc::new(DefaultExecutor);
|
||||||
let compile =
|
let compile =
|
||||||
ops::compile_ws(&ws, Some(source), opts, Arc::new(DefaultExecutor)).chain_err(|| {
|
ops::compile_ws(&ws, Some(source), opts, &exec).chain_err(|| {
|
||||||
if let Some(td) = td_opt.take() {
|
if let Some(td) = td_opt.take() {
|
||||||
// preserve the temporary directory, so the user can inspect it
|
// preserve the temporary directory, so the user can inspect it
|
||||||
td.into_path();
|
td.into_path();
|
||||||
|
@ -10,7 +10,7 @@ use git2;
|
|||||||
use tar::{Archive, Builder, EntryType, Header};
|
use tar::{Archive, Builder, EntryType, Header};
|
||||||
|
|
||||||
use core::{Package, Source, SourceId, Workspace};
|
use core::{Package, Source, SourceId, Workspace};
|
||||||
use core::compiler::{BuildConfig, CompileMode, DefaultExecutor};
|
use core::compiler::{BuildConfig, CompileMode, DefaultExecutor, Executor};
|
||||||
use sources::PathSource;
|
use sources::PathSource;
|
||||||
use util::{self, internal, Config, FileLock};
|
use util::{self, internal, Config, FileLock};
|
||||||
use util::paths;
|
use util::paths;
|
||||||
@ -333,6 +333,7 @@ fn run_verify(ws: &Workspace, tar: &FileLock, opts: &PackageOpts) -> CargoResult
|
|||||||
let pkg_fingerprint = src.last_modified_file(&new_pkg)?;
|
let pkg_fingerprint = src.last_modified_file(&new_pkg)?;
|
||||||
let ws = Workspace::ephemeral(new_pkg, config, None, true)?;
|
let ws = Workspace::ephemeral(new_pkg, config, None, true)?;
|
||||||
|
|
||||||
|
let exec: Arc<Executor> = Arc::new(DefaultExecutor);
|
||||||
ops::compile_ws(
|
ops::compile_ws(
|
||||||
&ws,
|
&ws,
|
||||||
None,
|
None,
|
||||||
@ -350,7 +351,7 @@ fn run_verify(ws: &Workspace, tar: &FileLock, opts: &PackageOpts) -> CargoResult
|
|||||||
target_rustc_args: None,
|
target_rustc_args: None,
|
||||||
export_dir: None,
|
export_dir: None,
|
||||||
},
|
},
|
||||||
Arc::new(DefaultExecutor),
|
&exec,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
// Check that build.rs didn't modify any files in the src directory.
|
// Check that build.rs didn't modify any files in the src directory.
|
||||||
|
@ -253,7 +253,7 @@ impl<'cfg> RegistryIndex<'cfg> {
|
|||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|dep| dep.into_dep(&self.source_id))
|
.map(|dep| dep.into_dep(&self.source_id))
|
||||||
.collect::<CargoResult<Vec<_>>>()?;
|
.collect::<CargoResult<Vec<_>>>()?;
|
||||||
let summary = Summary::new(pkgid, deps, features, links, false)?;
|
let summary = Summary::new(pkgid, deps, &features, links, false)?;
|
||||||
let summary = summary.set_checksum(cksum.clone());
|
let summary = summary.set_checksum(cksum.clone());
|
||||||
self.hashes
|
self.hashes
|
||||||
.entry(name.as_str())
|
.entry(name.as_str())
|
||||||
|
@ -893,7 +893,7 @@ impl TomlManifest {
|
|||||||
let summary = Summary::new(
|
let summary = Summary::new(
|
||||||
pkgid,
|
pkgid,
|
||||||
deps,
|
deps,
|
||||||
me.features
|
&me.features
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.map(|x| {
|
.map(|x| {
|
||||||
x.iter()
|
x.iter()
|
||||||
|
@ -38,7 +38,7 @@ fn resolve_with_config(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
let mut registry = MyRegistry(registry);
|
let mut registry = MyRegistry(registry);
|
||||||
let summary = Summary::new(pkg.clone(), deps, BTreeMap::<String, Vec<String>>::new(), None::<String>, false).unwrap();
|
let summary = Summary::new(pkg.clone(), deps, &BTreeMap::<String, Vec<String>>::new(), None::<String>, false).unwrap();
|
||||||
let method = Method::Everything;
|
let method = Method::Everything;
|
||||||
let resolve = resolver::resolve(
|
let resolve = resolver::resolve(
|
||||||
&[(summary, method)],
|
&[(summary, method)],
|
||||||
@ -100,13 +100,13 @@ macro_rules! pkg {
|
|||||||
let pkgid = $pkgid.to_pkgid();
|
let pkgid = $pkgid.to_pkgid();
|
||||||
let link = if pkgid.name().ends_with("-sys") {Some(pkgid.name().as_str())} else {None};
|
let link = if pkgid.name().ends_with("-sys") {Some(pkgid.name().as_str())} else {None};
|
||||||
|
|
||||||
Summary::new(pkgid, d, BTreeMap::<String, Vec<String>>::new(), link, false).unwrap()
|
Summary::new(pkgid, d, &BTreeMap::<String, Vec<String>>::new(), link, false).unwrap()
|
||||||
});
|
});
|
||||||
|
|
||||||
($pkgid:expr) => ({
|
($pkgid:expr) => ({
|
||||||
let pkgid = $pkgid.to_pkgid();
|
let pkgid = $pkgid.to_pkgid();
|
||||||
let link = if pkgid.name().ends_with("-sys") {Some(pkgid.name().as_str())} else {None};
|
let link = if pkgid.name().ends_with("-sys") {Some(pkgid.name().as_str())} else {None};
|
||||||
Summary::new(pkgid, Vec::new(), BTreeMap::<String, Vec<String>>::new(), link, false).unwrap()
|
Summary::new(pkgid, Vec::new(), &BTreeMap::<String, Vec<String>>::new(), link, false).unwrap()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ fn pkg(name: &str) -> Summary {
|
|||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
Summary::new(pkg_id(name), Vec::new(), BTreeMap::<String, Vec<String>>::new(), link, false).unwrap()
|
Summary::new(pkg_id(name), Vec::new(), &BTreeMap::<String, Vec<String>>::new(), link, false).unwrap()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn pkg_id(name: &str) -> PackageId {
|
fn pkg_id(name: &str) -> PackageId {
|
||||||
@ -145,7 +145,7 @@ fn pkg_loc(name: &str, loc: &str) -> Summary {
|
|||||||
Summary::new(
|
Summary::new(
|
||||||
pkg_id_loc(name, loc),
|
pkg_id_loc(name, loc),
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
BTreeMap::<String, Vec<String>>::new(),
|
&BTreeMap::<String, Vec<String>>::new(),
|
||||||
link,
|
link,
|
||||||
false,
|
false,
|
||||||
).unwrap()
|
).unwrap()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user