Auto merge of #8667 - Jarcho:proc_macro_check, r=flip1995

Don't lint various match lints when expanded by a proc-macro

fixes #4952

As always for proc-macro output this is a hack-job of a fix. It would be really nice if more proc-macro authors would set spans correctly.

changelog: Don't lint various lints on proc-macro output.
This commit is contained in:
bors 2022-04-11 16:41:51 +00:00
commit 89ee6aa6e3
5 changed files with 77 additions and 8 deletions

View file

@ -1,4 +1,4 @@
use clippy_utils::source::{snippet_opt, walk_span_to_context};
use clippy_utils::source::{snippet_opt, span_starts_with, walk_span_to_context};
use clippy_utils::{meets_msrv, msrvs};
use rustc_hir::{Arm, Expr, ExprKind, Local, MatchSource, Pat};
use rustc_lexer::{tokenize, TokenKind};
@ -653,6 +653,9 @@ impl<'tcx> LateLintPass<'tcx> for Matches {
}
if let ExprKind::Match(ex, arms, source) = expr.kind {
if !span_starts_with(cx, expr.span, "match") {
return;
}
if !contains_cfg_arm(cx, expr, ex, arms) {
if source == MatchSource::Normal {
if !(meets_msrv(self.msrv.as_ref(), &msrvs::MATCHES_MACRO)