Skip to content

Commit 5074a7e

Browse files
authored
Rollup merge of rust-lang#50669 - QuietMisdreavus:deprecated-attrs, r=GuillaumeGomez
rustdoc: deprecate `#![doc(passes, plugins, no_default_passes)]` Closes rust-lang#48164 Blocked on rust-lang#50541 - this includes those changes, which were necessary to create the UI test cc rust-lang#44136 Turns out, there were special attributes to mess with rustdoc passes and plugins! Who knew! Since we deprecated the CLI flags for this functionality, it makes sense that we do the same for the attributes. This PR also introduces a `#![doc(document_private_items)]` attribute, to match the `--document-private-items` flag introduced in rust-lang#44138 when the passes/plugins flags were deprecated. I haven't done a search to see whether these attributes are being used at all, but if the flags were any indication, i don't expect to see any users of these.
2 parents 5cc6fd3 + 10ac995 commit 5074a7e

File tree

3 files changed

+58
-2
lines changed

3 files changed

+58
-2
lines changed

src/librustdoc/lib.rs

+32-2
Original file line numberDiff line numberDiff line change
@@ -654,25 +654,55 @@ where R: 'static + Send,
654654

655655
krate.version = crate_version;
656656

657+
let diag = core::new_handler(error_format, None);
658+
659+
fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
660+
let mut msg = diag.struct_warn(&format!("the `#![doc({})]` attribute is \
661+
considered deprecated", name));
662+
msg.warn("please see https://github.com/rust-lang/rust/issues/44136");
663+
664+
if name == "no_default_passes" {
665+
msg.help("you may want to use `#![doc(document_private_items)]`");
666+
}
667+
668+
msg.emit();
669+
}
670+
657671
// Process all of the crate attributes, extracting plugin metadata along
658672
// with the passes which we are supposed to run.
659673
for attr in krate.module.as_ref().unwrap().attrs.lists("doc") {
660674
let name = attr.name().map(|s| s.as_str());
661675
let name = name.as_ref().map(|s| &s[..]);
662676
if attr.is_word() {
663677
if name == Some("no_default_passes") {
678+
report_deprecated_attr("no_default_passes", &diag);
664679
default_passes = false;
665680
}
666681
} else if let Some(value) = attr.value_str() {
667682
let sink = match name {
668-
Some("passes") => &mut passes,
669-
Some("plugins") => &mut plugins,
683+
Some("passes") => {
684+
report_deprecated_attr("passes = \"...\"", &diag);
685+
&mut passes
686+
},
687+
Some("plugins") => {
688+
report_deprecated_attr("plugins = \"...\"", &diag);
689+
&mut plugins
690+
},
670691
_ => continue,
671692
};
672693
for p in value.as_str().split_whitespace() {
673694
sink.push(p.to_string());
674695
}
675696
}
697+
698+
if attr.is_word() && name == Some("document_private_items") {
699+
default_passes = false;
700+
701+
passes = vec![
702+
String::from("collapse-docs"),
703+
String::from("unindent-comments"),
704+
];
705+
}
676706
}
677707

678708
if default_passes {
+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// compile-pass
12+
13+
#![doc(no_default_passes, passes = "collapse-docs unindent-comments")]
14+
15+
struct SomeStruct;
16+
17+
pub struct OtherStruct;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
warning: the `#![doc(no_default_passes)]` attribute is considered deprecated
2+
|
3+
= warning: please see https://github.com/rust-lang/rust/issues/44136
4+
= help: you may want to use `#![doc(document_private_items)]`
5+
6+
warning: the `#![doc(passes = "...")]` attribute is considered deprecated
7+
|
8+
= warning: please see https://github.com/rust-lang/rust/issues/44136
9+

0 commit comments

Comments
 (0)