mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-21 22:34:05 +00:00
Apply review comments + use shallow_lint_levels_on
This commit is contained in:
parent
8a40884e1c
commit
ddad55f6c2
@ -432,7 +432,7 @@ fn late_lint_crate<'tcx>(tcx: TyCtxt<'tcx>) {
|
||||
let mut filtered_passes: Vec<Box<dyn LateLintPass<'tcx>>> = passes
|
||||
.into_iter()
|
||||
.filter(|pass| {
|
||||
let lints = LintPass::get_lints(pass);
|
||||
let lints = (**pass).get_lints();
|
||||
!lints.iter().all(|lint| lints_that_dont_need_to_run.contains(&LintId::of(lint)))
|
||||
})
|
||||
.collect();
|
||||
|
@ -2,8 +2,8 @@ use rustc_ast_pretty::pprust;
|
||||
use rustc_data_structures::fx::{FxIndexMap, FxIndexSet};
|
||||
use rustc_errors::{Diag, LintDiagnostic, MultiSpan};
|
||||
use rustc_feature::{Features, GateIssue};
|
||||
use rustc_hir::HirId;
|
||||
use rustc_hir::intravisit::{self, Visitor};
|
||||
use rustc_hir::{CRATE_HIR_ID, HirId};
|
||||
use rustc_index::IndexVec;
|
||||
use rustc_middle::bug;
|
||||
use rustc_middle::hir::nested_filter;
|
||||
@ -118,12 +118,22 @@ impl LintLevelSets {
|
||||
fn lints_that_dont_need_to_run(tcx: TyCtxt<'_>, (): ()) -> FxIndexSet<LintId> {
|
||||
let store = unerased_lint_store(&tcx.sess);
|
||||
|
||||
let map = tcx.shallow_lint_levels_on(rustc_hir::CRATE_OWNER_ID);
|
||||
|
||||
let dont_need_to_run: FxIndexSet<LintId> = store
|
||||
.get_lints()
|
||||
.into_iter()
|
||||
.filter_map(|lint| {
|
||||
if !lint.eval_always && lint.default_level(tcx.sess.edition()) == Level::Allow {
|
||||
Some(LintId::of(lint))
|
||||
if !lint.eval_always {
|
||||
let lint_level = map.lint_level_id_at_node(tcx, LintId::of(lint), CRATE_HIR_ID);
|
||||
if matches!(lint_level, (Level::Allow, ..))
|
||||
|| (matches!(lint_level, (.., LintLevelSource::Default)))
|
||||
&& lint.default_level(tcx.sess.edition()) == Level::Allow
|
||||
{
|
||||
Some(LintId::of(lint))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
@ -372,7 +382,7 @@ impl<'tcx> Visitor<'tcx> for LintLevelMaximum<'tcx> {
|
||||
) {
|
||||
let store = unerased_lint_store(self.tcx.sess);
|
||||
let Some(meta) = attribute.meta() else { return };
|
||||
// SAFETY: Lint attributes are always a metalist inside a
|
||||
// Lint attributes are always a metalist inside a
|
||||
// metalist (even with just one lint).
|
||||
let Some(meta_item_list) = meta.meta_item_list() else { return };
|
||||
|
||||
@ -387,7 +397,7 @@ impl<'tcx> Visitor<'tcx> for LintLevelMaximum<'tcx> {
|
||||
.collect::<Vec<&str>>()
|
||||
.join("::");
|
||||
let Ok(lints) = store.find_lints(
|
||||
// SAFETY: Lint attributes can only have literals
|
||||
// Lint attributes can only have literals
|
||||
ident,
|
||||
) else {
|
||||
return;
|
||||
|
@ -968,14 +968,3 @@ macro_rules! declare_lint_pass {
|
||||
$crate::impl_lint_pass!($name => [$($lint),*]);
|
||||
};
|
||||
}
|
||||
|
||||
#[allow(rustc::lint_pass_impl_without_macro)]
|
||||
impl<P: LintPass + ?Sized> LintPass for Box<P> {
|
||||
fn name(&self) -> &'static str {
|
||||
(**self).name()
|
||||
}
|
||||
|
||||
fn get_lints(&self) -> LintVec {
|
||||
(**self).get_lints()
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ use rustc_session::declare_lint_pass;
|
||||
use rustc_span::Span;
|
||||
|
||||
/// Ensures that Constant-time Function Evaluation is being done (specifically, MIR lint passes).
|
||||
/// See rust-lang/rust#125116 for more info.
|
||||
/// As Clippy deactivates codegen, this lint ensures that CTFE (used in hard errors) is still ran.
|
||||
#[clippy::version = "1.82.0"]
|
||||
pub static CLIPPY_CTFE: &Lint = &Lint {
|
||||
name: &"clippy::CLIPPY_CTFE",
|
||||
|
@ -65,7 +65,7 @@ extern crate clippy_utils;
|
||||
#[cfg_attr(feature = "internal", allow(clippy::missing_clippy_version_attribute))]
|
||||
mod utils;
|
||||
|
||||
pub mod ctfe; // Very important lint (rust#125116)
|
||||
pub mod ctfe; // Very important lint, do not remove (rust#125116)
|
||||
pub mod declared_lints;
|
||||
pub mod deprecated_lints;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user