Skip to content

Commit 2717f60

Browse files
committed
Update mdbook
1 parent 388538f commit 2717f60

File tree

8 files changed

+146
-49
lines changed

8 files changed

+146
-49
lines changed

Cargo.lock

+30-19
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ dependencies = [
329329
"cargo-test-macro",
330330
"cargo-test-support",
331331
"cargo-util",
332-
"clap 4.0.15",
332+
"clap 4.0.32",
333333
"crates-io",
334334
"curl",
335335
"curl-sys",
@@ -631,26 +631,27 @@ dependencies = [
631631

632632
[[package]]
633633
name = "clap"
634-
version = "4.0.15"
634+
version = "4.0.32"
635635
source = "registry+https://github.com/rust-lang/crates.io-index"
636-
checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f"
636+
checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39"
637637
dependencies = [
638-
"atty",
639638
"bitflags",
640-
"clap_derive 4.0.13",
639+
"clap_derive 4.0.21",
641640
"clap_lex 0.3.0",
641+
"is-terminal",
642642
"once_cell",
643643
"strsim",
644644
"termcolor",
645+
"terminal_size",
645646
]
646647

647648
[[package]]
648649
name = "clap_complete"
649-
version = "3.1.1"
650+
version = "4.0.7"
650651
source = "registry+https://github.com/rust-lang/crates.io-index"
651-
checksum = "df6f3613c0a3cddfd78b41b10203eb322cb29b600cbdf808a7d3db95691b8e25"
652+
checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b"
652653
dependencies = [
653-
"clap 3.2.20",
654+
"clap 4.0.32",
654655
]
655656

656657
[[package]]
@@ -668,9 +669,9 @@ dependencies = [
668669

669670
[[package]]
670671
name = "clap_derive"
671-
version = "4.0.13"
672+
version = "4.0.21"
672673
source = "registry+https://github.com/rust-lang/crates.io-index"
673-
checksum = "c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad"
674+
checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014"
674675
dependencies = [
675676
"heck",
676677
"proc-macro-error",
@@ -2271,7 +2272,7 @@ name = "jsondoclint"
22712272
version = "0.1.0"
22722273
dependencies = [
22732274
"anyhow",
2274-
"clap 4.0.15",
2275+
"clap 4.0.32",
22752276
"fs-err",
22762277
"rustdoc-json-types",
22772278
"serde",
@@ -2527,21 +2528,21 @@ dependencies = [
25272528

25282529
[[package]]
25292530
name = "mdbook"
2530-
version = "0.4.21"
2531+
version = "0.4.25"
25312532
source = "registry+https://github.com/rust-lang/crates.io-index"
2532-
checksum = "23f3e133c6d515528745ffd3b9f0c7d975ae039f0b6abb099f2168daa2afb4f9"
2533+
checksum = "d1ed28d5903dde77bd5182645078a37ee57014cac6ccb2d54e1d6496386648e4"
25332534
dependencies = [
25342535
"ammonia",
25352536
"anyhow",
25362537
"chrono",
2537-
"clap 3.2.20",
2538+
"clap 4.0.32",
25382539
"clap_complete",
25392540
"elasticlunr-rs",
2540-
"env_logger 0.9.0",
2541+
"env_logger 0.10.0",
25412542
"handlebars 4.3.3",
2542-
"lazy_static",
25432543
"log",
25442544
"memchr",
2545+
"once_cell",
25452546
"opener",
25462547
"pulldown-cmark 0.9.2",
25472548
"regex",
@@ -3537,7 +3538,7 @@ dependencies = [
35373538
name = "rustbook"
35383539
version = "0.1.0"
35393540
dependencies = [
3540-
"clap 3.2.20",
3541+
"clap 4.0.32",
35413542
"env_logger 0.7.1",
35423543
"mdbook",
35433544
]
@@ -5502,6 +5503,16 @@ dependencies = [
55025503
"winapi-util",
55035504
]
55045505

5506+
[[package]]
5507+
name = "terminal_size"
5508+
version = "0.2.3"
5509+
source = "registry+https://github.com/rust-lang/crates.io-index"
5510+
checksum = "cb20089a8ba2b69debd491f8d2d023761cbf196e999218c591fa1e7e15a21907"
5511+
dependencies = [
5512+
"rustix",
5513+
"windows-sys",
5514+
]
5515+
55055516
[[package]]
55065517
name = "termize"
55075518
version = "0.1.1"
@@ -5718,9 +5729,9 @@ dependencies = [
57185729

57195730
[[package]]
57205731
name = "topological-sort"
5721-
version = "0.1.0"
5732+
version = "0.2.2"
57225733
source = "registry+https://github.com/rust-lang/crates.io-index"
5723-
checksum = "aa7c7f42dea4b1b99439786f5633aeb9c14c1b53f75e282803c2ec2ad545873c"
5734+
checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d"
57245735

57255736
[[package]]
57265737
name = "tracing"

src/bootstrap/bin/rustc.rs

+35
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,41 @@ fn main() {
154154
cmd.arg("-Z").arg("force-unstable-if-unmarked");
155155
}
156156

157+
// allow-features is handled from within this rustc wrapper because of
158+
// issues with build scripts. Some packages use build scripts to
159+
// dynamically detect if certain nightly features are available.
160+
// There are different ways this causes problems:
161+
//
162+
// * rustix runs `rustc` on a small test program to see if the feature is
163+
// available (and sets a `cfg` if it is). It does not honor
164+
// CARGO_ENCODED_RUSTFLAGS.
165+
// * proc-macro2 detects if `rustc -vV` says "nighty" or "dev" and enables
166+
// nightly features. It will scan CARGO_ENCODED_RUSTFLAGS for
167+
// -Zallow-features. Unfortunately CARGO_ENCODED_RUSTFLAGS is not set
168+
// for build-dependencies when --target is used.
169+
//
170+
// The issues above means we can't just use RUSTFLAGS, and we can't use
171+
// `cargo -Zallow-features=…`. Passing it through here ensures that it
172+
// always gets set. Unfortunately that also means we need to enable more
173+
// features than we really want (like those for proc-macro2), but there
174+
// isn't much of a way around it.
175+
//
176+
// I think it is unfortunate that build scripts are doing this at all,
177+
// since changes to nightly features can cause crates to break even if the
178+
// user didn't want or care about the use of the nightly features. I think
179+
// nightly features should be opt-in only. Unfortunately the dynamic
180+
// checks are now too wide spread that we just need to deal with it.
181+
//
182+
// If you want to try to remove this, I suggest working with the crate
183+
// authors to remove the dynamic checking. Another option is to pursue
184+
// https://github.com/rust-lang/cargo/issues/11244 and
185+
// https://github.com/rust-lang/cargo/issues/4423, which will likely be
186+
// very difficult, but could help expose -Zallow-features into build
187+
// scripts so they could try to honor them.
188+
if let Ok(allow_features) = env::var("RUSTC_ALLOW_FEATURES") {
189+
cmd.arg(format!("-Zallow-features={allow_features}"));
190+
}
191+
157192
if let Ok(flags) = env::var("MAGIC_EXTRA_RUSTFLAGS") {
158193
for flag in flags.split(' ') {
159194
cmd.arg(flag);

src/bootstrap/builder.rs

+40-12
Original file line numberDiff line numberDiff line change
@@ -1381,18 +1381,29 @@ impl<'a> Builder<'a> {
13811381
// this), as well as #63012 which is the tracking issue for this
13821382
// feature on the rustc side.
13831383
cargo.arg("-Zbinary-dep-depinfo");
1384-
match mode {
1385-
Mode::ToolBootstrap => {
1386-
// Restrict the allowed features to those passed by rustbuild, so we don't depend on nightly accidentally.
1387-
rustflags.arg("-Zallow-features=binary-dep-depinfo");
1388-
}
1389-
Mode::ToolStd => {
1390-
// Right now this is just compiletest and a few other tools that build on stable.
1391-
// Allow them to use `feature(test)`, but nothing else.
1392-
rustflags.arg("-Zallow-features=binary-dep-depinfo,test,proc_macro_internals,proc_macro_diagnostic,proc_macro_span");
1384+
let allow_features = match mode {
1385+
Mode::ToolBootstrap | Mode::ToolStd => {
1386+
// Restrict the allowed features so we don't depend on nightly
1387+
// accidentally.
1388+
//
1389+
// binary-dep-depinfo is used by rustbuild itself for all
1390+
// compilations.
1391+
//
1392+
// Lots of tools depend on proc_macro2 and proc-macro-error.
1393+
// Those have build scripts which assume nightly features are
1394+
// available if the `rustc` version is "nighty" or "dev". See
1395+
// bin/rustc.rs for why that is a problem. Instead of labeling
1396+
// those features for each individual tool that needs them,
1397+
// just blanket allow them here.
1398+
//
1399+
// If this is ever removed, be sure to add something else in
1400+
// its place to keep the restrictions in place (or make a way
1401+
// to unset RUSTC_BOOTSTRAP).
1402+
"binary-dep-depinfo,proc_macro_span,proc_macro_span_shrink,proc_macro_diagnostic"
1403+
.to_string()
13931404
}
1394-
Mode::Std | Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {}
1395-
}
1405+
Mode::Std | Mode::Rustc | Mode::Codegen | Mode::ToolRustc => String::new(),
1406+
};
13961407

13971408
cargo.arg("-j").arg(self.jobs().to_string());
13981409

@@ -1915,7 +1926,7 @@ impl<'a> Builder<'a> {
19151926
}
19161927
}
19171928

1918-
Cargo { command: cargo, rustflags, rustdocflags }
1929+
Cargo { command: cargo, rustflags, rustdocflags, allow_features }
19191930
}
19201931

19211932
/// Ensure that a given step is built, returning its output. This will
@@ -2094,6 +2105,7 @@ pub struct Cargo {
20942105
command: Command,
20952106
rustflags: Rustflags,
20962107
rustdocflags: Rustflags,
2108+
allow_features: String,
20972109
}
20982110

20992111
impl Cargo {
@@ -2138,6 +2150,18 @@ impl Cargo {
21382150
self.command.current_dir(dir);
21392151
self
21402152
}
2153+
2154+
/// Adds nightly-only features that this invocation is allowed to use.
2155+
///
2156+
/// By default, all nightly features are allowed. Once this is called, it
2157+
/// will be restricted to the given set.
2158+
pub fn allow_features(&mut self, features: &str) -> &mut Cargo {
2159+
if !self.allow_features.is_empty() {
2160+
self.allow_features.push(',');
2161+
}
2162+
self.allow_features.push_str(features);
2163+
self
2164+
}
21412165
}
21422166

21432167
impl From<Cargo> for Command {
@@ -2152,6 +2176,10 @@ impl From<Cargo> for Command {
21522176
cargo.command.env("RUSTDOCFLAGS", rustdocflags);
21532177
}
21542178

2179+
if !cargo.allow_features.is_empty() {
2180+
cargo.command.env("RUSTC_ALLOW_FEATURES", cargo.allow_features);
2181+
}
2182+
21552183
cargo.command
21562184
}
21572185
}

src/bootstrap/check.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -332,9 +332,7 @@ impl Step for RustAnalyzer {
332332
&["rust-analyzer/in-rust-tree".to_owned()],
333333
);
334334

335-
cargo.rustflag(
336-
"-Zallow-features=proc_macro_internals,proc_macro_diagnostic,proc_macro_span",
337-
);
335+
cargo.allow_features(crate::tool::RustAnalyzer::ALLOW_FEATURES);
338336

339337
// For ./x.py clippy, don't check those targets because
340338
// linting tests and benchmarks can produce very noisy results

src/bootstrap/test.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,7 @@ impl Step for RustAnalyzer {
378378
SourceType::InTree,
379379
&["sysroot-abi".to_owned()],
380380
);
381+
cargo.allow_features(tool::RustAnalyzer::ALLOW_FEATURES);
381382

382383
let dir = builder.src.join(workspace_path);
383384
// needed by rust-analyzer to find its own text fixtures, cf.
@@ -690,7 +691,7 @@ impl Step for CompiletestTest {
690691
// We need `ToolStd` for the locally-built sysroot because
691692
// compiletest uses unstable features of the `test` crate.
692693
builder.ensure(compile::Std::new(compiler, host));
693-
let cargo = tool::prepare_tool_cargo(
694+
let mut cargo = tool::prepare_tool_cargo(
694695
builder,
695696
compiler,
696697
Mode::ToolStd,
@@ -700,6 +701,7 @@ impl Step for CompiletestTest {
700701
SourceType::InTree,
701702
&[],
702703
);
704+
cargo.allow_features("test");
703705

704706
try_run(builder, &mut cargo.into());
705707
}

0 commit comments

Comments
 (0)