File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -2331,6 +2331,18 @@ pub fn is_expr_final_block_expr(tcx: TyCtxt<'_>, expr: &Expr<'_>) -> bool {
23312331 matches ! ( tcx. parent_hir_node( expr. hir_id) , Node :: Block ( ..) )
23322332}
23332333
2334+ /// Checks if the expression is a temporary value.
2335+ // This logic is the same as the one used in rustc's `check_named_place_expr function`.
2336+ // https://github.com/rust-lang/rust/blob/3ed2a10d173d6c2e0232776af338ca7d080b1cd4/compiler/rustc_hir_typeck/src/expr.rs#L482-L499
2337+ pub fn is_expr_temporary_value ( cx : & LateContext < ' _ > , expr : & Expr < ' _ > ) -> bool {
2338+ !expr. is_place_expr ( |base| {
2339+ cx. typeck_results ( )
2340+ . adjustments ( )
2341+ . get ( base. hir_id )
2342+ . is_some_and ( |x| x. iter ( ) . any ( |adj| matches ! ( adj. kind, Adjust :: Deref ( _) ) ) )
2343+ } )
2344+ }
2345+
23342346pub fn std_or_core ( cx : & LateContext < ' _ > ) -> Option < & ' static str > {
23352347 if !is_no_std_crate ( cx) {
23362348 Some ( "std" )
You can’t perform that action at this time.
0 commit comments