Skip to content

Commit 3beeb28

Browse files
committed
refactor: always get max rust-version from workspace
1 parent f8c152d commit 3beeb28

File tree

9 files changed

+3
-36
lines changed

9 files changed

+3
-36
lines changed

benches/benchsuite/benches/resolve.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ fn do_resolve<'cfg>(config: &'cfg Config, ws_root: &Path) -> ResolveInfo<'cfg> {
3131
let specs = pkgs.to_package_id_specs(&ws).unwrap();
3232
let has_dev_units = HasDevUnits::Yes;
3333
let force_all_targets = ForceAllTargets::No;
34-
let max_rust_version = None;
3534
// Do an initial run to download anything necessary so that it does
3635
// not confuse criterion's warmup.
3736
let ws_resolve = cargo::ops::resolve_ws_with_opts(
@@ -42,7 +41,6 @@ fn do_resolve<'cfg>(config: &'cfg Config, ws_root: &Path) -> ResolveInfo<'cfg> {
4241
&specs,
4342
has_dev_units,
4443
force_all_targets,
45-
max_rust_version,
4644
)
4745
.unwrap();
4846
ResolveInfo {
@@ -84,7 +82,6 @@ fn resolve_ws(c: &mut Criterion) {
8482
force_all_targets,
8583
..
8684
} = lazy_info.get_or_insert_with(|| do_resolve(&config, &ws_root));
87-
let max_rust_version = None;
8885
b.iter(|| {
8986
cargo::ops::resolve_ws_with_opts(
9087
ws,
@@ -94,7 +91,6 @@ fn resolve_ws(c: &mut Criterion) {
9491
specs,
9592
*has_dev_units,
9693
*force_all_targets,
97-
max_rust_version,
9894
)
9995
.unwrap();
10096
})

src/cargo/core/compiler/standard_lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,6 @@ pub fn resolve_std<'cfg>(
145145
let cli_features = CliFeatures::from_command_line(
146146
&features, /*all_features*/ false, /*uses_default_features*/ false,
147147
)?;
148-
let max_rust_version = ws.rust_version();
149148
let resolve = ops::resolve_ws_with_opts(
150149
&std_ws,
151150
target_data,
@@ -154,7 +153,6 @@ pub fn resolve_std<'cfg>(
154153
&specs,
155154
HasDevUnits::No,
156155
crate::core::resolver::features::ForceAllTargets::No,
157-
max_rust_version,
158156
)?;
159157
Ok((
160158
resolve.pkg_set,

src/cargo/ops/cargo_compile/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,6 @@ pub fn create_bcx<'a, 'cfg>(
262262
HasDevUnits::No
263263
}
264264
};
265-
let max_rust_version = ws.rust_version();
266265
let resolve = ops::resolve_ws_with_opts(
267266
ws,
268267
&mut target_data,
@@ -271,7 +270,6 @@ pub fn create_bcx<'a, 'cfg>(
271270
&specs,
272271
has_dev_units,
273272
crate::core::resolver::features::ForceAllTargets::No,
274-
max_rust_version,
275273
)?;
276274
let WorkspaceResolve {
277275
mut pkg_set,

src/cargo/ops/cargo_generate_lockfile.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ pub struct UpdateOptions<'a> {
2323

2424
pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> {
2525
let mut registry = PackageRegistry::new(ws.config())?;
26-
let max_rust_version = ws.rust_version();
2726
let mut resolve = ops::resolve_with_previous(
2827
&mut registry,
2928
ws,
@@ -33,7 +32,6 @@ pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> {
3332
None,
3433
&[],
3534
true,
36-
max_rust_version,
3735
)?;
3836
ops::write_pkg_lockfile(ws, &mut resolve)?;
3937
Ok(())
@@ -54,8 +52,6 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
5452
.config()
5553
.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?;
5654

57-
let max_rust_version = ws.rust_version();
58-
5955
let previous_resolve = match ops::load_pkg_lockfile(ws)? {
6056
Some(resolve) => resolve,
6157
None => {
@@ -75,7 +71,6 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
7571
None,
7672
&[],
7773
true,
78-
max_rust_version,
7974
)?
8075
}
8176
}
@@ -154,7 +149,6 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
154149
Some(&to_avoid),
155150
&[],
156151
true,
157-
max_rust_version,
158152
)?;
159153

160154
// Summarize what is changing for the user.

src/cargo/ops/cargo_output_metadata.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,6 @@ fn build_resolve_graph(
140140
crate::core::resolver::features::ForceAllTargets::No
141141
};
142142

143-
let max_rust_version = ws.rust_version();
144-
145143
// Note that even with --filter-platform we end up downloading host dependencies as well,
146144
// as that is the behavior of download_accessible.
147145
let ws_resolve = ops::resolve_ws_with_opts(
@@ -152,7 +150,6 @@ fn build_resolve_graph(
152150
&specs,
153151
HasDevUnits::Yes,
154152
force_all,
155-
max_rust_version,
156153
)?;
157154

158155
let package_map: BTreeMap<PackageId, Package> = ws_resolve

src/cargo/ops/cargo_package.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,6 @@ fn build_lock(ws: &Workspace<'_>, orig_pkg: &Package) -> CargoResult<String> {
461461
to_real_manifest(toml_manifest, false, source_id, package_root, config)?;
462462
let new_pkg = Package::new(manifest, orig_pkg.manifest_path());
463463

464-
let max_rust_version = new_pkg.rust_version().cloned();
465-
466464
// Regenerate Cargo.lock using the old one as a guide.
467465
let tmp_ws = Workspace::ephemeral(new_pkg, ws.config(), None, true)?;
468466
let mut tmp_reg = PackageRegistry::new(ws.config())?;
@@ -475,7 +473,6 @@ fn build_lock(ws: &Workspace<'_>, orig_pkg: &Package) -> CargoResult<String> {
475473
None,
476474
&[],
477475
true,
478-
max_rust_version.as_ref(),
479476
)?;
480477
let pkg_set = ops::get_resolved_packages(&new_resolve, tmp_reg)?;
481478

src/cargo/ops/fix.rs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@ fn check_resolver_change(ws: &Workspace<'_>, opts: &FixOptions) -> CargoResult<(
245245
let mut target_data =
246246
RustcTargetData::new(ws, &opts.compile_opts.build_config.requested_kinds)?;
247247
let mut resolve_differences = |has_dev_units| -> CargoResult<(WorkspaceResolve<'_>, DiffMap)> {
248-
let max_rust_version = ws.rust_version();
249-
250248
let ws_resolve = ops::resolve_ws_with_opts(
251249
ws,
252250
&mut target_data,
@@ -255,7 +253,6 @@ fn check_resolver_change(ws: &Workspace<'_>, opts: &FixOptions) -> CargoResult<(
255253
&specs,
256254
has_dev_units,
257255
crate::core::resolver::features::ForceAllTargets::No,
258-
max_rust_version,
259256
)?;
260257

261258
let feature_opts = FeatureOpts::new_behavior(ResolveBehavior::V2, has_dev_units);

src/cargo/ops/resolve.rs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ use crate::util::cache_lock::CacheLockMode;
7373
use crate::util::errors::CargoResult;
7474
use crate::util::{profile, CanonicalUrl};
7575
use anyhow::Context as _;
76-
use cargo_util_schemas::manifest::RustVersion;
7776
use std::collections::{HashMap, HashSet};
7877
use tracing::{debug, trace};
7978

@@ -109,10 +108,8 @@ version. This may also occur with an optional dependency that is not enabled.";
109108
/// This is a simple interface used by commands like `clean`, `fetch`, and
110109
/// `package`, which don't specify any options or features.
111110
pub fn resolve_ws<'a>(ws: &Workspace<'a>) -> CargoResult<(PackageSet<'a>, Resolve)> {
112-
let max_rust_version = ws.rust_version();
113-
114111
let mut registry = PackageRegistry::new(ws.config())?;
115-
let resolve = resolve_with_registry(ws, &mut registry, max_rust_version)?;
112+
let resolve = resolve_with_registry(ws, &mut registry)?;
116113
let packages = get_resolved_packages(&resolve, registry)?;
117114
Ok((packages, resolve))
118115
}
@@ -135,7 +132,6 @@ pub fn resolve_ws_with_opts<'cfg>(
135132
specs: &[PackageIdSpec],
136133
has_dev_units: HasDevUnits,
137134
force_all_targets: ForceAllTargets,
138-
max_rust_version: Option<&RustVersion>,
139135
) -> CargoResult<WorkspaceResolve<'cfg>> {
140136
let mut registry = PackageRegistry::new(ws.config())?;
141137
let mut add_patches = true;
@@ -144,7 +140,7 @@ pub fn resolve_ws_with_opts<'cfg>(
144140
} else if ws.require_optional_deps() {
145141
// First, resolve the root_package's *listed* dependencies, as well as
146142
// downloading and updating all remotes and such.
147-
let resolve = resolve_with_registry(ws, &mut registry, max_rust_version)?;
143+
let resolve = resolve_with_registry(ws, &mut registry)?;
148144
// No need to add patches again, `resolve_with_registry` has done it.
149145
add_patches = false;
150146

@@ -190,7 +186,6 @@ pub fn resolve_ws_with_opts<'cfg>(
190186
None,
191187
specs,
192188
add_patches,
193-
max_rust_version,
194189
)?;
195190

196191
let pkg_set = get_resolved_packages(&resolved_with_overrides, registry)?;
@@ -242,7 +237,6 @@ pub fn resolve_ws_with_opts<'cfg>(
242237
fn resolve_with_registry<'cfg>(
243238
ws: &Workspace<'cfg>,
244239
registry: &mut PackageRegistry<'cfg>,
245-
max_rust_version: Option<&RustVersion>,
246240
) -> CargoResult<Resolve> {
247241
let prev = ops::load_pkg_lockfile(ws)?;
248242
let mut resolve = resolve_with_previous(
@@ -254,7 +248,6 @@ fn resolve_with_registry<'cfg>(
254248
None,
255249
&[],
256250
true,
257-
max_rust_version,
258251
)?;
259252

260253
if !ws.is_ephemeral() && ws.require_optional_deps() {
@@ -287,7 +280,6 @@ pub fn resolve_with_previous<'cfg>(
287280
to_avoid: Option<&HashSet<PackageId>>,
288281
specs: &[PackageIdSpec],
289282
register_patches: bool,
290-
max_rust_version: Option<&RustVersion>,
291283
) -> CargoResult<Resolve> {
292284
// We only want one Cargo at a time resolving a crate graph since this can
293285
// involve a lot of frobbing of the global caches.
@@ -326,7 +318,7 @@ pub fn resolve_with_previous<'cfg>(
326318
version_prefs.version_ordering(VersionOrdering::MinimumVersionsFirst)
327319
}
328320
if ws.config().cli_unstable().msrv_policy {
329-
version_prefs.max_rust_version(max_rust_version.cloned());
321+
version_prefs.max_rust_version(ws.rust_version().cloned());
330322
}
331323

332324
// This is a set of PackageIds of `[patch]` entries, and some related locked PackageIds, for

src/cargo/ops/tree/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ pub fn build_and_print(ws: &Workspace<'_>, opts: &TreeOptions) -> CargoResult<()
150150
} else {
151151
ForceAllTargets::No
152152
};
153-
let max_rust_version = ws.rust_version();
154153
let ws_resolve = ops::resolve_ws_with_opts(
155154
ws,
156155
&mut target_data,
@@ -159,7 +158,6 @@ pub fn build_and_print(ws: &Workspace<'_>, opts: &TreeOptions) -> CargoResult<()
159158
&specs,
160159
has_dev,
161160
force_all,
162-
max_rust_version,
163161
)?;
164162

165163
let package_map: HashMap<PackageId, &Package> = ws_resolve

0 commit comments

Comments
 (0)