mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Rollup merge of #155560 - GuillaumeGomez:rm-attributelintkind, r=JonathanBrouwer
Remove `AttributeLintKind` variants - part 4 Part of https://github.com/rust-lang/rust/issues/153099. r? @JonathanBrouwer
This commit is contained in:
@@ -15,7 +15,8 @@
|
||||
use crate::context::{AcceptContext, FinalizeContext, Stage};
|
||||
use crate::errors::{
|
||||
DocAliasDuplicated, DocAutoCfgExpectsHideOrShow, DocAutoCfgHideShowExpectsList,
|
||||
DocAutoCfgHideShowUnexpectedItem, DocUnknownInclude, IllFormedAttributeInput,
|
||||
DocAutoCfgHideShowUnexpectedItem, DocAutoCfgWrongLiteral, DocUnknownAny, DocUnknownInclude,
|
||||
DocUnknownPasses, DocUnknownPlugins, DocUnknownSpotlight, IllFormedAttributeInput,
|
||||
};
|
||||
use crate::parser::{ArgParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser};
|
||||
use crate::session_diagnostics::{
|
||||
@@ -442,9 +443,9 @@ fn parse_auto_cfg<S: Stage>(
|
||||
ArgParser::NameValue(nv) => {
|
||||
let MetaItemLit { kind: LitKind::Bool(bool_value), span, .. } = nv.value_as_lit()
|
||||
else {
|
||||
cx.emit_lint(
|
||||
cx.emit_dyn_lint(
|
||||
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
|
||||
AttributeLintKind::DocAutoCfgWrongLiteral,
|
||||
move |dcx, level| DocAutoCfgWrongLiteral.into_diag(dcx, level),
|
||||
nv.value_span,
|
||||
);
|
||||
return;
|
||||
@@ -613,10 +614,11 @@ macro_rules! string_arg_and_crate_level {
|
||||
}
|
||||
}
|
||||
Some(sym::spotlight) => {
|
||||
cx.emit_lint(
|
||||
let span = path.span();
|
||||
cx.emit_dyn_lint(
|
||||
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
|
||||
AttributeLintKind::DocUnknownSpotlight { span: path.span() },
|
||||
path.span(),
|
||||
move |dcx, level| DocUnknownSpotlight { sugg_span: span }.into_diag(dcx, level),
|
||||
span,
|
||||
);
|
||||
}
|
||||
Some(sym::include) if let Some(nv) = args.name_value() => {
|
||||
@@ -640,32 +642,37 @@ macro_rules! string_arg_and_crate_level {
|
||||
);
|
||||
}
|
||||
Some(name @ (sym::passes | sym::no_default_passes)) => {
|
||||
cx.emit_lint(
|
||||
let span = path.span();
|
||||
cx.emit_dyn_lint(
|
||||
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
|
||||
AttributeLintKind::DocUnknownPasses { name, span: path.span() },
|
||||
path.span(),
|
||||
move |dcx, level| {
|
||||
DocUnknownPasses { name, note_span: span }.into_diag(dcx, level)
|
||||
},
|
||||
span,
|
||||
);
|
||||
}
|
||||
Some(sym::plugins) => {
|
||||
cx.emit_lint(
|
||||
let span = path.span();
|
||||
cx.emit_dyn_lint(
|
||||
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
|
||||
AttributeLintKind::DocUnknownPlugins { span: path.span() },
|
||||
path.span(),
|
||||
move |dcx, level| DocUnknownPlugins { label_span: span }.into_diag(dcx, level),
|
||||
span,
|
||||
);
|
||||
}
|
||||
Some(name) => {
|
||||
cx.emit_lint(
|
||||
cx.emit_dyn_lint(
|
||||
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
|
||||
AttributeLintKind::DocUnknownAny { name },
|
||||
move |dcx, level| DocUnknownAny { name }.into_diag(dcx, level),
|
||||
path.span(),
|
||||
);
|
||||
}
|
||||
None => {
|
||||
let full_name =
|
||||
path.segments().map(|s| s.as_str()).intersperse("::").collect::<String>();
|
||||
cx.emit_lint(
|
||||
let name = Symbol::intern(&full_name);
|
||||
cx.emit_dyn_lint(
|
||||
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
|
||||
AttributeLintKind::DocUnknownAny { name: Symbol::intern(&full_name) },
|
||||
move |dcx, level| DocUnknownAny { name }.into_diag(dcx, level),
|
||||
path.span(),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -205,3 +205,50 @@ pub(crate) struct DocUnknownInclude {
|
||||
)]
|
||||
pub sugg: (Span, Applicability),
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown `doc` attribute `spotlight`")]
|
||||
#[note("`doc(spotlight)` was renamed to `doc(notable_trait)`")]
|
||||
#[note("`doc(spotlight)` is now a no-op")]
|
||||
pub(crate) struct DocUnknownSpotlight {
|
||||
#[suggestion(
|
||||
"use `notable_trait` instead",
|
||||
style = "short",
|
||||
applicability = "machine-applicable",
|
||||
code = "notable_trait"
|
||||
)]
|
||||
pub sugg_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown `doc` attribute `{$name}`")]
|
||||
#[note(
|
||||
"`doc` attribute `{$name}` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>"
|
||||
)]
|
||||
#[note("`doc({$name})` is now a no-op")]
|
||||
pub(crate) struct DocUnknownPasses {
|
||||
pub name: Symbol,
|
||||
#[label("no longer functions")]
|
||||
pub note_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown `doc` attribute `plugins`")]
|
||||
#[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>"
|
||||
)]
|
||||
#[note("`doc(plugins)` is now a no-op")]
|
||||
pub(crate) struct DocUnknownPlugins {
|
||||
#[label("no longer functions")]
|
||||
pub label_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown `doc` attribute `{$name}`")]
|
||||
pub(crate) struct DocUnknownAny {
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("expected boolean for `#[doc(auto_cfg = ...)]`")]
|
||||
pub(crate) struct DocAutoCfgWrongLiteral;
|
||||
|
||||
@@ -43,26 +43,6 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
.into_diag(dcx, level)
|
||||
}
|
||||
|
||||
&AttributeLintKind::DocUnknownSpotlight { span } => {
|
||||
lints::DocUnknownSpotlight { sugg_span: span }.into_diag(dcx, level)
|
||||
}
|
||||
|
||||
&AttributeLintKind::DocUnknownPasses { name, span } => {
|
||||
lints::DocUnknownPasses { name, note_span: span }.into_diag(dcx, level)
|
||||
}
|
||||
|
||||
&AttributeLintKind::DocUnknownPlugins { span } => {
|
||||
lints::DocUnknownPlugins { label_span: span }.into_diag(dcx, level)
|
||||
}
|
||||
|
||||
&AttributeLintKind::DocUnknownAny { name } => {
|
||||
lints::DocUnknownAny { name }.into_diag(dcx, level)
|
||||
}
|
||||
|
||||
&AttributeLintKind::DocAutoCfgWrongLiteral => {
|
||||
lints::DocAutoCfgWrongLiteral.into_diag(dcx, level)
|
||||
}
|
||||
|
||||
&AttributeLintKind::DocTestTakesList => lints::DocTestTakesList.into_diag(dcx, level),
|
||||
|
||||
&AttributeLintKind::DocTestUnknown { name } => {
|
||||
|
||||
@@ -3303,53 +3303,6 @@ fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
||||
)]
|
||||
pub(crate) struct ExpectedNameValue;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown `doc` attribute `spotlight`")]
|
||||
#[note("`doc(spotlight)` was renamed to `doc(notable_trait)`")]
|
||||
#[note("`doc(spotlight)` is now a no-op")]
|
||||
pub(crate) struct DocUnknownSpotlight {
|
||||
#[suggestion(
|
||||
"use `notable_trait` instead",
|
||||
style = "short",
|
||||
applicability = "machine-applicable",
|
||||
code = "notable_trait"
|
||||
)]
|
||||
pub sugg_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown `doc` attribute `{$name}`")]
|
||||
#[note(
|
||||
"`doc` attribute `{$name}` no longer functions; see issue #44136 <https://github.com/rust-lang/rust/issues/44136>"
|
||||
)]
|
||||
#[note("`doc({$name})` is now a no-op")]
|
||||
pub(crate) struct DocUnknownPasses {
|
||||
pub name: Symbol,
|
||||
#[label("no longer functions")]
|
||||
pub note_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown `doc` attribute `plugins`")]
|
||||
#[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>"
|
||||
)]
|
||||
#[note("`doc(plugins)` is now a no-op")]
|
||||
pub(crate) struct DocUnknownPlugins {
|
||||
#[label("no longer functions")]
|
||||
pub label_span: Span,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown `doc` attribute `{$name}`")]
|
||||
pub(crate) struct DocUnknownAny {
|
||||
pub name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("expected boolean for `#[doc(auto_cfg = ...)]`")]
|
||||
pub(crate) struct DocAutoCfgWrongLiteral;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("`#[doc(test(...)]` takes a list of attributes")]
|
||||
pub(crate) struct DocTestTakesList;
|
||||
|
||||
@@ -656,11 +656,6 @@ pub enum DeprecatedSinceKind {
|
||||
pub enum AttributeLintKind {
|
||||
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
|
||||
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
|
||||
DocUnknownSpotlight { span: Span },
|
||||
DocUnknownPasses { name: Symbol, span: Span },
|
||||
DocUnknownPlugins { span: Span },
|
||||
DocUnknownAny { name: Symbol },
|
||||
DocAutoCfgWrongLiteral,
|
||||
DocTestTakesList,
|
||||
DocTestUnknown { name: Symbol },
|
||||
DocTestLiteral,
|
||||
|
||||
Reference in New Issue
Block a user