Skip to content

Commit cb16543

Browse files
committed
Auto merge of #7449 - flip1995:remove-lints_enabled, r=camsteffen
Remove lints_enabled r? `@camsteffen` cc rust-lang/rust-clippy#7448 (comment) I haven't added a variant with `last_node_with_lint_attrs` yet, since I didn't see a usecase for this. Also this field is not documented, so I'm wondering how it behaves with command line lints and so on. changelog: none
2 parents 8da39e6 + d2c8f50 commit cb16543

15 files changed

+39
-60
lines changed

clippy_lints/src/cargo_common_metadata.rs

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

5-
use clippy_utils::diagnostics::span_lint;
6-
use clippy_utils::lints_enabled;
5+
use clippy_utils::{diagnostics::span_lint, is_lint_allowed};
76
use rustc_hir::{hir_id::CRATE_HIR_ID, Crate};
87
use rustc_lint::{LateContext, LateLintPass};
98
use rustc_session::{declare_tool_lint, impl_lint_pass};
@@ -85,7 +84,7 @@ fn is_empty_vec(value: &[String]) -> bool {
8584

8685
impl LateLintPass<'_> for CargoCommonMetadata {
8786
fn check_crate(&mut self, cx: &LateContext<'_>, _: &Crate<'_>) {
88-
if !lints_enabled(cx, &[CARGO_COMMON_METADATA], CRATE_HIR_ID) {
87+
if is_lint_allowed(cx, CARGO_COMMON_METADATA, CRATE_HIR_ID) {
8988
return;
9089
}
9190

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-
lints_enabled, search_same, ContainsName, SpanlessEq, SpanlessHash,
5+
is_lint_allowed, 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 lints_enabled(cx, &[IF_SAME_THEN_ELSE], win[0].hir_id);
341-
if lints_enabled(cx, &[IF_SAME_THEN_ELSE], win[1].hir_id);
340+
if !is_lint_allowed(cx, IF_SAME_THEN_ELSE, win[0].hir_id);
341+
if !is_lint_allowed(cx, IF_SAME_THEN_ELSE, win[1].hir_id);
342342
then {
343343
span_lint_and_note(
344344
cx,

clippy_lints/src/dereference.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::span_lint_and_sugg;
22
use clippy_utils::source::snippet_with_context;
33
use clippy_utils::ty::peel_mid_ty_refs;
4-
use clippy_utils::{get_parent_node, in_macro, is_allowed};
4+
use clippy_utils::{get_parent_node, in_macro, is_lint_allowed};
55
use rustc_ast::util::parser::PREC_PREFIX;
66
use rustc_errors::Applicability;
77
use rustc_hir::{BorrowKind, Expr, ExprKind, HirId, MatchSource, Mutability, Node, UnOp};
@@ -107,7 +107,7 @@ impl<'tcx> LateLintPass<'tcx> for Dereferencing {
107107

108108
match kind {
109109
RefOp::Method(target_mut)
110-
if !is_allowed(cx, EXPLICIT_DEREF_METHODS, expr.hir_id)
110+
if !is_lint_allowed(cx, EXPLICIT_DEREF_METHODS, expr.hir_id)
111111
&& is_linted_explicit_deref_position(parent, expr.hir_id, expr.span) =>
112112
{
113113
self.state = Some((

clippy_lints/src/derive.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use clippy_utils::diagnostics::{span_lint_and_help, span_lint_and_note, span_lint_and_then};
22
use clippy_utils::paths;
33
use clippy_utils::ty::{implements_trait, is_copy};
4-
use clippy_utils::{get_trait_def_id, is_allowed, is_automatically_derived, match_def_path};
4+
use clippy_utils::{get_trait_def_id, is_automatically_derived, is_lint_allowed, match_def_path};
55
use if_chain::if_chain;
66
use rustc_hir::def_id::DefId;
77
use rustc_hir::intravisit::{walk_expr, walk_fn, walk_item, FnKind, NestedVisitorMap, Visitor};
@@ -362,7 +362,7 @@ fn check_unsafe_derive_deserialize<'tcx>(
362362
if let ty::Adt(def, _) = ty.kind();
363363
if let Some(local_def_id) = def.did.as_local();
364364
let adt_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_def_id);
365-
if !is_allowed(cx, UNSAFE_DERIVE_DESERIALIZE, adt_hir_id);
365+
if !is_lint_allowed(cx, UNSAFE_DERIVE_DESERIALIZE, adt_hir_id);
366366
if cx.tcx.inherent_impls(def.did)
367367
.iter()
368368
.map(|imp_did| item_from_def_id(cx, *imp_did))

clippy_lints/src/inherent_impl.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! lint on inherent implementations
22
33
use clippy_utils::diagnostics::span_lint_and_note;
4-
use clippy_utils::{in_macro, is_allowed};
4+
use clippy_utils::{in_macro, is_lint_allowed};
55
use rustc_data_structures::fx::FxHashMap;
66
use rustc_hir::{def_id::LocalDefId, Crate, Item, ItemKind, Node};
77
use rustc_lint::{LateContext, LateLintPass};
@@ -59,7 +59,7 @@ impl<'tcx> LateLintPass<'tcx> for MultipleInherentImpl {
5959
.filter(|(&id, impls)| {
6060
impls.len() > 1
6161
// Check for `#[allow]` on the type definition
62-
&& !is_allowed(
62+
&& !is_lint_allowed(
6363
cx,
6464
MULTIPLE_INHERENT_IMPL,
6565
cx.tcx.hir().local_def_id_to_hir_id(id),
@@ -123,7 +123,7 @@ fn get_impl_span(cx: &LateContext<'_>, id: LocalDefId) -> Option<Span> {
123123
..
124124
}) = cx.tcx.hir().get(id)
125125
{
126-
(!in_macro(span) && impl_item.generics.params.is_empty() && !is_allowed(cx, MULTIPLE_INHERENT_IMPL, id))
126+
(!in_macro(span) && impl_item.generics.params.is_empty() && !is_lint_allowed(cx, MULTIPLE_INHERENT_IMPL, id))
127127
.then(|| span)
128128
} else {
129129
None

clippy_lints/src/len_zero.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_then};
22
use clippy_utils::source::snippet_with_applicability;
3-
use clippy_utils::{get_item_name, get_parent_as_impl, is_allowed};
3+
use clippy_utils::{get_item_name, get_parent_as_impl, is_lint_allowed};
44
use if_chain::if_chain;
55
use rustc_ast::ast::LitKind;
66
use rustc_errors::Applicability;
@@ -139,7 +139,7 @@ impl<'tcx> LateLintPass<'tcx> for LenZero {
139139
if let Some(ty_id) = cx.qpath_res(ty_path, imp.self_ty.hir_id).opt_def_id();
140140
if let Some(local_id) = ty_id.as_local();
141141
let ty_hir_id = cx.tcx.hir().local_def_id_to_hir_id(local_id);
142-
if !is_allowed(cx, LEN_WITHOUT_IS_EMPTY, ty_hir_id);
142+
if !is_lint_allowed(cx, LEN_WITHOUT_IS_EMPTY, ty_hir_id);
143143
if let Some(output) = parse_len_output(cx, cx.tcx.fn_sig(item.def_id).skip_binder());
144144
then {
145145
let (name, kind) = match cx.tcx.hir().find(ty_hir_id) {

clippy_lints/src/manual_map.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use clippy_utils::diagnostics::span_lint_and_sugg;
33
use clippy_utils::source::{snippet_with_applicability, snippet_with_context};
44
use clippy_utils::ty::{is_type_diagnostic_item, peel_mid_ty_refs_is_mutable};
55
use clippy_utils::{
6-
can_move_expr_to_closure, in_constant, is_allowed, is_else_clause, is_lang_ctor, path_to_local_id,
6+
can_move_expr_to_closure, in_constant, is_else_clause, is_lang_ctor, is_lint_allowed, path_to_local_id,
77
peel_hir_expr_refs,
88
};
99
use rustc_ast::util::parser::PREC_POSTFIX;
@@ -102,7 +102,7 @@ impl LateLintPass<'_> for ManualMap {
102102

103103
// These two lints will go back and forth with each other.
104104
if cx.typeck_results().expr_ty(some_expr) == cx.tcx.types.unit
105-
&& !is_allowed(cx, OPTION_MAP_UNIT_FN, expr.hir_id)
105+
&& !is_lint_allowed(cx, OPTION_MAP_UNIT_FN, expr.hir_id)
106106
{
107107
return;
108108
}
@@ -146,7 +146,7 @@ impl LateLintPass<'_> for ManualMap {
146146
},
147147
_ => {
148148
if path_to_local_id(some_expr, id)
149-
&& !is_allowed(cx, MATCH_AS_REF, expr.hir_id)
149+
&& !is_lint_allowed(cx, MATCH_AS_REF, expr.hir_id)
150150
&& binding_ref.is_some()
151151
{
152152
return;

clippy_lints/src/matches.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use clippy_utils::sugg::Sugg;
77
use clippy_utils::ty::{implements_trait, is_type_diagnostic_item, match_type, peel_mid_ty_refs};
88
use clippy_utils::visitors::LocalUsedVisitor;
99
use clippy_utils::{
10-
get_parent_expr, in_macro, is_allowed, is_expn_of, is_lang_ctor, is_refutable, is_wild, meets_msrv, msrvs,
10+
get_parent_expr, in_macro, is_expn_of, is_lang_ctor, is_lint_allowed, is_refutable, is_wild, meets_msrv, msrvs,
1111
path_to_local, path_to_local_id, peel_hir_pat_refs, peel_n_hir_expr_refs, recurse_or_patterns, remove_blocks,
1212
strip_pat_refs,
1313
};
@@ -707,7 +707,7 @@ fn check_single_match(cx: &LateContext<'_>, ex: &Expr<'_>, arms: &[Arm<'_>], exp
707707
};
708708

709709
let ty = cx.typeck_results().expr_ty(ex);
710-
if *ty.kind() != ty::Bool || is_allowed(cx, MATCH_BOOL, ex.hir_id) {
710+
if *ty.kind() != ty::Bool || is_lint_allowed(cx, MATCH_BOOL, ex.hir_id) {
711711
check_single_match_single_pattern(cx, ex, arms, expr, els);
712712
check_single_match_opt_like(cx, ex, arms, expr, ty, els);
713713
}

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::lints_enabled;
4+
use clippy_utils::is_lint_allowed;
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 !lints_enabled(cx, &[MULTIPLE_CRATE_VERSIONS], CRATE_HIR_ID) {
42+
if is_lint_allowed(cx, MULTIPLE_CRATE_VERSIONS, CRATE_HIR_ID) {
4343
return;
4444
}
4545

clippy_lints/src/ptr.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use clippy_utils::diagnostics::{span_lint, span_lint_and_sugg, span_lint_and_the
44
use clippy_utils::ptr::get_spans;
55
use clippy_utils::source::snippet_opt;
66
use clippy_utils::ty::{is_type_diagnostic_item, match_type, walk_ptrs_hir_ty};
7-
use clippy_utils::{expr_path_res, is_allowed, match_any_def_paths, paths};
7+
use clippy_utils::{expr_path_res, is_lint_allowed, match_any_def_paths, paths};
88
use if_chain::if_chain;
99
use rustc_errors::Applicability;
1010
use rustc_hir::{
@@ -246,7 +246,7 @@ fn check_fn(cx: &LateContext<'_>, decl: &FnDecl<'_>, fn_id: HirId, opt_body_id:
246246
for (idx, (arg, ty)) in decl.inputs.iter().zip(fn_ty.inputs()).enumerate() {
247247
// Honor the allow attribute on parameters. See issue 5644.
248248
if let Some(body) = &body {
249-
if is_allowed(cx, PTR_ARG, body.params[idx].hir_id) {
249+
if is_lint_allowed(cx, PTR_ARG, body.params[idx].hir_id) {
250250
continue;
251251
}
252252
}

0 commit comments

Comments
 (0)