diff options
| author | lapla-cogito <me@lapla.dev> | 2025-02-25 08:34:13 +0900 |
|---|---|---|
| committer | lapla-cogito <me@lapla.dev> | 2025-03-06 07:54:54 +0900 |
| commit | 27e69a80f5bf6660fdadaa52c364a16994116688 (patch) | |
| tree | a7e5d8c44127a3dc073652e1945b295a07d49b5d | |
| parent | 2fda4f6bb85ae334ae36cc4b3d88a609b3132bd0 (diff) | |
| download | rust-27e69a80f5bf6660fdadaa52c364a16994116688.tar.gz rust-27e69a80f5bf6660fdadaa52c364a16994116688.zip | |
apply `is_expr_temporary_value` to Clippy source
| -rw-r--r-- | clippy_lints/src/casts/borrow_as_ptr.rs | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/clippy_lints/src/casts/borrow_as_ptr.rs b/clippy_lints/src/casts/borrow_as_ptr.rs index 6057144bc6a..c1d775831c0 100644 --- a/clippy_lints/src/casts/borrow_as_ptr.rs +++ b/clippy_lints/src/casts/borrow_as_ptr.rs @@ -2,11 +2,10 @@ use clippy_utils::diagnostics::span_lint_and_sugg; use clippy_utils::msrvs::Msrv; use clippy_utils::source::{snippet_with_applicability, snippet_with_context}; use clippy_utils::sugg::has_enclosing_paren; -use clippy_utils::{is_lint_allowed, msrvs, std_or_core}; +use clippy_utils::{is_expr_temporary_value, is_lint_allowed, msrvs, std_or_core}; use rustc_errors::Applicability; use rustc_hir::{BorrowKind, Expr, ExprKind, Mutability, Ty, TyKind}; use rustc_lint::LateContext; -use rustc_middle::ty::adjustment::Adjust; use rustc_span::BytePos; use super::BORROW_AS_PTR; @@ -25,12 +24,7 @@ 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 !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(_)))) - }) { + if is_expr_temporary_value(cx, e) { return false; } |
