mirror of
https://github.com/rust-lang/cargo.git
synced 2025-09-28 11:20:36 +00:00
refactor: Track when MSRV is explicitly set, either way
This will hopefully help when merging between CLI and config with #13540.
This commit is contained in:
parent
bd1cf584af
commit
2e75d66c7c
@ -205,8 +205,7 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
|
||||
|
||||
let dependencies = parse_dependencies(gctx, args)?;
|
||||
|
||||
let ignore_rust_version = args.flag("ignore-rust-version");
|
||||
let honor_rust_version = !ignore_rust_version;
|
||||
let honor_rust_version = args.honor_rust_version();
|
||||
|
||||
let options = AddOptions {
|
||||
gctx,
|
||||
|
@ -55,7 +55,7 @@ pub struct AddOptions<'a> {
|
||||
/// Act as if dependencies will be added
|
||||
pub dry_run: bool,
|
||||
/// Whether the minimum supported Rust version should be considered during resolution
|
||||
pub honor_rust_version: bool,
|
||||
pub honor_rust_version: Option<bool>,
|
||||
}
|
||||
|
||||
/// Add dependencies to a manifest
|
||||
@ -288,7 +288,7 @@ fn resolve_dependency(
|
||||
ws: &Workspace<'_>,
|
||||
spec: &Package,
|
||||
section: &DepTable,
|
||||
honor_rust_version: bool,
|
||||
honor_rust_version: Option<bool>,
|
||||
gctx: &GlobalContext,
|
||||
registry: &mut PackageRegistry<'_>,
|
||||
) -> CargoResult<DependencyUI> {
|
||||
@ -571,7 +571,7 @@ fn get_existing_dependency(
|
||||
fn get_latest_dependency(
|
||||
spec: &Package,
|
||||
dependency: &Dependency,
|
||||
honor_rust_version: bool,
|
||||
honor_rust_version: Option<bool>,
|
||||
gctx: &GlobalContext,
|
||||
registry: &mut PackageRegistry<'_>,
|
||||
) -> CargoResult<Dependency> {
|
||||
@ -608,7 +608,7 @@ fn get_latest_dependency(
|
||||
)
|
||||
})?;
|
||||
|
||||
if honor_rust_version {
|
||||
if honor_rust_version.unwrap_or(true) {
|
||||
let (req_msrv, is_msrv) = spec
|
||||
.rust_version()
|
||||
.cloned()
|
||||
|
@ -98,7 +98,7 @@ pub struct CompileOptions {
|
||||
pub rustdoc_document_private_items: bool,
|
||||
/// Whether the build process should check the minimum Rust version
|
||||
/// defined in the cargo metadata for a crate.
|
||||
pub honor_rust_version: bool,
|
||||
pub honor_rust_version: Option<bool>,
|
||||
}
|
||||
|
||||
impl CompileOptions {
|
||||
@ -116,7 +116,7 @@ impl CompileOptions {
|
||||
target_rustc_args: None,
|
||||
target_rustc_crate_types: None,
|
||||
rustdoc_document_private_items: false,
|
||||
honor_rust_version: true,
|
||||
honor_rust_version: None,
|
||||
})
|
||||
}
|
||||
}
|
||||
@ -474,7 +474,7 @@ pub fn create_bcx<'a, 'gctx>(
|
||||
.extend(args);
|
||||
}
|
||||
|
||||
if honor_rust_version {
|
||||
if honor_rust_version.unwrap_or(true) {
|
||||
let rustc_version = target_data.rustc.version.clone().into();
|
||||
|
||||
let mut incompatible = Vec::new();
|
||||
|
@ -624,7 +624,7 @@ pub fn install(
|
||||
let dst = root.join("bin").into_path_unlocked();
|
||||
let map = SourceConfigMap::new(gctx)?;
|
||||
|
||||
let current_rust_version = if opts.honor_rust_version {
|
||||
let current_rust_version = if opts.honor_rust_version.unwrap_or(true) {
|
||||
let rustc = gctx.load_global_rustc(None)?;
|
||||
Some(rustc.version.clone().into())
|
||||
} else {
|
||||
|
@ -933,7 +933,7 @@ fn run_verify(
|
||||
target_rustc_args: rustc_args,
|
||||
target_rustc_crate_types: None,
|
||||
rustdoc_document_private_items: false,
|
||||
honor_rust_version: true,
|
||||
honor_rust_version: None,
|
||||
},
|
||||
&exec,
|
||||
)?;
|
||||
|
@ -534,6 +534,10 @@ pub trait ArgMatchesExt {
|
||||
self.maybe_flag("keep-going")
|
||||
}
|
||||
|
||||
fn honor_rust_version(&self) -> Option<bool> {
|
||||
self.flag("ignore-rust-version").then_some(false)
|
||||
}
|
||||
|
||||
fn targets(&self) -> CargoResult<Vec<String>> {
|
||||
if self.is_present_with_zero_values("target") {
|
||||
let cmd = if is_rustup() {
|
||||
@ -763,7 +767,7 @@ Run `{cmd}` to see possible targets."
|
||||
target_rustc_args: None,
|
||||
target_rustc_crate_types: None,
|
||||
rustdoc_document_private_items: false,
|
||||
honor_rust_version: !self.flag("ignore-rust-version"),
|
||||
honor_rust_version: self.honor_rust_version(),
|
||||
};
|
||||
|
||||
if let Some(ws) = workspace {
|
||||
|
Loading…
x
Reference in New Issue
Block a user