Skip to content

Update mdbook #106520

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 30 additions & 19 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ dependencies = [
"cargo-test-macro",
"cargo-test-support",
"cargo-util",
"clap 4.0.15",
"clap 4.0.32",
"crates-io",
"curl",
"curl-sys",
Expand Down Expand Up @@ -631,26 +631,27 @@ dependencies = [

[[package]]
name = "clap"
version = "4.0.15"
version = "4.0.32"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6bf8832993da70a4c6d13c581f4463c2bdda27b9bf1c5498dc4365543abe6d6f"
checksum = "a7db700bc935f9e43e88d00b0850dae18a63773cfbec6d8e070fccf7fef89a39"
dependencies = [
"atty",
"bitflags",
"clap_derive 4.0.13",
"clap_derive 4.0.21",
"clap_lex 0.3.0",
"is-terminal",
"once_cell",
"strsim",
"termcolor",
"terminal_size",
]

[[package]]
name = "clap_complete"
version = "3.1.1"
version = "4.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df6f3613c0a3cddfd78b41b10203eb322cb29b600cbdf808a7d3db95691b8e25"
checksum = "10861370d2ba66b0f5989f83ebf35db6421713fd92351790e7fdd6c36774c56b"
dependencies = [
"clap 3.2.20",
"clap 4.0.32",
]

[[package]]
Expand All @@ -668,9 +669,9 @@ dependencies = [

[[package]]
name = "clap_derive"
version = "4.0.13"
version = "4.0.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c42f169caba89a7d512b5418b09864543eeb4d497416c917d7137863bd2076ad"
checksum = "0177313f9f02afc995627906bbd8967e2be069f5261954222dac78290c2b9014"
dependencies = [
"heck",
"proc-macro-error",
Expand Down Expand Up @@ -2271,7 +2272,7 @@ name = "jsondoclint"
version = "0.1.0"
dependencies = [
"anyhow",
"clap 4.0.15",
"clap 4.0.32",
"fs-err",
"rustdoc-json-types",
"serde",
Expand Down Expand Up @@ -2527,21 +2528,21 @@ dependencies = [

[[package]]
name = "mdbook"
version = "0.4.21"
version = "0.4.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "23f3e133c6d515528745ffd3b9f0c7d975ae039f0b6abb099f2168daa2afb4f9"
checksum = "d1ed28d5903dde77bd5182645078a37ee57014cac6ccb2d54e1d6496386648e4"
dependencies = [
"ammonia",
"anyhow",
"chrono",
"clap 3.2.20",
"clap 4.0.32",
"clap_complete",
"elasticlunr-rs",
"env_logger 0.9.0",
"env_logger 0.10.0",
"handlebars 4.3.3",
"lazy_static",
"log",
"memchr",
"once_cell",
"opener",
"pulldown-cmark 0.9.2",
"regex",
Expand Down Expand Up @@ -3537,7 +3538,7 @@ dependencies = [
name = "rustbook"
version = "0.1.0"
dependencies = [
"clap 3.2.20",
"clap 4.0.32",
"env_logger 0.7.1",
"mdbook",
]
Expand Down Expand Up @@ -5502,6 +5503,16 @@ dependencies = [
"winapi-util",
]

[[package]]
name = "terminal_size"
version = "0.2.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cb20089a8ba2b69debd491f8d2d023761cbf196e999218c591fa1e7e15a21907"
dependencies = [
"rustix",
"windows-sys",
]

[[package]]
name = "termize"
version = "0.1.1"
Expand Down Expand Up @@ -5718,9 +5729,9 @@ dependencies = [

[[package]]
name = "topological-sort"
version = "0.1.0"
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa7c7f42dea4b1b99439786f5633aeb9c14c1b53f75e282803c2ec2ad545873c"
checksum = "ea68304e134ecd095ac6c3574494fc62b909f416c4fca77e440530221e549d3d"

[[package]]
name = "tracing"
Expand Down
35 changes: 35 additions & 0 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,41 @@ fn main() {
cmd.arg("-Z").arg("force-unstable-if-unmarked");
}

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

if let Ok(flags) = env::var("MAGIC_EXTRA_RUSTFLAGS") {
for flag in flags.split(' ') {
cmd.arg(flag);
Expand Down
52 changes: 40 additions & 12 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,18 +1381,29 @@ impl<'a> Builder<'a> {
// this), as well as #63012 which is the tracking issue for this
// feature on the rustc side.
cargo.arg("-Zbinary-dep-depinfo");
match mode {
Mode::ToolBootstrap => {
// Restrict the allowed features to those passed by rustbuild, so we don't depend on nightly accidentally.
rustflags.arg("-Zallow-features=binary-dep-depinfo");
}
Mode::ToolStd => {
// Right now this is just compiletest and a few other tools that build on stable.
// Allow them to use `feature(test)`, but nothing else.
rustflags.arg("-Zallow-features=binary-dep-depinfo,test,proc_macro_internals,proc_macro_diagnostic,proc_macro_span");
let allow_features = match mode {
Mode::ToolBootstrap | Mode::ToolStd => {
// Restrict the allowed features so we don't depend on nightly
// accidentally.
//
// binary-dep-depinfo is used by rustbuild itself for all
// compilations.
//
// Lots of tools depend on proc_macro2 and proc-macro-error.
// Those have build scripts which assume nightly features are
// available if the `rustc` version is "nighty" or "dev". See
// bin/rustc.rs for why that is a problem. Instead of labeling
// those features for each individual tool that needs them,
// just blanket allow them here.
//
// If this is ever removed, be sure to add something else in
// its place to keep the restrictions in place (or make a way
// to unset RUSTC_BOOTSTRAP).
"binary-dep-depinfo,proc_macro_span,proc_macro_span_shrink,proc_macro_diagnostic"
.to_string()
}
Mode::Std | Mode::Rustc | Mode::Codegen | Mode::ToolRustc => {}
}
Mode::Std | Mode::Rustc | Mode::Codegen | Mode::ToolRustc => String::new(),
};

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

Expand Down Expand Up @@ -1915,7 +1926,7 @@ impl<'a> Builder<'a> {
}
}

Cargo { command: cargo, rustflags, rustdocflags }
Cargo { command: cargo, rustflags, rustdocflags, allow_features }
}

/// Ensure that a given step is built, returning its output. This will
Expand Down Expand Up @@ -2094,6 +2105,7 @@ pub struct Cargo {
command: Command,
rustflags: Rustflags,
rustdocflags: Rustflags,
allow_features: String,
}

impl Cargo {
Expand Down Expand Up @@ -2138,6 +2150,18 @@ impl Cargo {
self.command.current_dir(dir);
self
}

/// Adds nightly-only features that this invocation is allowed to use.
///
/// By default, all nightly features are allowed. Once this is called, it
/// will be restricted to the given set.
pub fn allow_features(&mut self, features: &str) -> &mut Cargo {
if !self.allow_features.is_empty() {
self.allow_features.push(',');
}
self.allow_features.push_str(features);
self
}
}

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

if !cargo.allow_features.is_empty() {
cargo.command.env("RUSTC_ALLOW_FEATURES", cargo.allow_features);
}

cargo.command
}
}
4 changes: 1 addition & 3 deletions src/bootstrap/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,7 @@ impl Step for RustAnalyzer {
&["rust-analyzer/in-rust-tree".to_owned()],
);

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

// For ./x.py clippy, don't check those targets because
// linting tests and benchmarks can produce very noisy results
Expand Down
4 changes: 3 additions & 1 deletion src/bootstrap/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ impl Step for RustAnalyzer {
SourceType::InTree,
&["sysroot-abi".to_owned()],
);
cargo.allow_features(tool::RustAnalyzer::ALLOW_FEATURES);

let dir = builder.src.join(workspace_path);
// needed by rust-analyzer to find its own text fixtures, cf.
Expand Down Expand Up @@ -690,7 +691,7 @@ impl Step for CompiletestTest {
// We need `ToolStd` for the locally-built sysroot because
// compiletest uses unstable features of the `test` crate.
builder.ensure(compile::Std::new(compiler, host));
let cargo = tool::prepare_tool_cargo(
let mut cargo = tool::prepare_tool_cargo(
builder,
compiler,
Mode::ToolStd,
Expand All @@ -700,6 +701,7 @@ impl Step for CompiletestTest {
SourceType::InTree,
&[],
);
cargo.allow_features("test");

try_run(builder, &mut cargo.into());
}
Expand Down
Loading