Skip to content

Commit a260a4c

Browse files
committed
Improve Workspaces docs page
1 parent 686e3e8 commit a260a4c

File tree

13 files changed

+72
-35
lines changed

13 files changed

+72
-35
lines changed

src/bin/cargo/commands/add.rs

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ Example uses:
8787
- Depend on crates with the same name from different registries"),
8888
flag(
8989
"ignore-rust-version",
90-
"Ignore `rust-version` specification in packages (unstable)"
90+
"Ignore `rust-version` specification in packages"
9191
),
9292
])
9393
.arg_manifest_path_without_unsupported_path_tip()
@@ -206,14 +206,6 @@ pub fn exec(gctx: &mut GlobalContext, args: &ArgMatches) -> CliResult {
206206
let dependencies = parse_dependencies(gctx, args)?;
207207

208208
let ignore_rust_version = args.flag("ignore-rust-version");
209-
if ignore_rust_version && !gctx.cli_unstable().msrv_policy {
210-
return Err(CliError::new(
211-
anyhow::format_err!(
212-
"`--ignore-rust-version` is unstable; pass `-Zmsrv-policy` to enable support for it"
213-
),
214-
101,
215-
));
216-
}
217209
let honor_rust_version = !ignore_rust_version;
218210

219211
let options = AddOptions {

src/cargo/core/compiler/fingerprint/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1526,11 +1526,14 @@ See https://doc.rust-lang.org/cargo/reference/build-scripts.html#rerun-if-change
15261526
.collect::<CargoResult<Vec<_>>>()?
15271527
};
15281528

1529+
let rustflags = build_runner.bcx.rustflags_args(unit).to_vec();
1530+
15291531
Ok(Fingerprint {
15301532
local: Mutex::new(local),
15311533
rustc: util::hash_u64(&build_runner.bcx.rustc().verbose_version),
15321534
deps,
15331535
outputs: if overridden { Vec::new() } else { vec![output] },
1536+
rustflags,
15341537

15351538
// Most of the other info is blank here as we don't really include it
15361539
// in the execution of the build script, but... this may be a latent

src/cargo/ops/cargo_add/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,7 +608,7 @@ fn get_latest_dependency(
608608
)
609609
})?;
610610

611-
if gctx.cli_unstable().msrv_policy && honor_rust_version {
611+
if honor_rust_version {
612612
let (req_msrv, is_msrv) = spec
613613
.rust_version()
614614
.cloned()

src/doc/man/cargo-add.md

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,6 @@ which enables all specified features.
141141

142142
{{#option "`--ignore-rust-version`" }}
143143
Ignore `rust-version` specification in packages.
144-
145-
This option is unstable and available only on the
146-
[nightly channel](https://doc.rust-lang.org/book/appendix-07-nightly-rust.html)
147-
and requires the `-Z unstable-options` flag to enable.
148-
See <https://github.com/rust-lang/cargo/issues/5579> for more information.
149144
{{/option}}
150145

151146
{{/options}}

src/doc/man/generated_txt/cargo-add.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,6 @@ OPTIONS
131131
--ignore-rust-version
132132
Ignore rust-version specification in packages.
133133

134-
This option is unstable and available only on the nightly channel
135-
<https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
136-
requires the -Z unstable-options flag to enable. See
137-
<https://github.com/rust-lang/cargo/issues/5579> for more
138-
information.
139-
140134
Display Options
141135
-v, --verbose
142136
Use verbose output. May be specified twice for “very verbose”

src/doc/src/commands/cargo-add.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,7 @@ which enables all specified features.</dd>
137137

138138

139139
<dt class="option-term" id="option-cargo-add---ignore-rust-version"><a class="option-anchor" href="#option-cargo-add---ignore-rust-version"></a><code>--ignore-rust-version</code></dt>
140-
<dd class="option-desc">Ignore <code>rust-version</code> specification in packages.</p>
141-
<p>This option is unstable and available only on the
142-
<a href="https://doc.rust-lang.org/book/appendix-07-nightly-rust.html">nightly channel</a>
143-
and requires the <code>-Z unstable-options</code> flag to enable.
144-
See <a href="https://github.com/rust-lang/cargo/issues/5579">https://github.com/rust-lang/cargo/issues/5579</a> for more information.</dd>
140+
<dd class="option-desc">Ignore <code>rust-version</code> specification in packages.</dd>
145141

146142

147143
</dl>

src/doc/src/reference/unstable.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,6 @@ Documentation updates:
326326

327327
## msrv-policy
328328
- [#9930](https://github.com/rust-lang/cargo/issues/9930) (MSRV-aware resolver)
329-
- [#10653](https://github.com/rust-lang/cargo/issues/10653) (MSRV-aware cargo-add)
330-
- [#10903](https://github.com/rust-lang/cargo/issues/10903) (MSRV-aware cargo-install)
331329

332330
The `msrv-policy` feature enables experiments in MSRV-aware policy for cargo in
333331
preparation for an upcoming RFC.

src/doc/src/reference/workspaces.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ version = "0.1.0" # the current version, obeying semver
5757
authors = ["Alice <[email protected]>", "Bob <[email protected]>"]
5858
```
5959

60+
Unless explicitly set through [`workspace.default-members`](#the-default-members-field),
61+
the root package is considered as the only default member of the workspace.
62+
6063
### Virtual workspace
6164

6265
Alternatively, a `Cargo.toml` file can be created with a `[workspace]` section
@@ -80,6 +83,9 @@ edition = "2021" # the edition, will have no effect on a resolver used in th
8083
authors = ["Alice <[email protected]>", "Bob <[email protected]>"]
8184
```
8285

86+
Unless explicitly set through [`workspace.default-members`](#the-default-members-field),
87+
every member of a virtual workspace is considered as a default member.
88+
8389
Note that in a virtual manifest the [`resolver = "2"`](resolver.md#resolver-versions)
8490
should be specified manually. It is usually deduced from the [`package.edition`][package-edition]
8591
field which is absent in virtual manifests and the edition field of a member

src/etc/_cargo

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ _cargo() {
8787
'--path=[local filesystem path to crate to add]: :_directories' \
8888
'--rev=[specific commit to use when adding from git]:commit' \
8989
'--tag=[tag to use when adding from git]:tag' \
90+
'--ignore-rust-version[Ignore rust-version specification in packages]' \
9091
'1: :_guard "^-*" "crate name"' \
9192
'*:args:_default'
9293
;;

src/etc/cargo.bashcomp.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ _cargo()
4949
local opt_targets="--lib --bin --bins --example --examples --test --tests --bench --benches --all-targets"
5050

5151
local opt___nocmd="$opt_common -V --version --list --explain"
52-
local opt__add="$opt_common -p --package --features --default-features --no-default-features $opt_mani --optional --no-optional --rename --dry-run --path --git --branch --tag --rev --registry --dev --build --target"
52+
local opt__add="$opt_common -p --package --features --default-features --no-default-features $opt_mani --optional --no-optional --rename --dry-run --path --git --branch --tag --rev --registry --dev --build --target --ignore-rust-version"
5353
local opt__bench="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_jobs $opt_targets --message-format --target --no-run --no-fail-fast --target-dir --ignore-rust-version"
5454
local opt__build="$opt_common $opt_pkg_spec $opt_feat $opt_mani $opt_lock $opt_parallel $opt_targets --message-format --target --release --profile --target-dir --ignore-rust-version"
5555
local opt__b="$opt__build"

src/etc/man/cargo-add.1

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,11 +162,6 @@ which enables all specified features.
162162
\fB\-\-ignore\-rust\-version\fR
163163
.RS 4
164164
Ignore \fBrust\-version\fR specification in packages.
165-
.sp
166-
This option is unstable and available only on the
167-
\fInightly channel\fR <https://doc.rust\-lang.org/book/appendix\-07\-nightly\-rust.html>
168-
and requires the \fB\-Z unstable\-options\fR flag to enable.
169-
See <https://github.com/rust\-lang/cargo/issues/5579> for more information.
170165
.RE
171166
.SS "Display Options"
172167
.sp

tests/testsuite/build_script.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5537,3 +5537,60 @@ fn test_old_syntax_with_old_msrv() {
55375537
p.cargo("build -v").run();
55385538
p.cargo("run -v").with_stdout("foo\n").run();
55395539
}
5540+
5541+
#[cargo_test]
5542+
fn build_script_rerun_when_target_rustflags_change() {
5543+
let target = rustc_host();
5544+
let p = project()
5545+
.file(
5546+
"src/main.rs",
5547+
r#"
5548+
fn main() {
5549+
#[cfg(enable)]
5550+
println!("hello");
5551+
}
5552+
"#,
5553+
)
5554+
.file(
5555+
"build.rs",
5556+
r#"
5557+
use std::env;
5558+
5559+
fn main() {
5560+
if let Ok(rustflags) = env::var("CARGO_ENCODED_RUSTFLAGS") {
5561+
if !rustflags.is_empty() {
5562+
println!("cargo::rustc-cfg=enable")
5563+
}
5564+
}
5565+
}
5566+
"#,
5567+
)
5568+
.build();
5569+
5570+
p.cargo("run --target")
5571+
.arg(&target)
5572+
.with_stderr(
5573+
"\
5574+
[COMPILING] foo v0.0.1 ([..])
5575+
[FINISHED] [..]
5576+
[RUNNING] [..]
5577+
",
5578+
)
5579+
.run();
5580+
5581+
p.cargo("run --target")
5582+
.arg(&target)
5583+
.env("RUSTFLAGS", "-C opt-level=3")
5584+
.with_stderr(
5585+
"\
5586+
[COMPILING] foo v0.0.1 ([..])
5587+
[FINISHED] [..]
5588+
[RUNNING] [..]
5589+
",
5590+
)
5591+
.with_stdout(
5592+
"\
5593+
hello",
5594+
)
5595+
.run();
5596+
}

tests/testsuite/cargo_add/help/stdout.term.svg

Lines changed: 1 addition & 1 deletion
Loading

0 commit comments

Comments
 (0)