diff options
| author | bors <bors@rust-lang.org> | 2024-02-21 22:53:46 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2024-02-21 22:53:46 +0000 |
| commit | 422f9c5b657299d577feab8a7bc208d653eec90e (patch) | |
| tree | 1eab466ec6563eba6b4a8fcd4b54cd00405afe51 /clippy_lints | |
| parent | 250fd094052291756011bf22eaa2adfbc060ece1 (diff) | |
| parent | b72996e3220d4a32f1d2bd40c3e0b8ae5d87d351 (diff) | |
Auto merge of #12317 - CBSpeir:issue_12291, r=y21
Add check for 'in_external_macro' and 'is_from_proc_macro' inside changelog: Fix #12291 #[tracing::instrument()] triggers infinite_loop Added an in_external_macro and is_from_proc_macro check to the [infinite_loop] lint
Diffstat (limited to 'clippy_lints')
| -rw-r--r-- | clippy_lints/src/loops/infinite_loop.rs | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/clippy_lints/src/loops/infinite_loop.rs b/clippy_lints/src/loops/infinite_loop.rs index 5e099f1e76f..5b5bb88c179 100644 --- a/clippy_lints/src/loops/infinite_loop.rs +++ b/clippy_lints/src/loops/infinite_loop.rs @@ -1,17 +1,18 @@ use clippy_utils::diagnostics::span_lint_and_then; -use clippy_utils::{fn_def_id, is_lint_allowed}; +use clippy_utils::{fn_def_id, is_from_proc_macro, is_lint_allowed}; use hir::intravisit::{walk_expr, Visitor}; use hir::{Expr, ExprKind, FnRetTy, FnSig, Node}; use rustc_ast::Label; use rustc_errors::Applicability; use rustc_hir as hir; -use rustc_lint::LateContext; +use rustc_lint::{LateContext, LintContext}; +use rustc_middle::lint::in_external_macro; use super::INFINITE_LOOP; pub(super) fn check<'tcx>( cx: &LateContext<'tcx>, - expr: &Expr<'_>, + expr: &Expr<'tcx>, loop_block: &'tcx hir::Block<'_>, label: Option<Label>, ) { @@ -34,6 +35,10 @@ pub(super) fn check<'tcx>( return; } + if in_external_macro(cx.sess(), expr.span) || is_from_proc_macro(cx, expr) { + return; + } + let mut loop_visitor = LoopVisitor { cx, label, |
