mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
Remove BuiltinLintDiag
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
use rustc_hir::lints::AttributeLintKind;
|
||||
use rustc_hir::{AttrArgs, AttrItem, AttrPath, Attribute, HashIgnoredAttrId, Target};
|
||||
use rustc_session::Session;
|
||||
use rustc_session::lint::{BuiltinLintDiag, LintId};
|
||||
use rustc_session::lint::LintId;
|
||||
use rustc_span::{DUMMY_SP, Ident, Span, Symbol, sym};
|
||||
|
||||
use crate::context::{AcceptContext, FinalizeContext, FinalizeFn, SharedContext, Stage};
|
||||
@@ -124,14 +124,7 @@ pub fn parse_limited_all<'a>(
|
||||
target,
|
||||
OmitDoc::Skip,
|
||||
std::convert::identity,
|
||||
|lint_id, span, kind| {
|
||||
sess.psess.buffer_lint(
|
||||
lint_id.lint,
|
||||
span,
|
||||
target_node_id,
|
||||
BuiltinLintDiag::AttributeLint(kind),
|
||||
)
|
||||
},
|
||||
|lint_id, span, kind| sess.psess.buffer_lint(lint_id.lint, span, target_node_id, kind),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -230,12 +223,7 @@ pub fn parse_single_args<T, I>(
|
||||
let mut parser =
|
||||
Self { features, tools: None, parse_only: None, sess, stage: Early { emit_errors } };
|
||||
let mut emit_lint = |lint_id: LintId, span: Span, kind: AttributeLintKind| {
|
||||
sess.psess.buffer_lint(
|
||||
lint_id.lint,
|
||||
span,
|
||||
target_node_id,
|
||||
BuiltinLintDiag::AttributeLint(kind),
|
||||
)
|
||||
sess.psess.buffer_lint(lint_id.lint, span, target_node_id, kind)
|
||||
};
|
||||
if let Some(safety) = attr_safety {
|
||||
parser.check_attribute_safety(&attr_path, inner_span, safety, &mut emit_lint)
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
use rustc_hir::lints::AttributeLintKind;
|
||||
use rustc_parse::parse_in;
|
||||
use rustc_session::errors::report_lit_error;
|
||||
use rustc_session::lint::BuiltinLintDiag;
|
||||
use rustc_session::lint::builtin::ILL_FORMED_ATTRIBUTE_INPUT;
|
||||
use rustc_session::parse::ParseSess;
|
||||
use rustc_span::{Span, Symbol, sym};
|
||||
@@ -208,11 +207,11 @@ fn emit_malformed_attribute(
|
||||
ILL_FORMED_ATTRIBUTE_INPUT,
|
||||
span,
|
||||
ast::CRATE_NODE_ID,
|
||||
BuiltinLintDiag::AttributeLint(AttributeLintKind::IllFormedAttributeInput {
|
||||
AttributeLintKind::IllFormedAttributeInput {
|
||||
suggestions: suggestions.clone(),
|
||||
docs: template.docs,
|
||||
help: None,
|
||||
}),
|
||||
},
|
||||
);
|
||||
} else {
|
||||
suggestions.sort();
|
||||
|
||||
@@ -5,11 +5,11 @@
|
||||
use rustc_data_structures::fx::FxIndexMap;
|
||||
use rustc_data_structures::sync::{DynSend, DynSync};
|
||||
use rustc_error_messages::MultiSpan;
|
||||
use rustc_lint_defs::{BuiltinLintDiag, Lint, LintId};
|
||||
use rustc_lint_defs::{AttributeLintKind, Lint, LintId};
|
||||
|
||||
use crate::{Diag, DiagCtxtHandle, Diagnostic, Level};
|
||||
|
||||
/// We can't implement `Diagnostic` for `BuiltinLintDiag`, because decorating some of its
|
||||
/// We can't implement `Diagnostic` for `AttributeLintKind`, because decorating some of its
|
||||
/// variants requires types we don't have yet. So, handle that case separately.
|
||||
pub enum DecorateDiagCompat {
|
||||
/// The third argument of the closure is a `Session`. However, due to the dependency tree,
|
||||
@@ -22,7 +22,7 @@ pub enum DecorateDiagCompat {
|
||||
+ 'static,
|
||||
>,
|
||||
),
|
||||
Builtin(BuiltinLintDiag),
|
||||
Builtin(AttributeLintKind),
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for DecorateDiagCompat {
|
||||
@@ -38,9 +38,9 @@ fn from(d: D) -> Self {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<BuiltinLintDiag> for DecorateDiagCompat {
|
||||
impl From<AttributeLintKind> for DecorateDiagCompat {
|
||||
#[inline]
|
||||
fn from(b: BuiltinLintDiag) -> Self {
|
||||
fn from(b: AttributeLintKind) -> Self {
|
||||
Self::Builtin(b)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
use crate::context::{EarlyContext, LintContext, LintStore};
|
||||
use crate::passes::{EarlyLintPass, EarlyLintPassObject};
|
||||
use crate::{DecorateBuiltinLint, DiagAndSess};
|
||||
use crate::{DecorateAttrLint, DiagAndSess};
|
||||
|
||||
pub(super) mod diagnostics;
|
||||
|
||||
@@ -42,10 +42,10 @@ fn check_id(&mut self, id: ast::NodeId) {
|
||||
self.context.opt_span_lint(
|
||||
lint_id.lint,
|
||||
span,
|
||||
DecorateBuiltinLint {
|
||||
DecorateAttrLint {
|
||||
sess: self.context.sess(),
|
||||
tcx: self.tcx,
|
||||
diagnostic: b,
|
||||
diagnostic: &b,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
use rustc_hir::lints::{AttributeLintKind, FormatWarning};
|
||||
use rustc_middle::ty::TyCtxt;
|
||||
use rustc_session::Session;
|
||||
use rustc_session::lint::BuiltinLintDiag;
|
||||
|
||||
use crate::lints;
|
||||
|
||||
@@ -25,25 +24,6 @@ fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
}
|
||||
}
|
||||
|
||||
/// This is a diagnostic struct that will decorate a `BuiltinLintDiag`
|
||||
/// Directly creating the lint structs is expensive, using this will only decorate the lint structs when needed.
|
||||
pub struct DecorateBuiltinLint<'sess, 'tcx> {
|
||||
pub sess: &'sess Session,
|
||||
pub tcx: Option<TyCtxt<'tcx>>,
|
||||
pub diagnostic: BuiltinLintDiag,
|
||||
}
|
||||
|
||||
impl<'a> Diagnostic<'a, ()> for DecorateBuiltinLint<'_, '_> {
|
||||
fn into_diag(self, dcx: DiagCtxtHandle<'a>, level: Level) -> Diag<'a, ()> {
|
||||
match self.diagnostic {
|
||||
BuiltinLintDiag::AttributeLint(kind) => {
|
||||
DecorateAttrLint { sess: self.sess, tcx: self.tcx, diagnostic: &kind }
|
||||
.into_diag(dcx, level)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// This is a diagnostic struct that will decorate a `AttributeLintKind`
|
||||
/// Directly creating the lint structs is expensive, using this will only decorate the lint structs when needed.
|
||||
pub struct DecorateAttrLint<'a, 'sess, 'tcx> {
|
||||
|
||||
@@ -129,7 +129,7 @@
|
||||
#[rustfmt::skip]
|
||||
pub use builtin::{MissingDoc, SoftLints};
|
||||
pub use context::{EarlyContext, LateContext, LintContext, LintStore};
|
||||
pub use early::diagnostics::{DecorateAttrLint, DecorateBuiltinLint, DiagAndSess};
|
||||
pub use early::diagnostics::{DecorateAttrLint, DiagAndSess};
|
||||
pub use early::{EarlyCheckNode, check_ast_node};
|
||||
pub use late::{check_crate, late_lint_mod, unerased_lint_store};
|
||||
pub use levels::LintLevelsBuilder;
|
||||
|
||||
@@ -652,13 +652,6 @@ pub enum DeprecatedSinceKind {
|
||||
InVersion(String),
|
||||
}
|
||||
|
||||
// This could be a closure, but then implementing derive trait
|
||||
// becomes hacky (and it gets allocated).
|
||||
#[derive(Debug)]
|
||||
pub enum BuiltinLintDiag {
|
||||
AttributeLint(AttributeLintKind),
|
||||
}
|
||||
|
||||
#[derive(Debug, HashStable_Generic)]
|
||||
pub enum AttributeLintKind {
|
||||
UnusedDuplicate {
|
||||
|
||||
Reference in New Issue
Block a user