mirror of
https://github.com/rust-lang/cargo
synced 2024-08-27 19:29:21 +00:00
refactor: always get max rust-version
from workspace
This commit is contained in:
parent
63581b3fde
commit
10b8e7bdac
|
@ -31,7 +31,6 @@ fn do_resolve<'cfg>(config: &'cfg Config, ws_root: &Path) -> ResolveInfo<'cfg> {
|
|||
let specs = pkgs.to_package_id_specs(&ws).unwrap();
|
||||
let has_dev_units = HasDevUnits::Yes;
|
||||
let force_all_targets = ForceAllTargets::No;
|
||||
let max_rust_version = None;
|
||||
// Do an initial run to download anything necessary so that it does
|
||||
// not confuse criterion's warmup.
|
||||
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> {
|
|||
&specs,
|
||||
has_dev_units,
|
||||
force_all_targets,
|
||||
max_rust_version,
|
||||
)
|
||||
.unwrap();
|
||||
ResolveInfo {
|
||||
|
@ -84,7 +82,6 @@ fn resolve_ws(c: &mut Criterion) {
|
|||
force_all_targets,
|
||||
..
|
||||
} = lazy_info.get_or_insert_with(|| do_resolve(&config, &ws_root));
|
||||
let max_rust_version = None;
|
||||
b.iter(|| {
|
||||
cargo::ops::resolve_ws_with_opts(
|
||||
ws,
|
||||
|
@ -94,7 +91,6 @@ fn resolve_ws(c: &mut Criterion) {
|
|||
specs,
|
||||
*has_dev_units,
|
||||
*force_all_targets,
|
||||
max_rust_version,
|
||||
)
|
||||
.unwrap();
|
||||
})
|
||||
|
|
|
@ -145,7 +145,6 @@ pub fn resolve_std<'cfg>(
|
|||
let cli_features = CliFeatures::from_command_line(
|
||||
&features, /*all_features*/ false, /*uses_default_features*/ false,
|
||||
)?;
|
||||
let max_rust_version = ws.rust_version();
|
||||
let resolve = ops::resolve_ws_with_opts(
|
||||
&std_ws,
|
||||
target_data,
|
||||
|
@ -154,7 +153,6 @@ pub fn resolve_std<'cfg>(
|
|||
&specs,
|
||||
HasDevUnits::No,
|
||||
crate::core::resolver::features::ForceAllTargets::No,
|
||||
max_rust_version,
|
||||
)?;
|
||||
Ok((
|
||||
resolve.pkg_set,
|
||||
|
|
|
@ -262,7 +262,6 @@ pub fn create_bcx<'a, 'cfg>(
|
|||
HasDevUnits::No
|
||||
}
|
||||
};
|
||||
let max_rust_version = ws.rust_version();
|
||||
let resolve = ops::resolve_ws_with_opts(
|
||||
ws,
|
||||
&mut target_data,
|
||||
|
@ -271,7 +270,6 @@ pub fn create_bcx<'a, 'cfg>(
|
|||
&specs,
|
||||
has_dev_units,
|
||||
crate::core::resolver::features::ForceAllTargets::No,
|
||||
max_rust_version,
|
||||
)?;
|
||||
let WorkspaceResolve {
|
||||
mut pkg_set,
|
||||
|
|
|
@ -26,7 +26,6 @@ pub struct UpdateOptions<'a> {
|
|||
|
||||
pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> {
|
||||
let mut registry = PackageRegistry::new(ws.config())?;
|
||||
let max_rust_version = ws.rust_version();
|
||||
let mut resolve = ops::resolve_with_previous(
|
||||
&mut registry,
|
||||
ws,
|
||||
|
@ -36,7 +35,6 @@ pub fn generate_lockfile(ws: &Workspace<'_>) -> CargoResult<()> {
|
|||
None,
|
||||
&[],
|
||||
true,
|
||||
max_rust_version,
|
||||
)?;
|
||||
ops::write_pkg_lockfile(ws, &mut resolve)?;
|
||||
Ok(())
|
||||
|
@ -57,8 +55,6 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
|
|||
.config()
|
||||
.acquire_package_cache_lock(CacheLockMode::DownloadExclusive)?;
|
||||
|
||||
let max_rust_version = ws.rust_version();
|
||||
|
||||
let previous_resolve = match ops::load_pkg_lockfile(ws)? {
|
||||
Some(resolve) => resolve,
|
||||
None => {
|
||||
|
@ -78,7 +74,6 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
|
|||
None,
|
||||
&[],
|
||||
true,
|
||||
max_rust_version,
|
||||
)?
|
||||
}
|
||||
}
|
||||
|
@ -157,7 +152,6 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
|
|||
Some(&to_avoid),
|
||||
&[],
|
||||
true,
|
||||
max_rust_version,
|
||||
)?;
|
||||
|
||||
// Summarize what is changing for the user.
|
||||
|
|
|
@ -140,8 +140,6 @@ fn build_resolve_graph(
|
|||
crate::core::resolver::features::ForceAllTargets::No
|
||||
};
|
||||
|
||||
let max_rust_version = ws.rust_version();
|
||||
|
||||
// Note that even with --filter-platform we end up downloading host dependencies as well,
|
||||
// as that is the behavior of download_accessible.
|
||||
let ws_resolve = ops::resolve_ws_with_opts(
|
||||
|
@ -152,7 +150,6 @@ fn build_resolve_graph(
|
|||
&specs,
|
||||
HasDevUnits::Yes,
|
||||
force_all,
|
||||
max_rust_version,
|
||||
)?;
|
||||
|
||||
let package_map: BTreeMap<PackageId, Package> = ws_resolve
|
||||
|
|
|
@ -461,8 +461,6 @@ fn build_lock(ws: &Workspace<'_>, orig_pkg: &Package) -> CargoResult<String> {
|
|||
to_real_manifest(toml_manifest, false, source_id, package_root, config)?;
|
||||
let new_pkg = Package::new(manifest, orig_pkg.manifest_path());
|
||||
|
||||
let max_rust_version = new_pkg.rust_version().cloned();
|
||||
|
||||
// Regenerate Cargo.lock using the old one as a guide.
|
||||
let tmp_ws = Workspace::ephemeral(new_pkg, ws.config(), None, true)?;
|
||||
let mut tmp_reg = PackageRegistry::new(ws.config())?;
|
||||
|
@ -475,7 +473,6 @@ fn build_lock(ws: &Workspace<'_>, orig_pkg: &Package) -> CargoResult<String> {
|
|||
None,
|
||||
&[],
|
||||
true,
|
||||
max_rust_version.as_ref(),
|
||||
)?;
|
||||
let pkg_set = ops::get_resolved_packages(&new_resolve, tmp_reg)?;
|
||||
|
||||
|
|
|
@ -245,8 +245,6 @@ fn check_resolver_change(ws: &Workspace<'_>, opts: &FixOptions) -> CargoResult<(
|
|||
let mut target_data =
|
||||
RustcTargetData::new(ws, &opts.compile_opts.build_config.requested_kinds)?;
|
||||
let mut resolve_differences = |has_dev_units| -> CargoResult<(WorkspaceResolve<'_>, DiffMap)> {
|
||||
let max_rust_version = ws.rust_version();
|
||||
|
||||
let ws_resolve = ops::resolve_ws_with_opts(
|
||||
ws,
|
||||
&mut target_data,
|
||||
|
@ -255,7 +253,6 @@ fn check_resolver_change(ws: &Workspace<'_>, opts: &FixOptions) -> CargoResult<(
|
|||
&specs,
|
||||
has_dev_units,
|
||||
crate::core::resolver::features::ForceAllTargets::No,
|
||||
max_rust_version,
|
||||
)?;
|
||||
|
||||
let feature_opts = FeatureOpts::new_behavior(ResolveBehavior::V2, has_dev_units);
|
||||
|
|
|
@ -73,7 +73,6 @@ use crate::util::cache_lock::CacheLockMode;
|
|||
use crate::util::errors::CargoResult;
|
||||
use crate::util::{profile, CanonicalUrl};
|
||||
use anyhow::Context as _;
|
||||
use cargo_util_schemas::manifest::RustVersion;
|
||||
use std::collections::{HashMap, HashSet};
|
||||
use tracing::{debug, trace};
|
||||
|
||||
|
@ -109,10 +108,8 @@ version. This may also occur with an optional dependency that is not enabled.";
|
|||
/// This is a simple interface used by commands like `clean`, `fetch`, and
|
||||
/// `package`, which don't specify any options or features.
|
||||
pub fn resolve_ws<'a>(ws: &Workspace<'a>) -> CargoResult<(PackageSet<'a>, Resolve)> {
|
||||
let max_rust_version = ws.rust_version();
|
||||
|
||||
let mut registry = PackageRegistry::new(ws.config())?;
|
||||
let resolve = resolve_with_registry(ws, &mut registry, max_rust_version)?;
|
||||
let resolve = resolve_with_registry(ws, &mut registry)?;
|
||||
let packages = get_resolved_packages(&resolve, registry)?;
|
||||
Ok((packages, resolve))
|
||||
}
|
||||
|
@ -135,7 +132,6 @@ pub fn resolve_ws_with_opts<'cfg>(
|
|||
specs: &[PackageIdSpec],
|
||||
has_dev_units: HasDevUnits,
|
||||
force_all_targets: ForceAllTargets,
|
||||
max_rust_version: Option<&RustVersion>,
|
||||
) -> CargoResult<WorkspaceResolve<'cfg>> {
|
||||
let mut registry = PackageRegistry::new(ws.config())?;
|
||||
let mut add_patches = true;
|
||||
|
@ -144,7 +140,7 @@ pub fn resolve_ws_with_opts<'cfg>(
|
|||
} else if ws.require_optional_deps() {
|
||||
// First, resolve the root_package's *listed* dependencies, as well as
|
||||
// downloading and updating all remotes and such.
|
||||
let resolve = resolve_with_registry(ws, &mut registry, max_rust_version)?;
|
||||
let resolve = resolve_with_registry(ws, &mut registry)?;
|
||||
// No need to add patches again, `resolve_with_registry` has done it.
|
||||
add_patches = false;
|
||||
|
||||
|
@ -190,7 +186,6 @@ pub fn resolve_ws_with_opts<'cfg>(
|
|||
None,
|
||||
specs,
|
||||
add_patches,
|
||||
max_rust_version,
|
||||
)?;
|
||||
|
||||
let pkg_set = get_resolved_packages(&resolved_with_overrides, registry)?;
|
||||
|
@ -242,7 +237,6 @@ pub fn resolve_ws_with_opts<'cfg>(
|
|||
fn resolve_with_registry<'cfg>(
|
||||
ws: &Workspace<'cfg>,
|
||||
registry: &mut PackageRegistry<'cfg>,
|
||||
max_rust_version: Option<&RustVersion>,
|
||||
) -> CargoResult<Resolve> {
|
||||
let prev = ops::load_pkg_lockfile(ws)?;
|
||||
let mut resolve = resolve_with_previous(
|
||||
|
@ -254,7 +248,6 @@ fn resolve_with_registry<'cfg>(
|
|||
None,
|
||||
&[],
|
||||
true,
|
||||
max_rust_version,
|
||||
)?;
|
||||
|
||||
if !ws.is_ephemeral() && ws.require_optional_deps() {
|
||||
|
@ -287,7 +280,6 @@ pub fn resolve_with_previous<'cfg>(
|
|||
to_avoid: Option<&HashSet<PackageId>>,
|
||||
specs: &[PackageIdSpec],
|
||||
register_patches: bool,
|
||||
max_rust_version: Option<&RustVersion>,
|
||||
) -> CargoResult<Resolve> {
|
||||
// We only want one Cargo at a time resolving a crate graph since this can
|
||||
// involve a lot of frobbing of the global caches.
|
||||
|
@ -326,7 +318,7 @@ pub fn resolve_with_previous<'cfg>(
|
|||
version_prefs.version_ordering(VersionOrdering::MinimumVersionsFirst)
|
||||
}
|
||||
if ws.config().cli_unstable().msrv_policy {
|
||||
version_prefs.max_rust_version(max_rust_version.cloned());
|
||||
version_prefs.max_rust_version(ws.rust_version().cloned());
|
||||
}
|
||||
|
||||
// This is a set of PackageIds of `[patch]` entries, and some related locked PackageIds, for
|
||||
|
|
|
@ -150,7 +150,6 @@ pub fn build_and_print(ws: &Workspace<'_>, opts: &TreeOptions) -> CargoResult<()
|
|||
} else {
|
||||
ForceAllTargets::No
|
||||
};
|
||||
let max_rust_version = ws.rust_version();
|
||||
let ws_resolve = ops::resolve_ws_with_opts(
|
||||
ws,
|
||||
&mut target_data,
|
||||
|
@ -159,7 +158,6 @@ pub fn build_and_print(ws: &Workspace<'_>, opts: &TreeOptions) -> CargoResult<()
|
|||
&specs,
|
||||
has_dev,
|
||||
force_all,
|
||||
max_rust_version,
|
||||
)?;
|
||||
|
||||
let package_map: HashMap<PackageId, &Package> = ws_resolve
|
||||
|
|
Loading…
Reference in a new issue