use rustc's criteria for a temporary
This commit is contained in:
parent
d2725402a9
commit
72aa180798
@ -1,11 +1,10 @@
|
||||
use std::ops::ControlFlow;
|
||||
|
||||
use clippy_utils::diagnostics::span_lint_and_sugg;
|
||||
use clippy_utils::is_no_std_crate;
|
||||
use clippy_utils::source::snippet_with_context;
|
||||
use clippy_utils::{diagnostics::span_lint_and_sugg, visitors::for_each_unconsumed_temporary};
|
||||
use rustc_errors::Applicability;
|
||||
use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, Ty, TyKind};
|
||||
use rustc_lint::LateContext;
|
||||
use rustc_middle::ty::adjustment::Adjust;
|
||||
|
||||
use super::BORROW_AS_PTR;
|
||||
|
||||
@ -26,7 +25,12 @@ pub(super) fn check<'tcx>(
|
||||
let mut app = Applicability::MachineApplicable;
|
||||
let snip = snippet_with_context(cx, e.span, cast_expr.span.ctxt(), "..", &mut app).0;
|
||||
// Fix #9884
|
||||
if for_each_unconsumed_temporary(cx, expr, |_| ControlFlow::Break(true)).is_break() {
|
||||
if !e.is_place_expr(|base| {
|
||||
cx.typeck_results()
|
||||
.adjustments()
|
||||
.get(base.hir_id)
|
||||
.is_some_and(|x| x.iter().any(|adj| matches!(adj.kind, Adjust::Deref(_))))
|
||||
}) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user