Remove rustc_lint_defs::lint_array
This commit is contained in:
parent
c01d8d238c
commit
f1b7484160
@ -5,19 +5,18 @@ use rustc_hir::def::DefKind;
|
|||||||
use rustc_middle::query::Providers;
|
use rustc_middle::query::Providers;
|
||||||
use rustc_middle::ty::layout::LayoutError;
|
use rustc_middle::ty::layout::LayoutError;
|
||||||
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
|
||||||
use rustc_session::lint::{lint_array, LintArray};
|
|
||||||
use rustc_span::{sym, Span, Symbol};
|
use rustc_span::{sym, Span, Symbol};
|
||||||
use rustc_target::abi::FIRST_VARIANT;
|
use rustc_target::abi::FIRST_VARIANT;
|
||||||
|
|
||||||
use crate::lints::{BuiltinClashingExtern, BuiltinClashingExternSub};
|
use crate::lints::{BuiltinClashingExtern, BuiltinClashingExternSub};
|
||||||
use crate::types;
|
use crate::{types, LintVec};
|
||||||
|
|
||||||
pub(crate) fn provide(providers: &mut Providers) {
|
pub(crate) fn provide(providers: &mut Providers) {
|
||||||
*providers = Providers { clashing_extern_declarations, ..*providers };
|
*providers = Providers { clashing_extern_declarations, ..*providers };
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn get_lints() -> LintArray {
|
pub(crate) fn get_lints() -> LintVec {
|
||||||
lint_array!(CLASHING_EXTERN_DECLARATIONS)
|
vec![CLASHING_EXTERN_DECLARATIONS]
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clashing_extern_declarations(tcx: TyCtxt<'_>, (): ()) {
|
fn clashing_extern_declarations(tcx: TyCtxt<'_>, (): ()) {
|
||||||
|
@ -130,7 +130,7 @@ pub use late::{check_crate, late_lint_mod, unerased_lint_store};
|
|||||||
pub use passes::{EarlyLintPass, LateLintPass};
|
pub use passes::{EarlyLintPass, LateLintPass};
|
||||||
pub use rustc_session::lint::Level::{self, *};
|
pub use rustc_session::lint::Level::{self, *};
|
||||||
pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId};
|
pub use rustc_session::lint::{BufferedEarlyLint, FutureIncompatibleInfo, Lint, LintId};
|
||||||
pub use rustc_session::lint::{LintArray, LintPass};
|
pub use rustc_session::lint::{LintPass, LintVec};
|
||||||
|
|
||||||
fluent_messages! { "../messages.ftl" }
|
fluent_messages! { "../messages.ftl" }
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ macro_rules! declare_combined_late_lint_pass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$v fn get_lints() -> $crate::LintArray {
|
$v fn get_lints() -> $crate::LintVec {
|
||||||
let mut lints = Vec::new();
|
let mut lints = Vec::new();
|
||||||
$(lints.extend_from_slice(&$pass::get_lints());)*
|
$(lints.extend_from_slice(&$pass::get_lints());)*
|
||||||
lints
|
lints
|
||||||
@ -226,7 +226,7 @@ macro_rules! declare_combined_early_lint_pass {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$v fn get_lints() -> $crate::LintArray {
|
$v fn get_lints() -> $crate::LintVec {
|
||||||
let mut lints = Vec::new();
|
let mut lints = Vec::new();
|
||||||
$(lints.extend_from_slice(&$pass::get_lints());)*
|
$(lints.extend_from_slice(&$pass::get_lints());)*
|
||||||
lints
|
lints
|
||||||
|
@ -785,16 +785,7 @@ macro_rules! declare_tool_lint {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Declares a static `LintArray` and return it as an expression.
|
pub type LintVec = Vec<&'static Lint>;
|
||||||
#[macro_export]
|
|
||||||
macro_rules! lint_array {
|
|
||||||
($( $lint:expr ),* ,) => { lint_array!( $($lint),* ) };
|
|
||||||
($( $lint:expr ),*) => {{
|
|
||||||
vec![$($lint),*]
|
|
||||||
}}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub type LintArray = Vec<&'static Lint>;
|
|
||||||
|
|
||||||
pub trait LintPass {
|
pub trait LintPass {
|
||||||
fn name(&self) -> &'static str;
|
fn name(&self) -> &'static str;
|
||||||
@ -808,7 +799,7 @@ macro_rules! impl_lint_pass {
|
|||||||
fn name(&self) -> &'static str { stringify!($ty) }
|
fn name(&self) -> &'static str { stringify!($ty) }
|
||||||
}
|
}
|
||||||
impl $ty {
|
impl $ty {
|
||||||
pub fn get_lints() -> $crate::LintArray { $crate::lint_array!($($lint),*) }
|
pub fn get_lints() -> $crate::LintVec { vec![$($lint),*] }
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -43,14 +43,14 @@ extern crate rustc_ast;
|
|||||||
|
|
||||||
// Load rustc as a plugin to get macros
|
// Load rustc as a plugin to get macros
|
||||||
extern crate rustc_driver;
|
extern crate rustc_driver;
|
||||||
#[macro_use]
|
|
||||||
extern crate rustc_lint;
|
extern crate rustc_lint;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
|
|
||||||
use rustc_driver::plugin::Registry;
|
|
||||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
|
|
||||||
use rustc_ast::ast;
|
use rustc_ast::ast;
|
||||||
|
use rustc_driver::plugin::Registry;
|
||||||
|
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
||||||
|
|
||||||
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
||||||
|
|
||||||
declare_lint_pass!(Pass => [TEST_LINT]);
|
declare_lint_pass!(Pass => [TEST_LINT]);
|
||||||
@ -58,9 +58,7 @@ declare_lint_pass!(Pass => [TEST_LINT]);
|
|||||||
impl EarlyLintPass for Pass {
|
impl EarlyLintPass for Pass {
|
||||||
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
|
fn check_item(&mut self, cx: &EarlyContext, it: &ast::Item) {
|
||||||
if it.ident.name.as_str() == "lintme" {
|
if it.ident.name.as_str() == "lintme" {
|
||||||
cx.lint(TEST_LINT, |lint| {
|
cx.lint(TEST_LINT, "item is named 'lintme'", |lint| lint.set_span(it.span));
|
||||||
lint.build("item is named 'lintme'").set_span(it.span).emit()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ declare_clippy_lint! {
|
|||||||
/// know the name of the lint.
|
/// know the name of the lint.
|
||||||
///
|
///
|
||||||
/// ### Known problems
|
/// ### Known problems
|
||||||
/// Only checks for lints associated using the
|
/// Only checks for lints associated using the `declare_lint_pass!` and
|
||||||
/// `declare_lint_pass!`, `impl_lint_pass!`, and `lint_array!` macros.
|
/// `impl_lint_pass!` macros.
|
||||||
///
|
///
|
||||||
/// ### Example
|
/// ### Example
|
||||||
/// ```rust,ignore
|
/// ```rust,ignore
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
extern crate rustc_middle;
|
extern crate rustc_middle;
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
|
|
||||||
use rustc_session::lint::{LintArray, LintPass};
|
use rustc_session::lint::{LintPass, LintVec};
|
||||||
use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
|
use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
|
|
||||||
use rustc_session::lint::{LintArray, LintPass};
|
use rustc_session::lint::{LintPass, LintVec};
|
||||||
use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
|
use rustc_session::{declare_lint, declare_lint_pass, impl_lint_pass};
|
||||||
|
|
||||||
declare_lint! {
|
declare_lint! {
|
||||||
|
@ -5,13 +5,12 @@
|
|||||||
// Load rustc as a plugin to get macros.
|
// Load rustc as a plugin to get macros.
|
||||||
extern crate rustc_driver;
|
extern crate rustc_driver;
|
||||||
extern crate rustc_hir;
|
extern crate rustc_hir;
|
||||||
#[macro_use]
|
|
||||||
extern crate rustc_lint;
|
extern crate rustc_lint;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
|
|
||||||
use rustc_driver::plugin::Registry;
|
use rustc_driver::plugin::Registry;
|
||||||
use rustc_lint::{LateContext, LateLintPass, LintArray, LintContext, LintId, LintPass};
|
use rustc_lint::{LateContext, LateLintPass, LintContext, LintId};
|
||||||
|
|
||||||
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
||||||
|
|
||||||
|
@ -6,14 +6,14 @@ extern crate rustc_ast;
|
|||||||
|
|
||||||
// Load rustc as a plugin to get macros
|
// Load rustc as a plugin to get macros
|
||||||
extern crate rustc_driver;
|
extern crate rustc_driver;
|
||||||
#[macro_use]
|
|
||||||
extern crate rustc_lint;
|
extern crate rustc_lint;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
|
|
||||||
|
use rustc_ast::ast;
|
||||||
use rustc_driver::plugin::Registry;
|
use rustc_driver::plugin::Registry;
|
||||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintPass};
|
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext};
|
||||||
use rustc_ast as ast;
|
|
||||||
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
declare_lint!(TEST_LINT, Warn, "Warn about items named 'lintme'");
|
||||||
|
|
||||||
declare_lint_pass!(Pass => [TEST_LINT]);
|
declare_lint_pass!(Pass => [TEST_LINT]);
|
||||||
|
@ -4,14 +4,14 @@ extern crate rustc_ast;
|
|||||||
|
|
||||||
// Load rustc as a plugin to get macros
|
// Load rustc as a plugin to get macros
|
||||||
extern crate rustc_driver;
|
extern crate rustc_driver;
|
||||||
#[macro_use]
|
|
||||||
extern crate rustc_lint;
|
extern crate rustc_lint;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rustc_session;
|
extern crate rustc_session;
|
||||||
|
|
||||||
use rustc_driver::plugin::Registry;
|
|
||||||
use rustc_lint::{EarlyContext, EarlyLintPass, LintArray, LintContext, LintId, LintPass};
|
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
|
use rustc_driver::plugin::Registry;
|
||||||
|
use rustc_lint::{EarlyContext, EarlyLintPass, LintContext, LintId};
|
||||||
|
|
||||||
declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
|
declare_tool_lint!(pub clippy::TEST_LINT, Warn, "Warn about stuff");
|
||||||
declare_tool_lint!(
|
declare_tool_lint!(
|
||||||
/// Some docs
|
/// Some docs
|
||||||
|
Loading…
x
Reference in New Issue
Block a user