Skip to content

Commit 3fd8c5a

Browse files
dingxiangfei2009ehuss
authored andcommitted
check lint level at session level
1 parent 1b7f6ac commit 3fd8c5a

File tree

2 files changed

+8
-14
lines changed

2 files changed

+8
-14
lines changed

compiler/rustc_hir_analysis/src/check/region.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use rustc_hir::def_id::DefId;
1414
use rustc_hir::intravisit::{self, Visitor};
1515
use rustc_hir::{Arm, Block, Expr, LetStmt, Pat, PatKind, Stmt};
1616
use rustc_index::Idx;
17+
use rustc_lint_defs::LintId;
1718
use rustc_middle::bug;
1819
use rustc_middle::middle::region::*;
1920
use rustc_middle::ty::TyCtxt;
@@ -172,10 +173,11 @@ fn resolve_block<'tcx>(visitor: &mut RegionResolutionVisitor<'tcx>, blk: &'tcx h
172173
let edition = blk.span.edition();
173174
if edition.at_least_rust_2024() {
174175
visitor.terminating_scopes.insert(local_id);
175-
} else if !matches!(
176-
visitor.tcx.lint_level_at_node(lint::builtin::TAIL_EXPR_DROP_ORDER, blk.hir_id),
177-
(lint::Level::Allow, _)
178-
) {
176+
} else if !visitor
177+
.tcx
178+
.lints_that_dont_need_to_run(())
179+
.contains(&LintId::of(lint::builtin::TAIL_EXPR_DROP_ORDER))
180+
{
179181
// If this temporary scope will be changing once the codebase adopts Rust 2024,
180182
// and we are linting about possible semantic changes that would result,
181183
// then record this node-id in the field `backwards_incompatible_scope`

compiler/rustc_mir_transform/src/lint_tail_expr_drop_order.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_middle::ty::{self, Ty, TyCtxt};
1919
use rustc_mir_dataflow::impls::MaybeInitializedPlaces;
2020
use rustc_mir_dataflow::move_paths::{LookupResult, MoveData, MovePathIndex};
2121
use rustc_mir_dataflow::{Analysis, MaybeReachable, ResultsCursor};
22-
use rustc_session::lint;
22+
use rustc_session::lint::{self};
2323
use rustc_span::{DUMMY_SP, Span, Symbol};
2424
use rustc_type_ir::data_structures::IndexMap;
2525
use smallvec::{SmallVec, smallvec};
@@ -336,15 +336,7 @@ pub(crate) fn run_lint<'tcx>(tcx: TyCtxt<'tcx>, def_id: LocalDefId, body: &Body<
336336
// A synthetic coroutine has no HIR body and it is enough to just analyse the original body
337337
return;
338338
}
339-
if body.span.edition().at_least_rust_2024()
340-
|| matches!(
341-
tcx.lint_level_at_node(
342-
lint::builtin::TAIL_EXPR_DROP_ORDER,
343-
tcx.hir().body_owned_by(def_id).id().hir_id
344-
),
345-
(lint::Level::Allow, _)
346-
)
347-
{
339+
if body.span.edition().at_least_rust_2024() {
348340
return;
349341
}
350342
// ## About BIDs in blocks ##

0 commit comments

Comments
 (0)