Use source_callsite() instead of recursive outer_expn_info()

This commit is contained in:
Lzu Tao 2019-08-08 21:28:40 +07:00
parent b041511b5f
commit 59a35874c1

View File

@ -46,8 +46,8 @@
static LINT_RETURN: &str = "add `return` as shown";
fn lint(cx: &LateContext<'_, '_>, outer_span: Span, inner_span: Span, msg: &str) {
let outer_span = span_to_outer_expn(outer_span);
let inner_span = span_to_outer_expn(inner_span);
let outer_span = outer_span.source_callsite();
let inner_span = inner_span.source_callsite();
span_lint_and_then(cx, IMPLICIT_RETURN, outer_span, "missing return statement", |db| {
if let Some(snippet) = snippet_opt(cx, inner_span) {
@ -61,14 +61,6 @@ fn lint(cx: &LateContext<'_, '_>, outer_span: Span, inner_span: Span, msg: &str)
});
}
fn span_to_outer_expn(span: Span) -> Span {
if let Some(expr) = span.ctxt().outer_expn_info() {
span_to_outer_expn(expr.call_site)
} else {
span
}
}
fn expr_match(cx: &LateContext<'_, '_>, expr: &Expr) {
match &expr.node {
// loops could be using `break` instead of `return`