mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Remove AttributeLintKind::DocUnknownInclude variant
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
use rustc_ast::ast::{AttrStyle, LitKind, MetaItemLit};
|
||||
use rustc_errors::{Diagnostic, msg};
|
||||
use rustc_errors::{Applicability, Diagnostic, msg};
|
||||
use rustc_feature::template;
|
||||
use rustc_hir::Target;
|
||||
use rustc_hir::attrs::{
|
||||
@@ -15,7 +15,7 @@
|
||||
use crate::context::{AcceptContext, FinalizeContext, Stage};
|
||||
use crate::errors::{
|
||||
DocAliasDuplicated, DocAutoCfgExpectsHideOrShow, DocAutoCfgHideShowExpectsList,
|
||||
DocAutoCfgHideShowUnexpectedItem, IllFormedAttributeInput,
|
||||
DocAutoCfgHideShowUnexpectedItem, DocUnknownInclude, IllFormedAttributeInput,
|
||||
};
|
||||
use crate::parser::{ArgParser, MetaItemOrLitParser, MetaItemParser, OwnedPathParser};
|
||||
use crate::session_diagnostics::{
|
||||
@@ -624,14 +624,19 @@ macro_rules! string_arg_and_crate_level {
|
||||
AttrStyle::Outer => "",
|
||||
AttrStyle::Inner => "!",
|
||||
};
|
||||
cx.emit_lint(
|
||||
let value = nv.value_as_lit().symbol;
|
||||
let span = path.span();
|
||||
cx.emit_dyn_lint(
|
||||
rustc_session::lint::builtin::INVALID_DOC_ATTRIBUTES,
|
||||
AttributeLintKind::DocUnknownInclude {
|
||||
inner,
|
||||
value: nv.value_as_lit().symbol,
|
||||
span: path.span(),
|
||||
move |dcx, level| {
|
||||
DocUnknownInclude {
|
||||
inner,
|
||||
value,
|
||||
sugg: (span, Applicability::MaybeIncorrect),
|
||||
}
|
||||
.into_diag(dcx, level)
|
||||
},
|
||||
path.span(),
|
||||
span,
|
||||
);
|
||||
}
|
||||
Some(name @ (sym::passes | sym::no_default_passes)) => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use rustc_errors::{DiagArgValue, MultiSpan};
|
||||
use rustc_errors::{Applicability, DiagArgValue, MultiSpan};
|
||||
use rustc_macros::{Diagnostic, Subdiagnostic};
|
||||
use rustc_span::{Span, Symbol};
|
||||
|
||||
@@ -193,3 +193,15 @@ pub(crate) struct DocAutoCfgHideShowUnexpectedItem {
|
||||
pub(crate) struct DocAutoCfgHideShowExpectsList {
|
||||
pub attr_name: Symbol,
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown `doc` attribute `include`")]
|
||||
pub(crate) struct DocUnknownInclude {
|
||||
pub inner: &'static str,
|
||||
pub value: Symbol,
|
||||
#[suggestion(
|
||||
"use `doc = include_str!` instead",
|
||||
code = "#{inner}[doc = include_str!(\"{value}\")]"
|
||||
)]
|
||||
pub sugg: (Span, Applicability),
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use std::any::Any;
|
||||
|
||||
use rustc_data_structures::sync::DynSend;
|
||||
use rustc_errors::{Applicability, Diag, DiagCtxtHandle, Diagnostic, Level};
|
||||
use rustc_errors::{Diag, DiagCtxtHandle, Diagnostic, Level};
|
||||
use rustc_hir::lints::{AttributeLintKind, FormatWarning};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::Session;
|
||||
@@ -43,15 +43,6 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
.into_diag(dcx, level)
|
||||
}
|
||||
|
||||
&AttributeLintKind::DocUnknownInclude { span, inner, value } => {
|
||||
lints::DocUnknownInclude {
|
||||
inner,
|
||||
value,
|
||||
sugg: (span, Applicability::MaybeIncorrect),
|
||||
}
|
||||
.into_diag(dcx, level)
|
||||
}
|
||||
|
||||
&AttributeLintKind::DocUnknownSpotlight { span } => {
|
||||
lints::DocUnknownSpotlight { sugg_span: span }.into_diag(dcx, level)
|
||||
}
|
||||
|
||||
@@ -3303,18 +3303,6 @@ fn add_to_diag<G: EmissionGuarantee>(self, diag: &mut Diag<'_, G>) {
|
||||
)]
|
||||
pub(crate) struct ExpectedNameValue;
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown `doc` attribute `include`")]
|
||||
pub(crate) struct DocUnknownInclude {
|
||||
pub inner: &'static str,
|
||||
pub value: Symbol,
|
||||
#[suggestion(
|
||||
"use `doc = include_str!` instead",
|
||||
code = "#{inner}[doc = include_str!(\"{value}\")]"
|
||||
)]
|
||||
pub sugg: (Span, Applicability),
|
||||
}
|
||||
|
||||
#[derive(Diagnostic)]
|
||||
#[diag("unknown `doc` attribute `spotlight`")]
|
||||
#[note("`doc(spotlight)` was renamed to `doc(notable_trait)`")]
|
||||
|
||||
@@ -656,7 +656,6 @@ pub enum DeprecatedSinceKind {
|
||||
pub enum AttributeLintKind {
|
||||
UnexpectedCfgName((Symbol, Span), Option<(Symbol, Span)>),
|
||||
UnexpectedCfgValue((Symbol, Span), Option<(Symbol, Span)>),
|
||||
DocUnknownInclude { span: Span, inner: &'static str, value: Symbol },
|
||||
DocUnknownSpotlight { span: Span },
|
||||
DocUnknownPasses { name: Symbol, span: Span },
|
||||
DocUnknownPlugins { span: Span },
|
||||
|
||||
Reference in New Issue
Block a user