Skip to content

Commit 8a30158

Browse files
committed
Remove source from compile_ws.
This was added for `cargo install` to avoid updating the source multiple times. Now that multiple updates are guarded via `Config::updated_sources`, it is no longer necessary.
1 parent 5553284 commit 8a30158

8 files changed

+12
-21
lines changed

src/cargo/ops/cargo_compile.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use crate::core::compiler::{
3131
use crate::core::compiler::{CompileMode, Kind, Unit};
3232
use crate::core::profiles::{Profiles, UnitFor};
3333
use crate::core::resolver::{Method, Resolve};
34-
use crate::core::{Package, Source, Target};
34+
use crate::core::{Package, Target};
3535
use crate::core::{PackageId, PackageIdSpec, TargetKind, Workspace};
3636
use crate::ops;
3737
use crate::util::config::Config;
@@ -247,12 +247,11 @@ pub fn compile_with_exec<'a>(
247247
exec: &Arc<dyn Executor>,
248248
) -> CargoResult<Compilation<'a>> {
249249
ws.emit_warnings()?;
250-
compile_ws(ws, None, options, exec)
250+
compile_ws(ws, options, exec)
251251
}
252252

253253
pub fn compile_ws<'a>(
254254
ws: &Workspace<'a>,
255-
source: Option<Box<dyn Source + 'a>>,
256255
options: &CompileOptions<'a>,
257256
exec: &Arc<dyn Executor>,
258257
) -> CargoResult<Compilation<'a>> {
@@ -305,7 +304,7 @@ pub fn compile_ws<'a>(
305304
all_features,
306305
uses_default_features: !no_default_features,
307306
};
308-
let resolve = ops::resolve_ws_with_method(ws, source, method, &specs)?;
307+
let resolve = ops::resolve_ws_with_method(ws, method, &specs)?;
309308
let (packages, resolve_with_overrides) = resolve;
310309

311310
let to_build_ids = specs

src/cargo/ops/cargo_doc.rs

-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub fn doc(ws: &Workspace<'_>, options: &DocOptions<'_>) -> CargoResult<()> {
2323
let specs = options.compile_opts.spec.to_package_id_specs(ws)?;
2424
let resolve = ops::resolve_ws_precisely(
2525
ws,
26-
None,
2726
&options.compile_opts.features,
2827
options.compile_opts.all_features,
2928
options.compile_opts.no_default_features,

src/cargo/ops/cargo_install.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ fn install_one(
145145
) -> CargoResult<()> {
146146
let config = opts.config;
147147

148-
let (pkg, source) = if source_id.is_git() {
148+
let pkg = if source_id.is_git() {
149149
select_pkg(
150150
GitSource::new(source_id, config)?,
151151
krate,
@@ -307,7 +307,7 @@ fn install_one(
307307
check_yanked_install(&ws)?;
308308

309309
let exec: Arc<dyn Executor> = Arc::new(DefaultExecutor);
310-
let compile = ops::compile_ws(&ws, Some(source), opts, &exec).chain_err(|| {
310+
let compile = ops::compile_ws(&ws, opts, &exec).chain_err(|| {
311311
if let Some(td) = td_opt.take() {
312312
// preserve the temporary directory, so the user can inspect it
313313
td.into_path();
@@ -489,7 +489,7 @@ fn check_yanked_install(ws: &Workspace<'_>) -> CargoResult<()> {
489489
// It would be best if `source` could be passed in here to avoid a
490490
// duplicate "Updating", but since `source` is taken by value, then it
491491
// wouldn't be available for `compile_ws`.
492-
let (pkg_set, resolve) = ops::resolve_ws_with_method(ws, None, Method::Everything, &specs)?;
492+
let (pkg_set, resolve) = ops::resolve_ws_with_method(ws, Method::Everything, &specs)?;
493493
let mut sources = pkg_set.sources_mut();
494494
for pkg_id in resolve.iter() {
495495
if let Some(source) = sources.get_mut(pkg_id.source_id()) {

src/cargo/ops/cargo_output_metadata.rs

-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ fn metadata_full(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> CargoResult
5252
let specs = Packages::All.to_package_id_specs(ws)?;
5353
let (package_set, resolve) = ops::resolve_ws_precisely(
5454
ws,
55-
None,
5655
&opt.features,
5756
opt.all_features,
5857
opt.no_default_features,

src/cargo/ops/cargo_package.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ fn build_lock(ws: &Workspace<'_>) -> CargoResult<String> {
141141
let specs = vec![PackageIdSpec::from_package_id(new_pkg.package_id())];
142142
let tmp_ws = Workspace::ephemeral(new_pkg, ws.config(), None, true)?;
143143
let (pkg_set, new_resolve) =
144-
ops::resolve_ws_with_method(&tmp_ws, None, Method::Everything, &specs)?;
144+
ops::resolve_ws_with_method(&tmp_ws, Method::Everything, &specs)?;
145145

146146
if let Some(orig_resolve) = orig_resolve {
147147
compare_resolve(config, tmp_ws.current()?, &orig_resolve, &new_resolve)?;
@@ -587,7 +587,6 @@ fn run_verify(ws: &Workspace<'_>, tar: &FileLock, opts: &PackageOpts<'_>) -> Car
587587
let exec: Arc<dyn Executor> = Arc::new(DefaultExecutor);
588588
ops::compile_ws(
589589
&ws,
590-
None,
591590
&ops::CompileOptions {
592591
config,
593592
build_config: BuildConfig::new(config, opts.jobs, &opts.target, CompileMode::Build)?,

src/cargo/ops/cargo_uninstall.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ fn uninstall_cwd(root: &Filesystem, bins: &[String], config: &Config) -> CargoRe
8585
let tracker = InstallTracker::load(config, root)?;
8686
let source_id = SourceId::for_path(config.cwd())?;
8787
let src = path_source(source_id, config)?;
88-
let (pkg, _source) = select_pkg(src, None, None, config, true, &mut |path| {
88+
let pkg = select_pkg(src, None, None, config, true, &mut |path| {
8989
path.read_packages()
9090
})?;
9191
let pkgid = pkg.package_id();

src/cargo/ops/common_for_install_and_uninstall.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ pub fn select_pkg<'a, T>(
560560
config: &Config,
561561
needs_update: bool,
562562
list_all: &mut dyn FnMut(&mut T) -> CargoResult<Vec<Package>>,
563-
) -> CargoResult<(Package, Box<dyn Source + 'a>)>
563+
) -> CargoResult<Package>
564564
where
565565
T: Source + 'a,
566566
{
@@ -647,7 +647,7 @@ where
647647
match deps.iter().map(|p| p.package_id()).max() {
648648
Some(pkgid) => {
649649
let pkg = Box::new(&mut source).download_now(pkgid, config)?;
650-
Ok((pkg, Box::new(source)))
650+
Ok(pkg)
651651
}
652652
None => {
653653
let vers_info = vers
@@ -679,7 +679,7 @@ where
679679
),
680680
},
681681
};
682-
return Ok((pkg.clone(), Box::new(source)));
682+
return Ok(pkg.clone());
683683

684684
fn multi_err(kind: &str, mut pkgs: Vec<&Package>) -> String {
685685
pkgs.sort_unstable_by_key(|a| a.name());

src/cargo/ops/resolve.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ pub fn resolve_ws<'a>(ws: &Workspace<'a>) -> CargoResult<(PackageSet<'a>, Resolv
3232
/// taking into account `paths` overrides and activated features.
3333
pub fn resolve_ws_precisely<'a>(
3434
ws: &Workspace<'a>,
35-
source: Option<Box<dyn Source + 'a>>,
3635
features: &[String],
3736
all_features: bool,
3837
no_default_features: bool,
@@ -49,19 +48,15 @@ pub fn resolve_ws_precisely<'a>(
4948
uses_default_features: !no_default_features,
5049
}
5150
};
52-
resolve_ws_with_method(ws, source, method, specs)
51+
resolve_ws_with_method(ws, method, specs)
5352
}
5453

5554
pub fn resolve_ws_with_method<'a>(
5655
ws: &Workspace<'a>,
57-
source: Option<Box<dyn Source + 'a>>,
5856
method: Method<'_>,
5957
specs: &[PackageIdSpec],
6058
) -> CargoResult<(PackageSet<'a>, Resolve)> {
6159
let mut registry = PackageRegistry::new(ws.config())?;
62-
if let Some(source) = source {
63-
registry.add_preloaded(source);
64-
}
6560
let mut add_patches = true;
6661

6762
let resolve = if ws.ignore_lock() {

0 commit comments

Comments
 (0)