small refactor
This commit is contained in:
parent
15ec5d2608
commit
23d1d07861
@ -1,4 +1,4 @@
|
|||||||
use clippy_utils::diagnostics::span_lint_hir_and_then;
|
use clippy_utils::diagnostics::{span_lint_hir_and_then, span_lint_and_then};
|
||||||
use clippy_utils::source::{snippet_opt, snippet_with_context};
|
use clippy_utils::source::{snippet_opt, snippet_with_context};
|
||||||
use clippy_utils::{fn_def_id, path_to_local_id};
|
use clippy_utils::{fn_def_id, path_to_local_id};
|
||||||
use if_chain::if_chain;
|
use if_chain::if_chain;
|
||||||
@ -194,7 +194,6 @@ fn check_final_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, span:
|
|||||||
if !borrows {
|
if !borrows {
|
||||||
emit_return_lint(
|
emit_return_lint(
|
||||||
cx,
|
cx,
|
||||||
inner.map_or(expr.hir_id, |inner| inner.hir_id),
|
|
||||||
span,
|
span,
|
||||||
inner.as_ref().map(|i| i.span),
|
inner.as_ref().map(|i| i.span),
|
||||||
replacement,
|
replacement,
|
||||||
@ -224,7 +223,6 @@ fn check_final_expr<'tcx>(cx: &LateContext<'tcx>, expr: &'tcx Expr<'tcx>, span:
|
|||||||
|
|
||||||
fn emit_return_lint(
|
fn emit_return_lint(
|
||||||
cx: &LateContext<'_>,
|
cx: &LateContext<'_>,
|
||||||
emission_place: HirId,
|
|
||||||
ret_span: Span,
|
ret_span: Span,
|
||||||
inner_span: Option<Span>,
|
inner_span: Option<Span>,
|
||||||
replacement: RetReplacement,
|
replacement: RetReplacement,
|
||||||
@ -245,10 +243,9 @@ fn emit_return_lint(
|
|||||||
} else {
|
} else {
|
||||||
replacement.sugg_help()
|
replacement.sugg_help()
|
||||||
};
|
};
|
||||||
span_lint_hir_and_then(
|
span_lint_and_then(
|
||||||
cx,
|
cx,
|
||||||
NEEDLESS_RETURN,
|
NEEDLESS_RETURN,
|
||||||
emission_place,
|
|
||||||
ret_span,
|
ret_span,
|
||||||
"unneeded `return` statement",
|
"unneeded `return` statement",
|
||||||
|diag| {
|
|diag| {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user