Skip to content

Commit 9415adc

Browse files
deprecate #![doc(no_default_passes, passes, plugins)]
1 parent c3fd12f commit 9415adc

File tree

1 file changed

+32
-2
lines changed

1 file changed

+32
-2
lines changed

src/librustdoc/lib.rs

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -646,25 +646,55 @@ where R: 'static + Send,
646646

647647
krate.version = crate_version;
648648

649+
let diag = core::new_handler(error_format, None);
650+
651+
fn report_deprecated_attr(name: &str, diag: &errors::Handler) {
652+
let mut msg = diag.struct_warn(&format!("WARNING: the `#![doc({})]` attribute is \
653+
considered deprecated", name));
654+
msg.warn("please see https://github.com/rust-lang/rust/issues/44136");
655+
656+
if name == "no_default_passes" {
657+
msg.help("you may want to use `#![doc(document_private_items)]`");
658+
}
659+
660+
msg.emit();
661+
}
662+
649663
// Process all of the crate attributes, extracting plugin metadata along
650664
// with the passes which we are supposed to run.
651665
for attr in krate.module.as_ref().unwrap().attrs.lists("doc") {
652666
let name = attr.name().map(|s| s.as_str());
653667
let name = name.as_ref().map(|s| &s[..]);
654668
if attr.is_word() {
655669
if name == Some("no_default_passes") {
670+
report_deprecated_attr("no_default_passes", &diag);
656671
default_passes = false;
657672
}
658673
} else if let Some(value) = attr.value_str() {
659674
let sink = match name {
660-
Some("passes") => &mut passes,
661-
Some("plugins") => &mut plugins,
675+
Some("passes") => {
676+
report_deprecated_attr("passes = \"...\"", &diag);
677+
&mut passes
678+
},
679+
Some("plugins") => {
680+
report_deprecated_attr("plugins = \"...\"", &diag);
681+
&mut plugins
682+
},
662683
_ => continue,
663684
};
664685
for p in value.as_str().split_whitespace() {
665686
sink.push(p.to_string());
666687
}
667688
}
689+
690+
if attr.is_word() && name == Some("document_private_items") {
691+
default_passes = false;
692+
693+
passes = vec![
694+
String::from("collapse-docs"),
695+
String::from("unindent-comments"),
696+
];
697+
}
668698
}
669699

670700
if default_passes {

0 commit comments

Comments
 (0)