Auto merge of #9732 - djc:rust-version-docs, r=ehuss

Stabilize the rust-version field

I've tried to make the documentation here fairly comprehensive. I've also updated the first version for the 2021 edition, which should now be stable pending substantial unforeseen changes.

See #8072.
This commit is contained in:
bors 2021-08-02 20:28:08 +00:00
commit cc17afbb00
44 changed files with 235 additions and 141 deletions

View file

@ -5,6 +5,8 @@
### Added
- Added support for the [`rust-version`](https://doc.rust-lang.org/nightly/cargo/reference/manifest.html#the-rust-version-field)
field in a crate's metadata and the `--ignore-rust-version` command line option.
- Build scripts can now pass additional linker arguments for binaries or all
linkable targets. [docs](https://doc.rust-lang.org/nightly/cargo/reference/build-scripts.html#outputs-of-the-build-script)
[#9557](https://github.com/rust-lang/cargo/pull/9557)

View file

@ -166,8 +166,7 @@ impl Edition {
match self {
Edition2015 => None,
Edition2018 => Some(semver::Version::new(1, 31, 0)),
// FIXME: This will likely be 1.56, update when that seems more likely.
Edition2021 => Some(semver::Version::new(1, 62, 0)),
Edition2021 => Some(semver::Version::new(1, 56, 0)),
}
}
@ -396,7 +395,7 @@ features! {
(unstable, strip, "", "reference/unstable.html#profile-strip-option"),
// Specifying a minimal 'rust-version' attribute for crates
(unstable, rust_version, "", "reference/unstable.html#rust-version"),
(stable, rust_version, "1.56", "reference/manifest.html#the-rust-version-field"),
// Support for 2021 edition.
(unstable, edition2021, "", "reference/unstable.html#edition-2021"),

View file

@ -218,7 +218,7 @@ pub trait AppExt: Sized {
fn arg_ignore_rust_version(self) -> Self {
self._arg(opt(
"ignore-rust-version",
"Ignore `rust-version` specification in packages (unstable)",
"Ignore `rust-version` specification in packages",
))
}
@ -533,12 +533,6 @@ pub trait ArgMatchesExt {
honor_rust_version: !self._is_present("ignore-rust-version"),
};
if !opts.honor_rust_version {
config
.cli_unstable()
.fail_if_stable_opt("--ignore-rust-version", 8072)?;
}
if let Some(ws) = workspace {
self.check_optional_opts(ws, &opts)?;
} else if self.is_present_with_zero_values("package") {

View file

@ -1122,46 +1122,25 @@ impl TomlManifest {
}
let rust_version = if let Some(rust_version) = &project.rust_version {
if features.require(Feature::rust_version()).is_err() {
let mut msg =
"`rust-version` is not supported on this version of Cargo and will be ignored"
.to_string();
if config.nightly_features_allowed {
msg.push_str(
"\n\n\
consider adding `cargo-features = [\"rust-version\"]` to the manifest",
);
} else {
msg.push_str(
"\n\n\
this Cargo does not support nightly features, but if you\n\
switch to nightly channel you can add\n\
`cargo-features = [\"rust-version\"]` to enable this feature",
);
let req = match semver::VersionReq::parse(rust_version) {
// Exclude semver operators like `^` and pre-release identifiers
Ok(req) if rust_version.chars().all(|c| c.is_ascii_digit() || c == '.') => req,
_ => bail!("`rust-version` must be a value like \"1.32\""),
};
if let Some(first_version) = edition.first_version() {
let unsupported =
semver::Version::new(first_version.major, first_version.minor - 1, 9999);
if req.matches(&unsupported) {
bail!(
"rust-version {} is older than first version ({}) required by \
the specified edition ({})",
rust_version,
first_version,
edition,
)
}
warnings.push(msg);
None
} else {
let req = match semver::VersionReq::parse(rust_version) {
// Exclude semver operators like `^` and pre-release identifiers
Ok(req) if rust_version.chars().all(|c| c.is_ascii_digit() || c == '.') => req,
_ => bail!("`rust-version` must be a value like \"1.32\""),
};
if let Some(first_version) = edition.first_version() {
let unsupported =
semver::Version::new(first_version.major, first_version.minor - 1, 9999);
if req.matches(&unsupported) {
bail!(
"rust-version {} is older than first version ({}) required by \
the specified edition ({})",
rust_version,
first_version,
edition,
)
}
}
Some(rust_version.clone())
}
Some(rust_version.clone())
} else {
None
};

View file

@ -83,6 +83,8 @@ target.
{{> options-target-triple }}
{{> options-ignore-rust-version }}
{{/options}}
### Output Options

View file

@ -35,6 +35,8 @@ they have `required-features` that are missing.
{{> options-release }}
{{> options-ignore-rust-version }}
{{/options}}
### Output Options

View file

@ -42,6 +42,8 @@ they have `required-features` that are missing.
{{> options-profile }}
{{> options-ignore-rust-version }}
{{/options}}
### Output Options

View file

@ -64,6 +64,8 @@ flag and will always document the given target.
{{> options-release }}
{{> options-ignore-rust-version }}
{{/options}}
### Output Options

View file

@ -122,6 +122,8 @@ When no target selection options are given, `cargo fix` will fix all targets
{{> options-profile }}
{{> options-ignore-rust-version }}
{{/options}}
### Output Options

View file

@ -50,6 +50,8 @@ Run the specified example.
{{> options-release }}
{{> options-ignore-rust-version }}
{{/options}}
### Output Options

View file

@ -47,6 +47,8 @@ binary and library targets of the selected package.
{{> options-release }}
{{> options-ignore-rust-version }}
{{/options}}
### Output Options

View file

@ -62,6 +62,8 @@ if its name is the same as the lib target. Binaries are skipped if they have
{{> options-release }}
{{> options-ignore-rust-version }}
{{/options}}
### Output Options

View file

@ -102,6 +102,8 @@ target options.
{{> options-release }}
{{> options-ignore-rust-version }}
{{/options}}
### Output Options

View file

@ -202,6 +202,11 @@ OPTIONS
<https://doc.rust-lang.org/cargo/guide/build-cache.html>
documentation for more details.
--ignore-rust-version
Benchmark the target even if the selected Rust compiler is older
than the required Rust version as configured in the project's
rust-version field.
Output Options
--target-dir directory
Directory for all generated artifacts and intermediate files. May

View file

@ -146,6 +146,11 @@ OPTIONS
Build optimized artifacts with the release profile. See the PROFILES
section for details on how this affects profile selection.
--ignore-rust-version
Build the target even if the selected Rust compiler is older than
the required Rust version as configured in the project's
rust-version field.
Output Options
--target-dir directory
Directory for all generated artifacts and intermediate files. May

View file

@ -158,6 +158,11 @@ OPTIONS
have it check unit tests which are usually excluded via the cfg
attribute. This does not change the actual profile used.
--ignore-rust-version
Check the target even if the selected Rust compiler is older than
the required Rust version as configured in the project's
rust-version field.
Output Options
--target-dir directory
Directory for all generated artifacts and intermediate files. May

View file

@ -123,6 +123,11 @@ OPTIONS
Document optimized artifacts with the release profile. See the
PROFILES section for details on how this affects profile selection.
--ignore-rust-version
Document the target even if the selected Rust compiler is older than
the required Rust version as configured in the project's
rust-version field.
Output Options
--target-dir directory
Directory for all generated artifacts and intermediate files. May

View file

@ -231,6 +231,11 @@ OPTIONS
it fix unit tests which are usually excluded via the cfg attribute.
This does not change the actual profile used.
--ignore-rust-version
Fix the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's rust-version
field.
Output Options
--target-dir directory
Directory for all generated artifacts and intermediate files. May

View file

@ -75,6 +75,11 @@ OPTIONS
Run optimized artifacts with the release profile. See the PROFILES
section for details on how this affects profile selection.
--ignore-rust-version
Run the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's rust-version
field.
Output Options
--target-dir directory
Directory for all generated artifacts and intermediate files. May

View file

@ -137,6 +137,11 @@ OPTIONS
Build optimized artifacts with the release profile. See the PROFILES
section for details on how this affects profile selection.
--ignore-rust-version
Build the target even if the selected Rust compiler is older than
the required Rust version as configured in the project's
rust-version field.
Output Options
--target-dir directory
Directory for all generated artifacts and intermediate files. May

View file

@ -146,6 +146,11 @@ OPTIONS
Document optimized artifacts with the release profile. See the
PROFILES section for details on how this affects profile selection.
--ignore-rust-version
Document the target even if the selected Rust compiler is older than
the required Rust version as configured in the project's
rust-version field.
Output Options
--target-dir directory
Directory for all generated artifacts and intermediate files. May

View file

@ -223,6 +223,11 @@ OPTIONS
Test optimized artifacts with the release profile. See the PROFILES
section for details on how this affects profile selection.
--ignore-rust-version
Test the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's rust-version
field.
Output Options
--target-dir directory
Directory for all generated artifacts and intermediate files. May

View file

@ -0,0 +1,4 @@
{{#option "`--ignore-rust-version`"}}
{{actionverb}} the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's `rust-version` field.
{{/option}}

View file

@ -245,6 +245,12 @@ target artifacts are placed in a separate directory. See the
<dt class="option-term" id="option-cargo-bench---ignore-rust-version"><a class="option-anchor" href="#option-cargo-bench---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
<dd class="option-desc">Benchmark the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's <code>rust-version</code> field.</dd>
</dl>
### Output Options

View file

@ -188,6 +188,12 @@ selection.</dd>
<dt class="option-term" id="option-cargo-build---ignore-rust-version"><a class="option-anchor" href="#option-cargo-build---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
<dd class="option-desc">Build the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's <code>rust-version</code> field.</dd>
</dl>
### Output Options

View file

@ -202,6 +202,12 @@ used.</dd>
<dt class="option-term" id="option-cargo-check---ignore-rust-version"><a class="option-anchor" href="#option-cargo-check---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
<dd class="option-desc">Check the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's <code>rust-version</code> field.</dd>
</dl>
### Output Options

View file

@ -161,6 +161,12 @@ selection.</dd>
<dt class="option-term" id="option-cargo-doc---ignore-rust-version"><a class="option-anchor" href="#option-cargo-doc---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
<dd class="option-desc">Document the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's <code>rust-version</code> field.</dd>
</dl>
### Output Options

View file

@ -282,6 +282,12 @@ used.</dd>
<dt class="option-term" id="option-cargo-fix---ignore-rust-version"><a class="option-anchor" href="#option-cargo-fix---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
<dd class="option-desc">Fix the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's <code>rust-version</code> field.</dd>
</dl>
### Output Options

View file

@ -106,6 +106,12 @@ selection.</dd>
<dt class="option-term" id="option-cargo-run---ignore-rust-version"><a class="option-anchor" href="#option-cargo-run---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
<dd class="option-desc">Run the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's <code>rust-version</code> field.</dd>
</dl>
### Output Options

View file

@ -175,6 +175,12 @@ selection.</dd>
<dt class="option-term" id="option-cargo-rustc---ignore-rust-version"><a class="option-anchor" href="#option-cargo-rustc---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
<dd class="option-desc">Build the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's <code>rust-version</code> field.</dd>
</dl>
### Output Options

View file

@ -190,6 +190,12 @@ selection.</dd>
<dt class="option-term" id="option-cargo-rustdoc---ignore-rust-version"><a class="option-anchor" href="#option-cargo-rustdoc---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
<dd class="option-desc">Document the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's <code>rust-version</code> field.</dd>
</dl>
### Output Options

View file

@ -269,6 +269,12 @@ selection.</dd>
<dt class="option-term" id="option-cargo-test---ignore-rust-version"><a class="option-anchor" href="#option-cargo-test---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
<dd class="option-desc">Test the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's <code>rust-version</code> field.</dd>
</dl>
### Output Options

View file

@ -9,6 +9,7 @@ in the [TOML] format. Every manifest file consists of the following sections:
* [`version`](#the-version-field) — The version of the package.
* [`authors`](#the-authors-field) — The authors of the package.
* [`edition`](#the-edition-field) — The Rust edition.
* [`rust-version`](#the-rust-version-field) — The minimal supported Rust version.
* [`description`](#the-description-field) — A description of the package.
* [`documentation`](#the-documentation-field) — URL of the package documentation.
* [`readme`](#the-readme-field) — Path to the package's README file.
@ -144,6 +145,33 @@ assumed for backwards compatibility. Note that all manifests
created with [`cargo new`] will not use this historical fallback because they
will have `edition` explicitly specified to a newer value.
#### The `rust-version` field
The `rust-version` field is an optional key that tells cargo what version of the
Rust language and compiler your package can be compiled with. If the currently
selected version of the Rust compiler is older than the stated version, cargo
will exit with an error, telling the user what version is required.
The first version of Cargo that supports this field was released with Rust 1.56.0.
In older releases, the field will be ignored, and Cargo will display a warning.
```toml
[package]
# ...
rust-version = "1.56"
```
The Rust version must be a bare version number with two or three components; it
cannot include semver operators or pre-release identifiers. Compiler pre-release
identifiers such as -nightly will be ignored while checking the Rust version.
The `rust-version` must be equal to or newer than the version that first
introduced the configured `edition`.
The `rust-version` may be ignored using the `--ignore-rust-version` option.
Setting the `rust-version` key in `[package]` will affect all targets/crates in
the package, including test suites, benchmarks, binaries, examples, etc.
#### The `description` field
The description is a short blurb about the package. [crates.io] will display

View file

@ -89,7 +89,6 @@ Each new feature described below should explain how to use it.
* [Custom named profiles](#custom-named-profiles) — Adds custom named profiles in addition to the standard names.
* [Profile `strip` option](#profile-strip-option) — Forces the removal of debug information and symbols from executables.
* [per-package-target](#per-package-target) — Sets the `--target` to use for each individual package.
* [rust-version](#rust-version) — Allows to declare the minimum supported Rust version.
* [Edition 2021](#edition-2021) — Adds support for the 2021 Edition.
* Information and metadata
* [Build-plan](#build-plan) — Emits JSON information on which commands will be run.
@ -1170,25 +1169,6 @@ cargo logout -Z credential-process
[crates.io]: https://crates.io/
[config file]: config.md
### rust-version
* RFC: [#2495](https://github.com/rust-lang/rfcs/blob/master/text/2495-min-rust-version.md)
* rustc Tracking Issue: [#65262](https://github.com/rust-lang/rust/issues/65262)
The `-Z rust-version` flag enables the reading of the `rust-version` field in the
Cargo manifest `package` section. This can be used by a package to state a minimal
version of the compiler required to build the package. An error is generated if
the version of rustc is older than the stated `rust-version`. The
`--ignore-rust-version` flag can be used to override the check.
```toml
cargo-features = ["rust-version"]
[package]
name = "mypackage"
version = "0.0.1"
rust-version = "1.42"
```
### edition 2021
* Tracking Issue: [rust-lang/rust#85811](https://github.com/rust-lang/rust/issues/85811)
@ -1420,3 +1400,9 @@ The `configurable-env` feature to specify environment variables in Cargo
configuration has been stabilized in the 1.56 release. See the [config
documentation](config.html#env) for more information about configuring
environment variables.
### rust-version
The `rust-version` field in `Cargo.toml` has been stabilized in the 1.56 release.
See the [rust-version field](manifest.html#the-rust-version-field) for more
information on using the `rust-version` field and the `--ignore-rust-version` option.

View file

@ -250,6 +250,12 @@ Note that specifying this flag makes Cargo run in a different mode where the
target artifacts are placed in a separate directory. See the
\fIbuild cache\fR <https://doc.rust\-lang.org/cargo/guide/build\-cache.html> documentation for more details.
.RE
.sp
\fB\-\-ignore\-rust\-version\fR
.RS 4
Benchmark the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's \fBrust\-version\fR field.
.RE
.SS "Output Options"
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR

View file

@ -175,6 +175,12 @@ Build optimized artifacts with the \fBrelease\fR profile. See the
PROFILES section for details on how this affects profile
selection.
.RE
.sp
\fB\-\-ignore\-rust\-version\fR
.RS 4
Build the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's \fBrust\-version\fR field.
.RE
.SS "Output Options"
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR

View file

@ -189,6 +189,12 @@ This is useful to have it check unit tests which are usually
excluded via the \fBcfg\fR attribute. This does not change the actual profile
used.
.RE
.sp
\fB\-\-ignore\-rust\-version\fR
.RS 4
Check the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's \fBrust\-version\fR field.
.RE
.SS "Output Options"
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR

View file

@ -142,6 +142,12 @@ Document optimized artifacts with the \fBrelease\fR profile. See the
PROFILES section for details on how this affects profile
selection.
.RE
.sp
\fB\-\-ignore\-rust\-version\fR
.RS 4
Document the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's \fBrust\-version\fR field.
.RE
.SS "Output Options"
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR

View file

@ -284,6 +284,12 @@ This is useful to have it fix unit tests which are usually
excluded via the \fBcfg\fR attribute. This does not change the actual profile
used.
.RE
.sp
\fB\-\-ignore\-rust\-version\fR
.RS 4
Fix the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's \fBrust\-version\fR field.
.RE
.SS "Output Options"
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR

View file

@ -86,6 +86,12 @@ Run optimized artifacts with the \fBrelease\fR profile. See the
PROFILES section for details on how this affects profile
selection.
.RE
.sp
\fB\-\-ignore\-rust\-version\fR
.RS 4
Run the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's \fBrust\-version\fR field.
.RE
.SS "Output Options"
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR

View file

@ -161,6 +161,12 @@ Build optimized artifacts with the \fBrelease\fR profile. See the
PROFILES section for details on how this affects profile
selection.
.RE
.sp
\fB\-\-ignore\-rust\-version\fR
.RS 4
Build the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's \fBrust\-version\fR field.
.RE
.SS "Output Options"
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR

View file

@ -172,6 +172,12 @@ Document optimized artifacts with the \fBrelease\fR profile. See the
PROFILES section for details on how this affects profile
selection.
.RE
.sp
\fB\-\-ignore\-rust\-version\fR
.RS 4
Document the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's \fBrust\-version\fR field.
.RE
.SS "Output Options"
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR

View file

@ -272,6 +272,12 @@ Test optimized artifacts with the \fBrelease\fR profile. See the
PROFILES section for details on how this affects profile
selection.
.RE
.sp
\fB\-\-ignore\-rust\-version\fR
.RS 4
Test the target even if the selected Rust compiler is older than the
required Rust version as configured in the project's \fBrust\-version\fR field.
.RE
.SS "Output Options"
.sp
\fB\-\-target\-dir\fR \fIdirectory\fR

View file

@ -2,58 +2,12 @@
use cargo_test_support::{project, registry::Package};
#[cargo_test]
fn rust_version_gated() {
project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
rust-version = "1.9999"
"#,
)
.file("src/lib.rs", "")
.build()
.cargo("build")
.masquerade_as_nightly_cargo()
.with_stderr_contains(
"warning: `rust-version` is not supported on this version of Cargo and will be ignored\
\n\nconsider adding `cargo-features = [\"rust-version\"]` to the manifest",
)
.run();
project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
rust-version = "1.9999"
"#,
)
.file("src/lib.rs", "")
.build()
.cargo("build")
.with_stderr_contains(
"warning: `rust-version` is not supported on this version of Cargo and will be ignored\
\n\nthis Cargo does not support nightly features, but if you\n\
switch to nightly channel you can add\n\
`cargo-features = [\"rust-version\"]` to enable this feature",
)
.run();
}
#[cargo_test]
fn rust_version_satisfied() {
let p = project()
.file(
"Cargo.toml",
r#"
cargo-features = ["rust-version"]
[project]
name = "foo"
version = "0.0.1"
@ -66,10 +20,8 @@ fn rust_version_satisfied() {
.file("src/main.rs", "fn main() {}")
.build();
p.cargo("build").masquerade_as_nightly_cargo().run();
p.cargo("build --ignore-rust-version -Zunstable-options")
.masquerade_as_nightly_cargo()
.run();
p.cargo("build").run();
p.cargo("build --ignore-rust-version").run();
}
#[cargo_test]
@ -78,8 +30,6 @@ fn rust_version_bad_caret() {
.file(
"Cargo.toml",
r#"
cargo-features = ["rust-version"]
[project]
name = "foo"
version = "0.0.1"
@ -92,7 +42,6 @@ fn rust_version_bad_caret() {
.file("src/main.rs", "fn main() {}")
.build()
.cargo("build")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr(
"error: failed to parse manifest at `[..]`\n\n\
@ -107,8 +56,6 @@ fn rust_version_bad_pre_release() {
.file(
"Cargo.toml",
r#"
cargo-features = ["rust-version"]
[project]
name = "foo"
version = "0.0.1"
@ -121,7 +68,6 @@ fn rust_version_bad_pre_release() {
.file("src/main.rs", "fn main() {}")
.build()
.cargo("build")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr(
"error: failed to parse manifest at `[..]`\n\n\
@ -136,8 +82,6 @@ fn rust_version_bad_nonsense() {
.file(
"Cargo.toml",
r#"
cargo-features = ["rust-version"]
[project]
name = "foo"
version = "0.0.1"
@ -150,7 +94,6 @@ fn rust_version_bad_nonsense() {
.file("src/main.rs", "fn main() {}")
.build()
.cargo("build")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr(
"error: failed to parse manifest at `[..]`\n\n\
@ -165,8 +108,6 @@ fn rust_version_too_high() {
.file(
"Cargo.toml",
r#"
cargo-features = ["rust-version"]
[project]
name = "foo"
version = "0.0.1"
@ -180,22 +121,18 @@ fn rust_version_too_high() {
.build();
p.cargo("build")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr(
"error: package `foo v0.0.1 ([..])` cannot be built because it requires \
rustc 1.9876.0 or newer, while the currently active rustc version is [..]",
)
.run();
p.cargo("build --ignore-rust-version -Zunstable-options")
.masquerade_as_nightly_cargo()
.run();
p.cargo("build --ignore-rust-version").run();
}
#[cargo_test]
fn rust_version_dependency_fails() {
Package::new("bar", "0.0.1")
.cargo_feature("rust-version")
.rust_version("1.2345.0")
.file("src/lib.rs", "fn other_stuff() {}")
.publish();
@ -216,7 +153,6 @@ fn rust_version_dependency_fails() {
.build();
p.cargo("build")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr(
" Updating `[..]` index\n \
@ -226,9 +162,7 @@ fn rust_version_dependency_fails() {
rustc 1.2345.0 or newer, while the currently active rustc version is [..]",
)
.run();
p.cargo("build --ignore-rust-version -Zunstable-options")
.masquerade_as_nightly_cargo()
.run();
p.cargo("build --ignore-rust-version").run();
}
#[cargo_test]
@ -237,8 +171,6 @@ fn rust_version_older_than_edition() {
.file(
"Cargo.toml",
r#"
cargo-features = ["rust-version"]
[project]
name = "foo"
version = "0.0.1"
@ -252,7 +184,6 @@ fn rust_version_older_than_edition() {
.file("src/main.rs", "fn main() {}")
.build()
.cargo("build")
.masquerade_as_nightly_cargo()
.with_status(101)
.with_stderr_contains(" rust-version 1.1 is older than first version (1.31.0) required by the specified edition (2018)",
)