Rollup merge of #71670 - GuillaumeGomez:enforce-codeblocks-attribute-check, r=Mark-Simulacrum
Enforce even more the code blocks attributes check through rustdoc `rustdoc` now has a lint which allows it to warn if a code block attribute is malformated (which can end up in bad situations, even more in case of testing examples!). Now it'll fail if such a situation is encountered when testing markdown code blocks examples. r? @Mark-Simulacrum
This commit is contained in:
commit
3006ea3560
@ -725,7 +725,11 @@ impl<'a> Builder<'a> {
|
||||
.env("CFG_RELEASE_CHANNEL", &self.config.channel)
|
||||
.env("RUSTDOC_REAL", self.rustdoc(compiler))
|
||||
.env("RUSTDOC_CRATE_VERSION", self.rust_version())
|
||||
.env("RUSTC_BOOTSTRAP", "1");
|
||||
.env("RUSTC_BOOTSTRAP", "1")
|
||||
.arg("-Winvalid_codeblock_attributes");
|
||||
if self.config.deny_warnings {
|
||||
cmd.arg("-Dwarnings");
|
||||
}
|
||||
|
||||
// Remove make-related flags that can cause jobserver problems.
|
||||
cmd.env_remove("MAKEFLAGS");
|
||||
@ -838,7 +842,7 @@ impl<'a> Builder<'a> {
|
||||
// FIXME: It might be better to use the same value for both `RUSTFLAGS` and `RUSTDOCFLAGS`,
|
||||
// but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See
|
||||
// #71458.
|
||||
let rustdocflags = rustflags.clone();
|
||||
let mut rustdocflags = rustflags.clone();
|
||||
|
||||
if let Ok(s) = env::var("CARGOFLAGS") {
|
||||
cargo.args(s.split_whitespace());
|
||||
@ -1140,6 +1144,7 @@ impl<'a> Builder<'a> {
|
||||
|
||||
if self.config.deny_warnings {
|
||||
lint_flags.push("-Dwarnings");
|
||||
rustdocflags.arg("-Dwarnings");
|
||||
}
|
||||
|
||||
// FIXME(#58633) hide "unused attribute" errors in incremental
|
||||
@ -1157,6 +1162,8 @@ impl<'a> Builder<'a> {
|
||||
// are always ignored in dependencies. Eventually this should be
|
||||
// fixed via better support from Cargo.
|
||||
cargo.env("RUSTC_LINT_FLAGS", lint_flags.join(" "));
|
||||
|
||||
rustdocflags.arg("-Winvalid_codeblock_attributes");
|
||||
}
|
||||
|
||||
if let Mode::Rustc | Mode::Codegen = mode {
|
||||
|
@ -320,7 +320,7 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||
let missing_doc_example = rustc_lint::builtin::MISSING_DOC_CODE_EXAMPLES.name;
|
||||
let private_doc_tests = rustc_lint::builtin::PRIVATE_DOC_TESTS.name;
|
||||
let no_crate_level_docs = rustc_lint::builtin::MISSING_CRATE_LEVEL_DOCS.name;
|
||||
let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
|
||||
let invalid_codeblock_attributes_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
|
||||
|
||||
// In addition to those specific lints, we also need to allow those given through
|
||||
// command line, otherwise they'll get ignored and we don't want that.
|
||||
@ -330,12 +330,12 @@ pub fn run_core(options: RustdocOptions) -> (clean::Crate, RenderInfo, RenderOpt
|
||||
missing_doc_example.to_owned(),
|
||||
private_doc_tests.to_owned(),
|
||||
no_crate_level_docs.to_owned(),
|
||||
invalid_codeblock_attribute_name.to_owned(),
|
||||
invalid_codeblock_attributes_name.to_owned(),
|
||||
];
|
||||
|
||||
let (lint_opts, lint_caps) = init_lints(allowed_lints, lint_opts, |lint| {
|
||||
if lint.name == intra_link_resolution_failure_name
|
||||
|| lint.name == invalid_codeblock_attribute_name
|
||||
|| lint.name == invalid_codeblock_attributes_name
|
||||
{
|
||||
None
|
||||
} else {
|
||||
|
@ -45,14 +45,14 @@ pub struct TestOptions {
|
||||
pub fn run(options: Options) -> Result<(), String> {
|
||||
let input = config::Input::File(options.input.clone());
|
||||
|
||||
let invalid_codeblock_attribute_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
|
||||
let invalid_codeblock_attributes_name = rustc_lint::builtin::INVALID_CODEBLOCK_ATTRIBUTES.name;
|
||||
|
||||
// In addition to those specific lints, we also need to allow those given through
|
||||
// command line, otherwise they'll get ignored and we don't want that.
|
||||
let allowed_lints = vec![invalid_codeblock_attribute_name.to_owned()];
|
||||
let allowed_lints = vec![invalid_codeblock_attributes_name.to_owned()];
|
||||
|
||||
let (lint_opts, lint_caps) = init_lints(allowed_lints, options.lint_opts.clone(), |lint| {
|
||||
if lint.name == invalid_codeblock_attribute_name {
|
||||
if lint.name == invalid_codeblock_attributes_name {
|
||||
None
|
||||
} else {
|
||||
Some((lint.name_lower(), lint::Allow))
|
||||
|
Loading…
x
Reference in New Issue
Block a user