multiple_unsafe_ops_per_block: don't lint in external macros
This commit is contained in:
parent
8fb0041f47
commit
926c5e4cde
4 changed files with 41 additions and 21 deletions
|
|
@ -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![];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue