From aabca44d27fbede156d2f87ee75f24fc3176d052 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 29 Apr 2020 15:08:03 +0200 Subject: [PATCH 1/4] Enforce even more the code blocks attributes check through rustdoc --- src/bootstrap/builder.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index f6060ac14e75e..6157d3d4ac695 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -725,7 +725,9 @@ 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("--deny") + .arg("invalid_codeblock_attribute"); // Remove make-related flags that can cause jobserver problems. cmd.env_remove("MAKEFLAGS"); @@ -838,7 +840,8 @@ 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(); + rustdocflags.arg("--deny").arg("invalid_codeblock_attribute"); if let Ok(s) = env::var("CARGOFLAGS") { cargo.args(s.split_whitespace()); From d70e6e10c50998ea7ffa1e0e11aa5129b7468405 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 13 Jul 2020 16:29:12 +0200 Subject: [PATCH 2/4] Apply review comments --- src/bootstrap/builder.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 6157d3d4ac695..a9bdca5ad7741 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -726,8 +726,10 @@ impl<'a> Builder<'a> { .env("RUSTDOC_REAL", self.rustdoc(compiler)) .env("RUSTDOC_CRATE_VERSION", self.rust_version()) .env("RUSTC_BOOTSTRAP", "1") - .arg("--deny") - .arg("invalid_codeblock_attribute"); + .arg("-Dinvalid_codeblock_attribute"); + if self.config.deny_warnings { + cmd.arg("-Dwarnings"); + } // Remove make-related flags that can cause jobserver problems. cmd.env_remove("MAKEFLAGS"); @@ -841,7 +843,6 @@ impl<'a> Builder<'a> { // but this breaks CI. At the very least, stage0 `rustdoc` needs `--cfg bootstrap`. See // #71458. let mut rustdocflags = rustflags.clone(); - rustdocflags.arg("--deny").arg("invalid_codeblock_attribute"); if let Ok(s) = env::var("CARGOFLAGS") { cargo.args(s.split_whitespace()); @@ -1160,6 +1161,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("-Dinvalid_codeblock_attribute"); } if let Mode::Rustc | Mode::Codegen = mode { From 3dc8544e7bb26e3ee791b5c9b4c4e3da7ad9508a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 13 Jul 2020 17:11:50 +0200 Subject: [PATCH 3/4] Update code to new invalid_codeblock_attributes lint name --- src/bootstrap/builder.rs | 4 ++-- src/librustdoc/core.rs | 6 +++--- src/librustdoc/test.rs | 6 +++--- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index a9bdca5ad7741..1aea0f34a2b11 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -726,7 +726,7 @@ impl<'a> Builder<'a> { .env("RUSTDOC_REAL", self.rustdoc(compiler)) .env("RUSTDOC_CRATE_VERSION", self.rust_version()) .env("RUSTC_BOOTSTRAP", "1") - .arg("-Dinvalid_codeblock_attribute"); + .arg("-Dinvalid_codeblock_attributes"); if self.config.deny_warnings { cmd.arg("-Dwarnings"); } @@ -1162,7 +1162,7 @@ impl<'a> Builder<'a> { // fixed via better support from Cargo. cargo.env("RUSTC_LINT_FLAGS", lint_flags.join(" ")); - rustdocflags.arg("-Dinvalid_codeblock_attribute"); + rustdocflags.arg("-Dinvalid_codeblock_attributes"); } if let Mode::Rustc | Mode::Codegen = mode { diff --git a/src/librustdoc/core.rs b/src/librustdoc/core.rs index a222920c7d292..48ca2b446abb3 100644 --- a/src/librustdoc/core.rs +++ b/src/librustdoc/core.rs @@ -315,7 +315,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. @@ -325,12 +325,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 { diff --git a/src/librustdoc/test.rs b/src/librustdoc/test.rs index c2d644bdd05f1..e8ea71997109a 100644 --- a/src/librustdoc/test.rs +++ b/src/librustdoc/test.rs @@ -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)) From 5f6c07937ae4afcf80644a82da5f95af97044efd Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 16 Jul 2020 21:32:44 +0200 Subject: [PATCH 4/4] Set "invalid_codeblock_attributes" lint to warning level by default --- src/bootstrap/builder.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 1aea0f34a2b11..a165982670798 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -726,7 +726,7 @@ impl<'a> Builder<'a> { .env("RUSTDOC_REAL", self.rustdoc(compiler)) .env("RUSTDOC_CRATE_VERSION", self.rust_version()) .env("RUSTC_BOOTSTRAP", "1") - .arg("-Dinvalid_codeblock_attributes"); + .arg("-Winvalid_codeblock_attributes"); if self.config.deny_warnings { cmd.arg("-Dwarnings"); } @@ -1144,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 @@ -1162,7 +1163,7 @@ impl<'a> Builder<'a> { // fixed via better support from Cargo. cargo.env("RUSTC_LINT_FLAGS", lint_flags.join(" ")); - rustdocflags.arg("-Dinvalid_codeblock_attributes"); + rustdocflags.arg("-Winvalid_codeblock_attributes"); } if let Mode::Rustc | Mode::Codegen = mode {