mirror of https://github.com/rust-lang/cargo
feat(reslve): Respect '--ignore-rust-version'
This commit is contained in:
parent
11448b44fe
commit
cd3d31b361
|
@ -100,6 +100,7 @@ pub struct Workspace<'gctx> {
|
|||
|
||||
/// The resolver behavior specified with the `resolver` field.
|
||||
resolve_behavior: ResolveBehavior,
|
||||
honor_rust_version: Option<bool>,
|
||||
|
||||
/// Workspace-level custom metadata
|
||||
custom_metadata: Option<toml::Value>,
|
||||
|
@ -229,6 +230,7 @@ impl<'gctx> Workspace<'gctx> {
|
|||
loaded_packages: RefCell::new(HashMap::new()),
|
||||
ignore_lock: false,
|
||||
resolve_behavior: ResolveBehavior::V1,
|
||||
honor_rust_version: None,
|
||||
custom_metadata: None,
|
||||
}
|
||||
}
|
||||
|
@ -605,8 +607,12 @@ impl<'gctx> Workspace<'gctx> {
|
|||
self.members().filter_map(|pkg| pkg.rust_version()).min()
|
||||
}
|
||||
|
||||
pub fn set_honor_rust_version(&mut self, honor_rust_version: Option<bool>) {
|
||||
self.honor_rust_version = honor_rust_version;
|
||||
}
|
||||
|
||||
pub fn resolve_honors_rust_version(&self) -> bool {
|
||||
self.gctx().cli_unstable().msrv_policy
|
||||
self.gctx().cli_unstable().msrv_policy && self.honor_rust_version.unwrap_or(true)
|
||||
}
|
||||
|
||||
pub fn custom_metadata(&self) -> Option<&toml::Value> {
|
||||
|
|
|
@ -504,6 +504,7 @@ pub trait ArgMatchesExt {
|
|||
fn workspace<'a>(&self, gctx: &'a GlobalContext) -> CargoResult<Workspace<'a>> {
|
||||
let root = self.root_manifest(gctx)?;
|
||||
let mut ws = Workspace::new(&root, gctx)?;
|
||||
ws.set_honor_rust_version(self.honor_rust_version());
|
||||
if gctx.cli_unstable().avoid_dev_deps {
|
||||
ws.set_require_optional_deps(false);
|
||||
}
|
||||
|
|
|
@ -347,15 +347,13 @@ fn dependency_rust_version_older_and_newer_than_package() {
|
|||
p.cargo("check --ignore-rust-version")
|
||||
.arg("-Zmsrv-policy")
|
||||
.masquerade_as_nightly_cargo(&["msrv-policy"])
|
||||
// This should pick 1.6.0
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] `dummy-registry` index
|
||||
[LOCKING] 2 packages
|
||||
[ADDING] bar v1.5.0 (latest: v1.6.0)
|
||||
[DOWNLOADING] crates ...
|
||||
[DOWNLOADED] bar v1.5.0 (registry `dummy-registry`)
|
||||
[CHECKING] bar v1.5.0
|
||||
[DOWNLOADED] bar v1.6.0 (registry `dummy-registry`)
|
||||
[CHECKING] bar v1.6.0
|
||||
[CHECKING] [..]
|
||||
[FINISHED] [..]
|
||||
",
|
||||
|
@ -483,15 +481,13 @@ fn workspace_with_mixed_rust_version() {
|
|||
p.cargo("check --ignore-rust-version")
|
||||
.arg("-Zmsrv-policy")
|
||||
.masquerade_as_nightly_cargo(&["msrv-policy"])
|
||||
// This should pick 1.6.0
|
||||
.with_stderr(
|
||||
"\
|
||||
[UPDATING] `dummy-registry` index
|
||||
[LOCKING] 3 packages
|
||||
[ADDING] bar v1.4.0 (latest: v1.6.0)
|
||||
[DOWNLOADING] crates ...
|
||||
[DOWNLOADED] bar v1.4.0 (registry `dummy-registry`)
|
||||
[CHECKING] bar v1.4.0
|
||||
[DOWNLOADED] bar v1.6.0 (registry `dummy-registry`)
|
||||
[CHECKING] bar v1.6.0
|
||||
[CHECKING] [..]
|
||||
[FINISHED] [..]
|
||||
",
|
||||
|
|
Loading…
Reference in New Issue