Auto merge of #10260 - Niki4tap:external_macro_fp, r=xFrednet

`multiple_unsafe_ops_per_block`: Don't lint in external macros

Fixes #10259

changelog: FP: [`multiple_unsafe_ops_per_block`]: No longer lints in external macros
[#10260](https://github.com/rust-lang/rust-clippy/pull/10260)
<!-- changelog_none -->
This commit is contained in:
bors 2023-01-30 20:10:19 +00:00
commit d020fd7fe6
4 changed files with 41 additions and 21 deletions

View file

@ -10,6 +10,7 @@ use hir::{
use rustc_ast::Mutability;
use rustc_hir as hir;
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::lint::in_external_macro;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::Span;
@ -66,7 +67,7 @@ declare_lint_pass!(MultipleUnsafeOpsPerBlock => [MULTIPLE_UNSAFE_OPS_PER_BLOCK])
impl<'tcx> LateLintPass<'tcx> for MultipleUnsafeOpsPerBlock {
fn check_block(&mut self, cx: &LateContext<'tcx>, block: &'tcx hir::Block<'_>) {
if !matches!(block.rules, BlockCheckMode::UnsafeBlock(_)) {
if !matches!(block.rules, BlockCheckMode::UnsafeBlock(_)) || in_external_macro(cx.tcx.sess, block.span) {
return;
}
let mut unsafe_ops = vec![];