Skip to content

Commit

Permalink
Unrolled build for rust-lang#116231
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#116231 - DaniPopes:simpler-lint-array, r=Nilstrieb

Remove `rustc_lint_defs::lint_array`
  • Loading branch information
rust-timer authored Sep 29, 2023
2 parents b8536c1 + f1b7484 commit 0a867cd
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 36 deletions.
7 changes: 3 additions & 4 deletions compiler/rustc_lint/src/foreign_modules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,18 @@ use rustc_hir::def::DefKind;
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<'_>, (): ()) {
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_lint/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ pub use late::{check_crate, late_lint_mod, unerased_lint_store};
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" }

Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_lint/src/passes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
$(lints.extend_from_slice(&$pass::get_lints());)*
lints
Expand Down Expand Up @@ -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();
$(lints.extend_from_slice(&$pass::get_lints());)*
lints
Expand Down
13 changes: 2 additions & 11 deletions compiler/rustc_lint_defs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -808,7 +799,7 @@ macro_rules! impl_lint_pass {
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),*] }
}
};
}
Expand Down
10 changes: 4 additions & 6 deletions src/doc/unstable-book/src/language-features/plugin.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,22 @@ 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]);
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));
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ declare_clippy_lint! {
/// 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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down
2 changes: 1 addition & 1 deletion tests/ui-fulldeps/lint-pass-macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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! {
Expand Down
3 changes: 1 addition & 2 deletions tests/ui-fulldeps/plugin/auxiliary/lint-group-plugin-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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'");

Expand Down
6 changes: 3 additions & 3 deletions tests/ui-fulldeps/plugin/auxiliary/lint-plugin-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,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_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]);
Expand Down
6 changes: 3 additions & 3 deletions tests/ui-fulldeps/plugin/auxiliary/lint-tool-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,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, 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
Expand Down

0 comments on commit 0a867cd

Please sign in to comment.