Extract leaks_droppable_temporary_with_limited_lifetime()
This commit is contained in:
parent
8f1b4bb87a
commit
71ba2cf1e5
2 changed files with 26 additions and 22 deletions
|
|
@ -1,10 +1,11 @@
|
|||
use clippy_utils::diagnostics::{span_lint_and_sugg, span_lint_hir_and_then};
|
||||
use clippy_utils::source::{SpanRangeExt, snippet_with_context};
|
||||
use clippy_utils::sugg::has_enclosing_paren;
|
||||
use clippy_utils::visitors::{Descend, for_each_expr, for_each_unconsumed_temporary};
|
||||
use clippy_utils::visitors::{Descend, for_each_expr};
|
||||
use clippy_utils::{
|
||||
binary_expr_needs_parentheses, fn_def_id, is_from_proc_macro, is_inside_let_else, is_res_lang_ctor, path_res,
|
||||
path_to_local_id, span_contains_cfg, span_find_starting_semi,
|
||||
binary_expr_needs_parentheses, fn_def_id, is_from_proc_macro, is_inside_let_else, is_res_lang_ctor,
|
||||
leaks_droppable_temporary_with_limited_lifetime, path_res, path_to_local_id, span_contains_cfg,
|
||||
span_find_starting_semi,
|
||||
};
|
||||
use core::ops::ControlFlow;
|
||||
use rustc_ast::MetaItemInner;
|
||||
|
|
@ -389,22 +390,8 @@ fn check_final_expr<'tcx>(
|
|||
}
|
||||
};
|
||||
|
||||
if let Some(inner) = inner {
|
||||
if for_each_unconsumed_temporary(cx, inner, |temporary_ty| {
|
||||
if temporary_ty.has_significant_drop(cx.tcx, cx.typing_env())
|
||||
&& temporary_ty
|
||||
.walk()
|
||||
.any(|arg| matches!(arg.unpack(), GenericArgKind::Lifetime(re) if !re.is_static()))
|
||||
{
|
||||
ControlFlow::Break(())
|
||||
} else {
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
})
|
||||
.is_break()
|
||||
{
|
||||
return;
|
||||
}
|
||||
if inner.is_some_and(|inner| leaks_droppable_temporary_with_limited_lifetime(cx, inner)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ret_span.from_expansion() || is_from_proc_macro(cx, expr) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue