Skip to content

Commit 7a26cfc

Browse files
committed
Add macro checks in src/methods.rs lints
1 parent 91ff1db commit 7a26cfc

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/methods.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ use syntax::ptr::P;
88
use syntax::codemap::Span;
99

1010
use utils::{
11-
snippet, span_lint, span_note_and_lint, match_path, match_type, method_chain_args,
12-
match_trait_method, walk_ptrs_ty_depth, walk_ptrs_ty, get_trait_def_id, implements_trait,
13-
span_lint_and_then
11+
get_trait_def_id, implements_trait, in_external_macro, in_macro, match_path,
12+
match_trait_method, match_type, method_chain_args, snippet, span_lint, span_lint_and_then,
13+
span_note_and_lint, walk_ptrs_ty, walk_ptrs_ty_depth,
1414
};
1515
use utils::{
1616
BTREEMAP_ENTRY_PATH, DEFAULT_TRAIT_PATH, HASHMAP_ENTRY_PATH, OPTION_PATH, RESULT_PATH,
@@ -231,6 +231,10 @@ impl LintPass for MethodsPass {
231231

232232
impl LateLintPass for MethodsPass {
233233
fn check_expr(&mut self, cx: &LateContext, expr: &Expr) {
234+
if in_macro(cx, expr.span) {
235+
return;
236+
}
237+
234238
match expr.node {
235239
ExprMethodCall(name, _, ref args) => {
236240
// Chain calls
@@ -266,6 +270,10 @@ impl LateLintPass for MethodsPass {
266270
}
267271

268272
fn check_item(&mut self, cx: &LateContext, item: &Item) {
273+
if in_external_macro(cx, item.span) {
274+
return;
275+
}
276+
269277
if let ItemImpl(_, _, _, None, ref ty, ref items) = item.node {
270278
for implitem in items {
271279
let name = implitem.name;

0 commit comments

Comments
 (0)