don't lint external macro expansions

This commit is contained in:
Jason Newcomb 2020-12-31 12:07:24 -05:00
parent 2a41d40807
commit 27c0d6c14b
No known key found for this signature in database
GPG Key ID: DA59E8643A37ED06

View File

@ -2,7 +2,7 @@ use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::{Expr, ExprKind, LangItem};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::TyS;
use rustc_middle::{lint::in_external_macro, ty::TyS};
use rustc_session::{declare_lint_pass, declare_tool_lint};
use crate::utils::{is_type_lang_item, snippet_with_applicability, span_lint_and_sugg};
@ -39,6 +39,10 @@ declare_lint_pass!(RedundantSlicing => [REDUNDANT_SLICING]);
impl LateLintPass<'_> for RedundantSlicing {
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
if in_external_macro(cx.sess, expr.span) {
return;
}
if_chain! {
if let ExprKind::AddrOf(_, _, addressee) = expr.kind;
if let ExprKind::Index(indexed, range) = addressee.kind;