Add doc(plugins), doc(passes), etc. to INVALID_DOC_ATTRIBUTES
This commit is contained in:
parent
785c83015c
commit
d11a9702ab
6 changed files with 84 additions and 69 deletions
|
@ -245,6 +245,19 @@ passes_doc_test_unknown_include =
|
||||||
unknown `doc` attribute `{$path}`
|
unknown `doc` attribute `{$path}`
|
||||||
.suggestion = use `doc = include_str!` instead
|
.suggestion = use `doc = include_str!` instead
|
||||||
|
|
||||||
|
passes_doc_test_unknown_passes =
|
||||||
|
unknown `doc` attribute `{$path}`
|
||||||
|
.note = `doc` attribute `{$path}` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>
|
||||||
|
.label = no longer functions
|
||||||
|
.help = you may want to use `doc(document_private_items)`
|
||||||
|
.no_op_note = `doc({$path})` is now a no-op
|
||||||
|
|
||||||
|
passes_doc_test_unknown_plugins =
|
||||||
|
unknown `doc` attribute `{$path}`
|
||||||
|
.note = `doc` attribute `{$path}` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136> and CVE-2018-1000622 <https://nvd.nist.gov/vuln/detail/CVE-2018-1000622>
|
||||||
|
.label = no longer functions
|
||||||
|
.no_op_note = `doc({$path})` is now a no-op
|
||||||
|
|
||||||
passes_doc_test_unknown_spotlight =
|
passes_doc_test_unknown_spotlight =
|
||||||
unknown `doc` attribute `{$path}`
|
unknown `doc` attribute `{$path}`
|
||||||
.note = `doc(spotlight)` was renamed to `doc(notable_trait)`
|
.note = `doc(spotlight)` was renamed to `doc(notable_trait)`
|
||||||
|
|
|
@ -1187,15 +1187,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||||
|
|
||||||
sym::masked => self.check_doc_masked(attr, meta, hir_id, target),
|
sym::masked => self.check_doc_masked(attr, meta, hir_id, target),
|
||||||
|
|
||||||
// no_default_passes: deprecated
|
sym::cfg | sym::hidden | sym::notable_trait => {}
|
||||||
// passes: deprecated
|
|
||||||
// plugins: removed, but rustdoc warns about it itself
|
|
||||||
sym::cfg
|
|
||||||
| sym::hidden
|
|
||||||
| sym::no_default_passes
|
|
||||||
| sym::notable_trait
|
|
||||||
| sym::passes
|
|
||||||
| sym::plugins => {}
|
|
||||||
|
|
||||||
sym::rust_logo => {
|
sym::rust_logo => {
|
||||||
if self.check_attr_crate_level(attr, meta, hir_id)
|
if self.check_attr_crate_level(attr, meta, hir_id)
|
||||||
|
@ -1244,6 +1236,22 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
|
||||||
sugg: (attr.meta().unwrap().span, applicability),
|
sugg: (attr.meta().unwrap().span, applicability),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
} else if i_meta.has_name(sym::passes)
|
||||||
|
|| i_meta.has_name(sym::no_default_passes)
|
||||||
|
{
|
||||||
|
self.tcx.emit_node_span_lint(
|
||||||
|
INVALID_DOC_ATTRIBUTES,
|
||||||
|
hir_id,
|
||||||
|
i_meta.span,
|
||||||
|
errors::DocTestUnknownPasses { path, span: i_meta.span },
|
||||||
|
);
|
||||||
|
} else if i_meta.has_name(sym::plugins) {
|
||||||
|
self.tcx.emit_node_span_lint(
|
||||||
|
INVALID_DOC_ATTRIBUTES,
|
||||||
|
hir_id,
|
||||||
|
i_meta.span,
|
||||||
|
errors::DocTestUnknownPlugins { path, span: i_meta.span },
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
self.tcx.emit_node_span_lint(
|
self.tcx.emit_node_span_lint(
|
||||||
INVALID_DOC_ATTRIBUTES,
|
INVALID_DOC_ATTRIBUTES,
|
||||||
|
|
|
@ -317,6 +317,27 @@ pub(crate) struct DocTestUnknownSpotlight {
|
||||||
pub span: Span,
|
pub span: Span,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(LintDiagnostic)]
|
||||||
|
#[diag(passes_doc_test_unknown_passes)]
|
||||||
|
#[note]
|
||||||
|
#[help]
|
||||||
|
#[note(passes_no_op_note)]
|
||||||
|
pub(crate) struct DocTestUnknownPasses {
|
||||||
|
pub path: String,
|
||||||
|
#[label]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(LintDiagnostic)]
|
||||||
|
#[diag(passes_doc_test_unknown_plugins)]
|
||||||
|
#[note]
|
||||||
|
#[note(passes_no_op_note)]
|
||||||
|
pub(crate) struct DocTestUnknownPlugins {
|
||||||
|
pub path: String,
|
||||||
|
#[label]
|
||||||
|
pub span: Span,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(LintDiagnostic)]
|
#[derive(LintDiagnostic)]
|
||||||
#[diag(passes_doc_test_unknown_include)]
|
#[diag(passes_doc_test_unknown_include)]
|
||||||
pub(crate) struct DocTestUnknownInclude {
|
pub(crate) struct DocTestUnknownInclude {
|
||||||
|
|
|
@ -8,7 +8,7 @@ use rustc_data_structures::unord::UnordSet;
|
||||||
use rustc_errors::codes::*;
|
use rustc_errors::codes::*;
|
||||||
use rustc_errors::emitter::{DynEmitter, HumanEmitter, stderr_destination};
|
use rustc_errors::emitter::{DynEmitter, HumanEmitter, stderr_destination};
|
||||||
use rustc_errors::json::JsonEmitter;
|
use rustc_errors::json::JsonEmitter;
|
||||||
use rustc_errors::{DiagCtxtHandle, ErrorGuaranteed, TerminalUrl};
|
use rustc_errors::{ErrorGuaranteed, TerminalUrl};
|
||||||
use rustc_feature::UnstableFeatures;
|
use rustc_feature::UnstableFeatures;
|
||||||
use rustc_hir::def::Res;
|
use rustc_hir::def::Res;
|
||||||
use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId};
|
use rustc_hir::def_id::{DefId, DefIdMap, DefIdSet, LocalDefId};
|
||||||
|
@ -21,8 +21,8 @@ use rustc_middle::ty::{ParamEnv, Ty, TyCtxt};
|
||||||
use rustc_session::config::{self, CrateType, ErrorOutputType, Input, ResolveDocLinks};
|
use rustc_session::config::{self, CrateType, ErrorOutputType, Input, ResolveDocLinks};
|
||||||
pub(crate) use rustc_session::config::{Options, UnstableOptions};
|
pub(crate) use rustc_session::config::{Options, UnstableOptions};
|
||||||
use rustc_session::{Session, lint};
|
use rustc_session::{Session, lint};
|
||||||
|
use rustc_span::source_map;
|
||||||
use rustc_span::symbol::sym;
|
use rustc_span::symbol::sym;
|
||||||
use rustc_span::{Span, source_map};
|
|
||||||
use tracing::{debug, info};
|
use tracing::{debug, info};
|
||||||
|
|
||||||
use crate::clean::inline::build_external_trait;
|
use crate::clean::inline::build_external_trait;
|
||||||
|
@ -380,45 +380,10 @@ pub(crate) fn run_global_ctxt(
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn report_deprecated_attr(name: &str, dcx: DiagCtxtHandle<'_>, sp: Span) {
|
|
||||||
let mut msg =
|
|
||||||
dcx.struct_span_warn(sp, format!("the `#![doc({name})]` attribute is deprecated"));
|
|
||||||
msg.note(
|
|
||||||
"see issue #44136 <https://github.com/rust-lang/rust/issues/44136> \
|
|
||||||
for more information",
|
|
||||||
);
|
|
||||||
|
|
||||||
if name == "no_default_passes" {
|
|
||||||
msg.help("`#![doc(no_default_passes)]` no longer functions; you may want to use `#![doc(document_private_items)]`");
|
|
||||||
} else if name.starts_with("passes") {
|
|
||||||
msg.help("`#![doc(passes = \"...\")]` no longer functions; you may want to use `#![doc(document_private_items)]`");
|
|
||||||
} else if name.starts_with("plugins") {
|
|
||||||
msg.warn("`#![doc(plugins = \"...\")]` no longer functions; see CVE-2018-1000622 <https://nvd.nist.gov/vuln/detail/CVE-2018-1000622>");
|
|
||||||
}
|
|
||||||
|
|
||||||
msg.emit();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Process all of the crate attributes, extracting plugin metadata along
|
// Process all of the crate attributes, extracting plugin metadata along
|
||||||
// with the passes which we are supposed to run.
|
// with the passes which we are supposed to run.
|
||||||
for attr in krate.module.attrs.lists(sym::doc) {
|
for attr in krate.module.attrs.lists(sym::doc) {
|
||||||
let dcx = ctxt.sess().dcx();
|
|
||||||
|
|
||||||
let name = attr.name_or_empty();
|
let name = attr.name_or_empty();
|
||||||
// `plugins = "..."`, `no_default_passes`, and `passes = "..."` have no effect
|
|
||||||
if attr.is_word() && name == sym::no_default_passes {
|
|
||||||
report_deprecated_attr("no_default_passes", dcx, attr.span());
|
|
||||||
} else if attr.value_str().is_some() {
|
|
||||||
match name {
|
|
||||||
sym::passes => {
|
|
||||||
report_deprecated_attr("passes = \"...\"", dcx, attr.span());
|
|
||||||
}
|
|
||||||
sym::plugins => {
|
|
||||||
report_deprecated_attr("plugins = \"...\"", dcx, attr.span());
|
|
||||||
}
|
|
||||||
_ => (),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if attr.is_word() && name == sym::document_private_items {
|
if attr.is_word() && name == sym::document_private_items {
|
||||||
ctxt.render_options.document_private = true;
|
ctxt.render_options.document_private = true;
|
||||||
|
|
|
@ -1,16 +1,21 @@
|
||||||
//@ check-pass
|
|
||||||
//@ compile-flags: --passes unknown-pass
|
//@ compile-flags: --passes unknown-pass
|
||||||
//@ error-pattern: the `passes` flag no longer functions
|
//@ error-pattern: the `passes` flag no longer functions
|
||||||
|
|
||||||
#![doc(no_default_passes)]
|
#![doc(no_default_passes)]
|
||||||
//~^ WARNING attribute is deprecated
|
//~^ ERROR unknown `doc` attribute `no_default_passes`
|
||||||
|
//~| NOTE no longer functions
|
||||||
//~| NOTE see issue #44136
|
//~| NOTE see issue #44136
|
||||||
//~| HELP no longer functions; you may want to use `#![doc(document_private_items)]`
|
//~| HELP you may want to use `doc(document_private_items)`
|
||||||
|
//~| NOTE `doc(no_default_passes)` is now a no-op
|
||||||
|
//~| NOTE `#[deny(invalid_doc_attributes)]` on by default
|
||||||
#![doc(passes = "collapse-docs unindent-comments")]
|
#![doc(passes = "collapse-docs unindent-comments")]
|
||||||
//~^ WARNING attribute is deprecated
|
//~^ ERROR unknown `doc` attribute `passes`
|
||||||
|
//~| NOTE no longer functions
|
||||||
//~| NOTE see issue #44136
|
//~| NOTE see issue #44136
|
||||||
//~| HELP no longer functions; you may want to use `#![doc(document_private_items)]`
|
//~| HELP you may want to use `doc(document_private_items)`
|
||||||
|
//~| NOTE `doc(passes)` is now a no-op
|
||||||
#![doc(plugins = "xxx")]
|
#![doc(plugins = "xxx")]
|
||||||
//~^ WARNING attribute is deprecated
|
//~^ ERROR unknown `doc` attribute `plugins`
|
||||||
//~| NOTE see issue #44136
|
//~| NOTE see issue #44136
|
||||||
//~| WARNING no longer functions; see CVE
|
//~| NOTE no longer functions
|
||||||
|
//~| NOTE `doc(plugins)` is now a no-op
|
||||||
|
|
|
@ -3,32 +3,35 @@ warning: the `passes` flag no longer functions
|
||||||
= note: see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information
|
= note: see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information
|
||||||
= help: you may want to use --document-private-items
|
= help: you may want to use --document-private-items
|
||||||
|
|
||||||
warning: the `#![doc(no_default_passes)]` attribute is deprecated
|
error: unknown `doc` attribute `no_default_passes`
|
||||||
--> $DIR/deprecated-attrs.rs:5:8
|
--> $DIR/deprecated-attrs.rs:4:8
|
||||||
|
|
|
|
||||||
LL | #![doc(no_default_passes)]
|
LL | #![doc(no_default_passes)]
|
||||||
| ^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^ no longer functions
|
||||||
|
|
|
|
||||||
= note: see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information
|
= note: `doc` attribute `no_default_passes` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>
|
||||||
= help: `#![doc(no_default_passes)]` no longer functions; you may want to use `#![doc(document_private_items)]`
|
= help: you may want to use `doc(document_private_items)`
|
||||||
|
= note: `doc(no_default_passes)` is now a no-op
|
||||||
|
= note: `#[deny(invalid_doc_attributes)]` on by default
|
||||||
|
|
||||||
warning: the `#![doc(passes = "...")]` attribute is deprecated
|
error: unknown `doc` attribute `passes`
|
||||||
--> $DIR/deprecated-attrs.rs:9:8
|
--> $DIR/deprecated-attrs.rs:11:8
|
||||||
|
|
|
|
||||||
LL | #![doc(passes = "collapse-docs unindent-comments")]
|
LL | #![doc(passes = "collapse-docs unindent-comments")]
|
||||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ no longer functions
|
||||||
|
|
|
|
||||||
= note: see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information
|
= note: `doc` attribute `passes` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>
|
||||||
= help: `#![doc(passes = "...")]` no longer functions; you may want to use `#![doc(document_private_items)]`
|
= help: you may want to use `doc(document_private_items)`
|
||||||
|
= note: `doc(passes)` is now a no-op
|
||||||
|
|
||||||
warning: the `#![doc(plugins = "...")]` attribute is deprecated
|
error: unknown `doc` attribute `plugins`
|
||||||
--> $DIR/deprecated-attrs.rs:13:8
|
--> $DIR/deprecated-attrs.rs:17:8
|
||||||
|
|
|
|
||||||
LL | #![doc(plugins = "xxx")]
|
LL | #![doc(plugins = "xxx")]
|
||||||
| ^^^^^^^^^^^^^^^
|
| ^^^^^^^^^^^^^^^ no longer functions
|
||||||
|
|
|
|
||||||
= note: see issue #44136 <https://github.com/rust-lang/rust/issues/44136> for more information
|
= note: `doc` attribute `plugins` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136> and CVE-2018-1000622 <https://nvd.nist.gov/vuln/detail/CVE-2018-1000622>
|
||||||
= warning: `#![doc(plugins = "...")]` no longer functions; see CVE-2018-1000622 <https://nvd.nist.gov/vuln/detail/CVE-2018-1000622>
|
= note: `doc(plugins)` is now a no-op
|
||||||
|
|
||||||
warning: 3 warnings emitted
|
error: aborting due to 3 previous errors
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue