mirror of
https://github.com/rust-lang/cargo.git
synced 2025-10-01 11:30:39 +00:00
Introduce -Zprecise-pre-release
unstable flag
This change introduces the feature but does not yet attempt an implementation. The actual implementation will happen in future PRs r? @epage
This commit is contained in:
parent
4eef543a4d
commit
c8ec94c765
@ -779,6 +779,7 @@ unstable_cli_options!(
|
|||||||
next_lockfile_bump: bool,
|
next_lockfile_bump: bool,
|
||||||
no_index_update: bool = ("Do not update the registry index even if the cache is outdated"),
|
no_index_update: bool = ("Do not update the registry index even if the cache is outdated"),
|
||||||
panic_abort_tests: bool = ("Enable support to run tests with -Cpanic=abort"),
|
panic_abort_tests: bool = ("Enable support to run tests with -Cpanic=abort"),
|
||||||
|
precise_pre_release: bool = ("Enable pre-release versions to be selected with `update --precise`"),
|
||||||
profile_rustflags: bool = ("Enable the `rustflags` option in profiles in .cargo/config.toml file"),
|
profile_rustflags: bool = ("Enable the `rustflags` option in profiles in .cargo/config.toml file"),
|
||||||
publish_timeout: bool = ("Enable the `publish.timeout` key in .cargo/config.toml file"),
|
publish_timeout: bool = ("Enable the `publish.timeout` key in .cargo/config.toml file"),
|
||||||
rustdoc_map: bool = ("Allow passing external documentation mappings to rustdoc"),
|
rustdoc_map: bool = ("Allow passing external documentation mappings to rustdoc"),
|
||||||
@ -1125,6 +1126,7 @@ impl CliUnstable {
|
|||||||
"no-index-update" => self.no_index_update = parse_empty(k, v)?,
|
"no-index-update" => self.no_index_update = parse_empty(k, v)?,
|
||||||
"panic-abort-tests" => self.panic_abort_tests = parse_empty(k, v)?,
|
"panic-abort-tests" => self.panic_abort_tests = parse_empty(k, v)?,
|
||||||
"profile-rustflags" => self.profile_rustflags = parse_empty(k, v)?,
|
"profile-rustflags" => self.profile_rustflags = parse_empty(k, v)?,
|
||||||
|
"precise-pre-release" => self.precise_pre_release = parse_empty(k, v)?,
|
||||||
"trim-paths" => self.trim_paths = parse_empty(k, v)?,
|
"trim-paths" => self.trim_paths = parse_empty(k, v)?,
|
||||||
"publish-timeout" => self.publish_timeout = parse_empty(k, v)?,
|
"publish-timeout" => self.publish_timeout = parse_empty(k, v)?,
|
||||||
"rustdoc-map" => self.rustdoc_map = parse_empty(k, v)?,
|
"rustdoc-map" => self.rustdoc_map = parse_empty(k, v)?,
|
||||||
|
@ -72,6 +72,7 @@ For the latest nightly, see the [nightly version] of this page.
|
|||||||
* [direct-minimal-versions](#direct-minimal-versions) — Forces the resolver to use the lowest compatible version instead of the highest.
|
* [direct-minimal-versions](#direct-minimal-versions) — Forces the resolver to use the lowest compatible version instead of the highest.
|
||||||
* [public-dependency](#public-dependency) --- Allows dependencies to be classified as either public or private.
|
* [public-dependency](#public-dependency) --- Allows dependencies to be classified as either public or private.
|
||||||
* [msrv-policy](#msrv-policy) --- MSRV-aware resolver and version selection
|
* [msrv-policy](#msrv-policy) --- MSRV-aware resolver and version selection
|
||||||
|
* [precise-pre-release](#precise-pre-release) --- Allows pre-release versions to be selected with `update --precise`
|
||||||
* Output behavior
|
* Output behavior
|
||||||
* [out-dir](#out-dir) --- Adds a directory where artifacts are copied to.
|
* [out-dir](#out-dir) --- Adds a directory where artifacts are copied to.
|
||||||
* [Different binary name](#different-binary-name) --- Assign a name to the built binary that is separate from the crate name.
|
* [Different binary name](#different-binary-name) --- Assign a name to the built binary that is separate from the crate name.
|
||||||
@ -315,6 +316,25 @@ Documentation updates:
|
|||||||
The `msrv-policy` feature enables experiments in MSRV-aware policy for cargo in
|
The `msrv-policy` feature enables experiments in MSRV-aware policy for cargo in
|
||||||
preparation for an upcoming RFC.
|
preparation for an upcoming RFC.
|
||||||
|
|
||||||
|
## precise-pre-release
|
||||||
|
|
||||||
|
* Tracking Issue: [#13290](https://github.com/rust-lang/rust/issues/13290)
|
||||||
|
* RFC: [#3493](https://github.com/rust-lang/rfcs/pull/3493)
|
||||||
|
|
||||||
|
The `precise-pre-release` feature allows pre-release versions to be selected with `update --precise`
|
||||||
|
even when a pre-release is not specified by a projects `Cargo.toml`.
|
||||||
|
|
||||||
|
Take for example this `Cargo.toml`.
|
||||||
|
|
||||||
|
```toml
|
||||||
|
[dependencies]
|
||||||
|
my-dependency = "0.1.1"
|
||||||
|
```
|
||||||
|
|
||||||
|
It's possible to update `my-dependancy` to a pre-release with `update -Zprecise-pre-release -p my-dependency --precise 0.1.2-pre.0`.
|
||||||
|
This is because `0.1.2-pre.0` is considered compatible with `0.1.1`.
|
||||||
|
It would not be possible to upgrade to `0.2.0-pre.0` from `0.1.1` in the same way.
|
||||||
|
|
||||||
## build-std
|
## build-std
|
||||||
* Tracking Repository: <https://github.com/rust-lang/wg-cargo-std-aware>
|
* Tracking Repository: <https://github.com/rust-lang/wg-cargo-std-aware>
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ Available unstable (nightly-only) flags:
|
|||||||
-Z mtime-on-use Configure Cargo to update the mtime of used files
|
-Z mtime-on-use Configure Cargo to update the mtime of used files
|
||||||
-Z no-index-update Do not update the registry index even if the cache is outdated
|
-Z no-index-update Do not update the registry index even if the cache is outdated
|
||||||
-Z panic-abort-tests Enable support to run tests with -Cpanic=abort
|
-Z panic-abort-tests Enable support to run tests with -Cpanic=abort
|
||||||
|
-Z precise-pre-release Enable pre-release versions to be selected with `update --precise`
|
||||||
-Z profile-rustflags Enable the `rustflags` option in profiles in .cargo/config.toml file
|
-Z profile-rustflags Enable the `rustflags` option in profiles in .cargo/config.toml file
|
||||||
-Z publish-timeout Enable the `publish.timeout` key in .cargo/config.toml file
|
-Z publish-timeout Enable the `publish.timeout` key in .cargo/config.toml file
|
||||||
-Z rustdoc-map Allow passing external documentation mappings to rustdoc
|
-Z rustdoc-map Allow passing external documentation mappings to rustdoc
|
||||||
|
@ -134,6 +134,7 @@ mod patch;
|
|||||||
mod path;
|
mod path;
|
||||||
mod paths;
|
mod paths;
|
||||||
mod pkgid;
|
mod pkgid;
|
||||||
|
mod precise_pre_release;
|
||||||
mod proc_macro;
|
mod proc_macro;
|
||||||
mod profile_config;
|
mod profile_config;
|
||||||
mod profile_custom;
|
mod profile_custom;
|
||||||
|
60
tests/testsuite/precise_pre_release.rs
Normal file
60
tests/testsuite/precise_pre_release.rs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
//! Tests for selecting pre-release versions with `update --precise`.
|
||||||
|
|
||||||
|
use cargo_test_support::project;
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn requires_nightly_cargo() {
|
||||||
|
cargo_test_support::registry::init();
|
||||||
|
|
||||||
|
for version in ["0.1.1", "0.1.2-pre.0"] {
|
||||||
|
cargo_test_support::registry::Package::new("my-dependency", version).publish();
|
||||||
|
}
|
||||||
|
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "package"
|
||||||
|
[dependencies]
|
||||||
|
my-dependency = "0.1.1"
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/lib.rs", "")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("update -p my-dependency --precise 0.1.2-pre.0")
|
||||||
|
.with_status(101)
|
||||||
|
// This error is suffering from #12579 but still demonstrates that updating to
|
||||||
|
// a pre-release does not work on stable
|
||||||
|
.with_stderr(
|
||||||
|
r#"[UPDATING] `dummy-registry` index
|
||||||
|
[ERROR] failed to select a version for the requirement `my-dependency = "^0.1.1"`
|
||||||
|
candidate versions found which didn't match: 0.1.2-pre.0
|
||||||
|
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
|
||||||
|
required by package `package v0.0.0 ([ROOT]/foo)`
|
||||||
|
if you are looking for the prerelease package it needs to be specified explicitly
|
||||||
|
my-dependency = { version = "0.1.2-pre.0" }
|
||||||
|
perhaps a crate was updated and forgotten to be re-vendored?"#,
|
||||||
|
)
|
||||||
|
.run()
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cargo_test]
|
||||||
|
fn feature_exists() {
|
||||||
|
let p = project()
|
||||||
|
.file(
|
||||||
|
"Cargo.toml",
|
||||||
|
r#"
|
||||||
|
[package]
|
||||||
|
name = "package"
|
||||||
|
"#,
|
||||||
|
)
|
||||||
|
.file("src/lib.rs", "")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
p.cargo("-Zprecise-pre-release update")
|
||||||
|
.masquerade_as_nightly_cargo(&["precise-pre-release"])
|
||||||
|
.with_stderr("")
|
||||||
|
.run()
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user