Skip to content

Commit 8c235d1

Browse files
committed
in_macro check in NEEDLESS_RETURN
This allows you to define a macro like `try!(...)` that embeds an early exit without emitting the "needless_return" warning. Closes #1271.
1 parent c6f5c89 commit 8c235d1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

clippy_lints/src/returns.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ use syntax::ast;
33
use syntax::codemap::{Span, Spanned};
44
use syntax::visit::FnKind;
55

6-
use utils::{span_note_and_lint, span_lint_and_then, snippet_opt, match_path_ast, in_external_macro};
6+
use utils::{span_note_and_lint, span_lint_and_then, snippet_opt, match_path_ast, in_macro,
7+
in_external_macro};
78

89
/// **What it does:** Checks for return statements at the end of a block.
910
///
@@ -89,7 +90,7 @@ impl ReturnPass {
8990
}
9091

9192
fn emit_return_lint(&mut self, cx: &EarlyContext, ret_span: Span, inner_span: Span) {
92-
if in_external_macro(cx, inner_span) {
93+
if in_external_macro(cx, inner_span) || in_macro(inner_span) {
9394
return;
9495
}
9596
span_lint_and_then(cx,

0 commit comments

Comments
 (0)