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