Skip to content

Commit 8da39e6

Browse files
committed
Auto merge of rust-lang#7448 - flip1995:run_lints-rename, r=llogiq
Rename run_lints -> lints_enabled Just a quick rename of a utilities function. `run_lints` kinda suggested that the lints were run by this function. But the only thing this function does is to check if the lints are enabled in the context of the `hir_id` changelog: none
2 parents 28e7699 + 795868d commit 8da39e6

File tree

6 files changed

+19
-19
lines changed

6 files changed

+19
-19
lines changed

clippy_lints/src/cargo_common_metadata.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
use std::path::PathBuf;
44

55
use clippy_utils::diagnostics::span_lint;
6-
use clippy_utils::run_lints;
6+
use clippy_utils::lints_enabled;
77
use rustc_hir::{hir_id::CRATE_HIR_ID, Crate};
88
use rustc_lint::{LateContext, LateLintPass};
99
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -85,7 +85,7 @@ fn is_empty_vec(value: &[String]) -> bool {
8585

8686
impl LateLintPass<'_> for CargoCommonMetadata {
8787
fn check_crate(&mut self, cx: &LateContext<'_>, _: &Crate<'_>) {
88-
if !run_lints(cx, &[CARGO_COMMON_METADATA], CRATE_HIR_ID) {
88+
if !lints_enabled(cx, &[CARGO_COMMON_METADATA], CRATE_HIR_ID) {
8989
return;
9090
}
9191

clippy_lints/src/copies.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use clippy_utils::diagnostics::{span_lint_and_note, span_lint_and_then};
22
use clippy_utils::source::{first_line_of_span, indent_of, reindent_multiline, snippet, snippet_opt};
33
use clippy_utils::{
44
both, count_eq, eq_expr_value, get_enclosing_block, get_parent_expr, if_sequence, in_macro, is_else_clause,
5-
run_lints, search_same, ContainsName, SpanlessEq, SpanlessHash,
5+
lints_enabled, search_same, ContainsName, SpanlessEq, SpanlessHash,
66
};
77
use if_chain::if_chain;
88
use rustc_data_structures::fx::FxHashSet;
@@ -337,8 +337,8 @@ fn scan_block_for_eq(cx: &LateContext<'tcx>, blocks: &[&Block<'tcx>]) -> Option<
337337
if block_expr_eq;
338338
if l_stmts.len() == r_stmts.len();
339339
if l_stmts.len() == current_start_eq;
340-
if run_lints(cx, &[IF_SAME_THEN_ELSE], win[0].hir_id);
341-
if run_lints(cx, &[IF_SAME_THEN_ELSE], win[1].hir_id);
340+
if lints_enabled(cx, &[IF_SAME_THEN_ELSE], win[0].hir_id);
341+
if lints_enabled(cx, &[IF_SAME_THEN_ELSE], win[1].hir_id);
342342
then {
343343
span_lint_and_note(
344344
cx,

clippy_lints/src/multiple_crate_versions.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! lint on multiple versions of a crate being used
22
33
use clippy_utils::diagnostics::span_lint;
4-
use clippy_utils::run_lints;
4+
use clippy_utils::lints_enabled;
55
use rustc_hir::def_id::LOCAL_CRATE;
66
use rustc_hir::{Crate, CRATE_HIR_ID};
77
use rustc_lint::{LateContext, LateLintPass};
@@ -39,7 +39,7 @@ declare_lint_pass!(MultipleCrateVersions => [MULTIPLE_CRATE_VERSIONS]);
3939

4040
impl LateLintPass<'_> for MultipleCrateVersions {
4141
fn check_crate(&mut self, cx: &LateContext<'_>, _: &Crate<'_>) {
42-
if !run_lints(cx, &[MULTIPLE_CRATE_VERSIONS], CRATE_HIR_ID) {
42+
if !lints_enabled(cx, &[MULTIPLE_CRATE_VERSIONS], CRATE_HIR_ID) {
4343
return;
4444
}
4545

clippy_lints/src/utils/internal_lints.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_and_sug
33
use clippy_utils::source::snippet;
44
use clippy_utils::ty::match_type;
55
use clippy_utils::{
6-
is_else_clause, is_expn_of, is_expr_path_def_path, match_def_path, method_calls, path_to_res, paths, run_lints,
6+
is_else_clause, is_expn_of, is_expr_path_def_path, lints_enabled, match_def_path, method_calls, path_to_res, paths,
77
SpanlessEq,
88
};
99
use if_chain::if_chain;
@@ -353,7 +353,7 @@ impl_lint_pass!(LintWithoutLintPass => [DEFAULT_LINT, LINT_WITHOUT_LINT_PASS]);
353353

354354
impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass {
355355
fn check_item(&mut self, cx: &LateContext<'tcx>, item: &'tcx Item<'_>) {
356-
if !run_lints(cx, &[DEFAULT_LINT], item.hir_id()) {
356+
if !lints_enabled(cx, &[DEFAULT_LINT], item.hir_id()) {
357357
return;
358358
}
359359

@@ -411,7 +411,7 @@ impl<'tcx> LateLintPass<'tcx> for LintWithoutLintPass {
411411
}
412412

413413
fn check_crate_post(&mut self, cx: &LateContext<'tcx>, _: &'tcx Crate<'_>) {
414-
if !run_lints(cx, &[LINT_WITHOUT_LINT_PASS], CRATE_HIR_ID) {
414+
if !lints_enabled(cx, &[LINT_WITHOUT_LINT_PASS], CRATE_HIR_ID) {
415415
return;
416416
}
417417

@@ -497,7 +497,7 @@ impl_lint_pass!(CompilerLintFunctions => [COMPILER_LINT_FUNCTIONS]);
497497

498498
impl<'tcx> LateLintPass<'tcx> for CompilerLintFunctions {
499499
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
500-
if !run_lints(cx, &[COMPILER_LINT_FUNCTIONS], expr.hir_id) {
500+
if !lints_enabled(cx, &[COMPILER_LINT_FUNCTIONS], expr.hir_id) {
501501
return;
502502
}
503503

@@ -526,7 +526,7 @@ declare_lint_pass!(OuterExpnDataPass => [OUTER_EXPN_EXPN_DATA]);
526526

527527
impl<'tcx> LateLintPass<'tcx> for OuterExpnDataPass {
528528
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
529-
if !run_lints(cx, &[OUTER_EXPN_EXPN_DATA], expr.hir_id) {
529+
if !lints_enabled(cx, &[OUTER_EXPN_EXPN_DATA], expr.hir_id) {
530530
return;
531531
}
532532

@@ -576,7 +576,7 @@ declare_lint_pass!(CollapsibleCalls => [COLLAPSIBLE_SPAN_LINT_CALLS]);
576576

577577
impl<'tcx> LateLintPass<'tcx> for CollapsibleCalls {
578578
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
579-
if !run_lints(cx, &[COLLAPSIBLE_SPAN_LINT_CALLS], expr.hir_id) {
579+
if !lints_enabled(cx, &[COLLAPSIBLE_SPAN_LINT_CALLS], expr.hir_id) {
580580
return;
581581
}
582582

@@ -757,7 +757,7 @@ declare_lint_pass!(MatchTypeOnDiagItem => [MATCH_TYPE_ON_DIAGNOSTIC_ITEM]);
757757

758758
impl<'tcx> LateLintPass<'tcx> for MatchTypeOnDiagItem {
759759
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx hir::Expr<'_>) {
760-
if !run_lints(cx, &[MATCH_TYPE_ON_DIAGNOSTIC_ITEM], expr.hir_id) {
760+
if !lints_enabled(cx, &[MATCH_TYPE_ON_DIAGNOSTIC_ITEM], expr.hir_id) {
761761
return;
762762
}
763763

clippy_lints/src/wildcard_dependencies.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use clippy_utils::diagnostics::span_lint;
2-
use clippy_utils::run_lints;
2+
use clippy_utils::lints_enabled;
33
use rustc_hir::{hir_id::CRATE_HIR_ID, Crate};
44
use rustc_lint::{LateContext, LateLintPass};
55
use rustc_session::{declare_lint_pass, declare_tool_lint};
@@ -31,7 +31,7 @@ declare_lint_pass!(WildcardDependencies => [WILDCARD_DEPENDENCIES]);
3131

3232
impl LateLintPass<'_> for WildcardDependencies {
3333
fn check_crate(&mut self, cx: &LateContext<'_>, _: &Crate<'_>) {
34-
if !run_lints(cx, &[WILDCARD_DEPENDENCIES], CRATE_HIR_ID) {
34+
if !lints_enabled(cx, &[WILDCARD_DEPENDENCIES], CRATE_HIR_ID) {
3535
return;
3636
}
3737

clippy_utils/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1546,12 +1546,12 @@ pub fn fn_def_id(cx: &LateContext<'_>, expr: &Expr<'_>) -> Option<DefId> {
15461546
///
15471547
/// ```ignore
15481548
/// #[deny(clippy::YOUR_AWESOME_LINT)]
1549-
/// println!("Hello, World!"); // <- Clippy code: run_lints(cx, &[YOUR_AWESOME_LINT], id) == true
1549+
/// println!("Hello, World!"); // <- Clippy code: lints_enabled(cx, &[YOUR_AWESOME_LINT], id) == true
15501550
///
15511551
/// #[allow(clippy::YOUR_AWESOME_LINT)]
1552-
/// println!("See you soon!"); // <- Clippy code: run_lints(cx, &[YOUR_AWESOME_LINT], id) == false
1552+
/// println!("See you soon!"); // <- Clippy code: lints_enabled(cx, &[YOUR_AWESOME_LINT], id) == false
15531553
/// ```
1554-
pub fn run_lints(cx: &LateContext<'_>, lints: &[&'static Lint], id: HirId) -> bool {
1554+
pub fn lints_enabled(cx: &LateContext<'_>, lints: &[&'static Lint], id: HirId) -> bool {
15551555
lints.iter().any(|lint| {
15561556
matches!(
15571557
cx.tcx.lint_level_at_node(lint, id),

0 commit comments

Comments
 (0)