Add in_macro again
This commit is contained in:
parent
7eb8018554
commit
abf6481f87
3 changed files with 11 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
use crate::utils::{
|
||||
get_trait_def_id, implements_trait, in_macro_or_desugar, match_type, paths, snippet_opt, span_lint_and_then,
|
||||
SpanlessEq,
|
||||
get_trait_def_id, implements_trait, in_macro, in_macro_or_desugar, match_type, paths, snippet_opt,
|
||||
span_lint_and_then, SpanlessEq,
|
||||
};
|
||||
use rustc::hir::intravisit::*;
|
||||
use rustc::hir::*;
|
||||
|
@ -442,7 +442,7 @@ impl<'a, 'tcx> NonminimalBoolVisitor<'a, 'tcx> {
|
|||
|
||||
impl<'a, 'tcx> Visitor<'tcx> for NonminimalBoolVisitor<'a, 'tcx> {
|
||||
fn visit_expr(&mut self, e: &'tcx Expr) {
|
||||
if in_macro_or_desugar(e.span) {
|
||||
if in_macro(e.span) {
|
||||
return;
|
||||
}
|
||||
match &e.node {
|
||||
|
|
|
@ -20,7 +20,7 @@ use syntax::symbol::LocalInternedString;
|
|||
use crate::utils::paths;
|
||||
use crate::utils::sugg;
|
||||
use crate::utils::{
|
||||
get_arg_name, get_parent_expr, get_trait_def_id, has_iter_method, implements_trait, in_macro_or_desugar, is_copy,
|
||||
get_arg_name, get_parent_expr, get_trait_def_id, has_iter_method, implements_trait, in_macro, is_copy,
|
||||
is_ctor_function, is_expn_of, is_self, is_self_ty, iter_input_pats, last_path_segment, match_path, match_qpath,
|
||||
match_trait_method, match_type, match_var, method_calls, method_chain_args, remove_blocks, return_ty, same_tys,
|
||||
single_segment_path, snippet, snippet_with_applicability, snippet_with_macro_callsite, span_lint,
|
||||
|
@ -859,7 +859,7 @@ declare_lint_pass!(Methods => [
|
|||
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Methods {
|
||||
#[allow(clippy::cognitive_complexity)]
|
||||
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx hir::Expr) {
|
||||
if in_macro_or_desugar(expr.span) {
|
||||
if in_macro(expr.span) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -89,8 +89,13 @@ pub fn in_constant(cx: &LateContext<'_, '_>, id: HirId) -> bool {
|
|||
}
|
||||
}
|
||||
|
||||
/// Returns `true` if this `expn_info` was expanded by any macro.
|
||||
/// Returns `true` if this `expn_info` was expanded by any macro or desugaring
|
||||
pub fn in_macro_or_desugar(span: Span) -> bool {
|
||||
span.ctxt().outer().expn_info().is_some()
|
||||
}
|
||||
|
||||
/// Returns `true` if this `expn_info` was expanded by any macro.
|
||||
pub fn in_macro(span: Span) -> bool {
|
||||
if let Some(info) = span.ctxt().outer().expn_info() {
|
||||
if let ExpnFormat::CompilerDesugaring(..) = info.format {
|
||||
false
|
||||
|
@ -101,7 +106,6 @@ pub fn in_macro_or_desugar(span: Span) -> bool {
|
|||
false
|
||||
}
|
||||
}
|
||||
|
||||
// If the snippet is empty, it's an attribute that was inserted during macro
|
||||
// expansion and we want to ignore those, because they could come from external
|
||||
// sources that the user has no control over.
|
||||
|
|
Loading…
Reference in a new issue