Auto merge of #4358 - lzutao:cleanup_implicit_return, r=flip1995
Use source_callsite() instead of recursive outer_expn_info() changelog: none
This commit is contained in:
commit
d23e6b396a
@ -46,8 +46,8 @@ static LINT_BREAK: &str = "change `break` to `return` as shown";
|
||||
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`
|
||||
|
Loading…
Reference in New Issue
Block a user