Warn on missing edition in book.toml

This commit is contained in:
Rick Weber 2022-02-23 14:14:09 -08:00
parent 4bcc075ad8
commit 92e304a91c
2 changed files with 10 additions and 4 deletions

View File

@ -245,7 +245,12 @@ impl MDBook {
} }
/// Run `rustdoc` tests on the book, linking against the provided libraries. /// Run `rustdoc` tests on the book, linking against the provided libraries.
pub fn test(&mut self, library_paths: Vec<&str>, externs: Vec<&str>, verbose: bool) -> Result<()> { pub fn test(
&mut self,
library_paths: Vec<&str>,
externs: Vec<&str>,
verbose: bool,
) -> Result<()> {
let library_args: Vec<&str> = (0..library_paths.len()) let library_args: Vec<&str> = (0..library_paths.len())
.map(|_| "-L") .map(|_| "-L")
.zip(library_paths.into_iter()) .zip(library_paths.into_iter())
@ -287,8 +292,7 @@ impl MDBook {
tmpf.write_all(ch.content.as_bytes())?; tmpf.write_all(ch.content.as_bytes())?;
let mut cmd = Command::new("rustdoc"); let mut cmd = Command::new("rustdoc");
cmd cmd.arg(&path)
.arg(&path)
.arg("--test") .arg("--test")
.args(&library_args) .args(&library_args)
.args(&extern_args) .args(&extern_args)
@ -306,6 +310,8 @@ impl MDBook {
cmd.args(&["--edition", "2021"]); cmd.args(&["--edition", "2021"]);
} }
} }
} else {
warn!("Edition not set in book.toml [rust] section. Rustdoc will default to 2015, which probably not what you want.");
} }
let command = cmd let command = cmd

View File

@ -51,7 +51,7 @@ pub fn make_subcommand<'help>() -> App<'help> {
.arg(Arg::with_name("verbose") .arg(Arg::with_name("verbose")
.long("verbose") .long("verbose")
.short("v") .short("v")
.takes_value(false) .takes_value(false)
.multiple(false) .multiple(false)
.help("Enables verbose logging with the test command.")) .help("Enables verbose logging with the test command."))
} }