Skip to content

Commit b60a516

Browse files
committed
Make LevelAndSource a struct
1 parent 978ed96 commit b60a516

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

clippy_lints/src/booleans.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ fn check_simplify_not(cx: &LateContext<'_>, msrv: Msrv, expr: &Expr<'_>) {
199199
&& !expr.span.from_expansion()
200200
&& !inner.span.from_expansion()
201201
&& let Some(suggestion) = simplify_not(cx, msrv, inner)
202-
&& cx.tcx.lint_level_at_node(NONMINIMAL_BOOL, expr.hir_id).0 != Level::Allow
202+
&& cx.tcx.lint_level_at_node(NONMINIMAL_BOOL, expr.hir_id).level != Level::Allow
203203
{
204204
use clippy_utils::sugg::{Sugg, has_enclosing_paren};
205205
let maybe_par = if let Some(sug) = Sugg::hir_opt(cx, inner) {
@@ -605,7 +605,7 @@ impl<'tcx> NonminimalBoolVisitor<'_, 'tcx> {
605605
}
606606
}
607607
let nonminimal_bool_lint = |mut suggestions: Vec<_>| {
608-
if self.cx.tcx.lint_level_at_node(NONMINIMAL_BOOL, e.hir_id).0 != Level::Allow {
608+
if self.cx.tcx.lint_level_at_node(NONMINIMAL_BOOL, e.hir_id).level != Level::Allow {
609609
suggestions.sort();
610610
span_lint_hir_and_then(
611611
self.cx,

clippy_lints/src/disallowed_script_idents.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl EarlyLintPass for DisallowedScriptIdents {
6969
// Implementation is heavily inspired by the implementation of [`non_ascii_idents`] lint:
7070
// https://github.com/rust-lang/rust/blob/master/compiler/rustc_lint/src/non_ascii_idents.rs
7171

72-
let check_disallowed_script_idents = cx.builder.lint_level(DISALLOWED_SCRIPT_IDENTS).0 != Level::Allow;
72+
let check_disallowed_script_idents = cx.builder.lint_level(DISALLOWED_SCRIPT_IDENTS).level != Level::Allow;
7373
if !check_disallowed_script_idents {
7474
return;
7575
}

clippy_lints/src/module_style.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ impl_lint_pass!(ModStyle => [MOD_MODULE_FILES, SELF_NAMED_MODULE_FILES]);
7373

7474
impl EarlyLintPass for ModStyle {
7575
fn check_crate(&mut self, cx: &EarlyContext<'_>, _: &ast::Crate) {
76-
if cx.builder.lint_level(MOD_MODULE_FILES).0 == Level::Allow
77-
&& cx.builder.lint_level(SELF_NAMED_MODULE_FILES).0 == Level::Allow
76+
if cx.builder.lint_level(MOD_MODULE_FILES).level == Level::Allow
77+
&& cx.builder.lint_level(SELF_NAMED_MODULE_FILES).level == Level::Allow
7878
{
7979
return;
8080
}

clippy_utils/src/lib.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ use rustc_hir::{
114114
use rustc_lexer::{TokenKind, tokenize};
115115
use rustc_lint::{LateContext, Level, Lint, LintContext};
116116
use rustc_middle::hir::place::PlaceBase;
117+
use rustc_middle::lint::LevelAndSource;
117118
use rustc_middle::mir::{AggregateKind, Operand, RETURN_PLACE, Rvalue, StatementKind, TerminatorKind};
118119
use rustc_middle::ty::adjustment::{Adjust, Adjustment, AutoBorrow};
119120
use rustc_middle::ty::fast_reject::SimplifiedType;
@@ -1976,7 +1977,7 @@ pub fn fulfill_or_allowed(cx: &LateContext<'_>, lint: &'static Lint, ids: impl I
19761977
let mut suppress_lint = false;
19771978

19781979
for id in ids {
1979-
let (level, _) = cx.tcx.lint_level_at_node(lint, id);
1980+
let LevelAndSource { level, .. } = cx.tcx.lint_level_at_node(lint, id);
19801981
if let Some(expectation) = level.get_expectation_id() {
19811982
cx.fulfill_expectation(expectation);
19821983
}
@@ -1998,7 +1999,7 @@ pub fn fulfill_or_allowed(cx: &LateContext<'_>, lint: &'static Lint, ids: impl I
19981999
/// make sure to use `span_lint_hir` functions to emit the lint. This ensures that
19992000
/// expectations at the checked nodes will be fulfilled.
20002001
pub fn is_lint_allowed(cx: &LateContext<'_>, lint: &'static Lint, id: HirId) -> bool {
2001-
cx.tcx.lint_level_at_node(lint, id).0 == Level::Allow
2002+
cx.tcx.lint_level_at_node(lint, id).level == Level::Allow
20022003
}
20032004

20042005
pub fn strip_pat_refs<'hir>(mut pat: &'hir Pat<'hir>) -> &'hir Pat<'hir> {

0 commit comments

Comments
 (0)