Disable default_trait_access in macros
This commit is contained in:
parent
841244dff0
commit
b9c8e683d6
@ -1,6 +1,6 @@
|
|||||||
use clippy_utils::diagnostics::{span_lint_and_note, span_lint_and_sugg};
|
use clippy_utils::diagnostics::{span_lint_and_note, span_lint_and_sugg};
|
||||||
use clippy_utils::source::snippet_with_macro_callsite;
|
use clippy_utils::source::snippet_with_macro_callsite;
|
||||||
use clippy_utils::{any_parent_is_automatically_derived, contains_name, match_def_path, paths};
|
use clippy_utils::{any_parent_is_automatically_derived, contains_name, in_macro, match_def_path, paths};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
use rustc_data_structures::fx::FxHashSet;
|
use rustc_data_structures::fx::FxHashSet;
|
||||||
use rustc_errors::Applicability;
|
use rustc_errors::Applicability;
|
||||||
@ -75,6 +75,7 @@ impl_lint_pass!(Default => [DEFAULT_TRAIT_ACCESS, FIELD_REASSIGN_WITH_DEFAULT]);
|
|||||||
impl LateLintPass<'_> for Default {
|
impl LateLintPass<'_> for Default {
|
||||||
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||||
if_chain! {
|
if_chain! {
|
||||||
|
if !in_macro(expr.span);
|
||||||
// Avoid cases already linted by `field_reassign_with_default`
|
// Avoid cases already linted by `field_reassign_with_default`
|
||||||
if !self.reassigned_linted.contains(&expr.span);
|
if !self.reassigned_linted.contains(&expr.span);
|
||||||
if let ExprKind::Call(path, ..) = expr.kind;
|
if let ExprKind::Call(path, ..) = expr.kind;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user