@@ -12,7 +12,7 @@ use rustc_hir::hir_id::{HirId, HirIdMap};
12
12
use rustc_hir:: intravisit:: { walk_expr, Visitor } ;
13
13
use rustc_hir:: {
14
14
self as hir, AnonConst , BinOpKind , BindingMode , Body , Expr , ExprKind , FnRetTy , FnSig , GenericArg , ImplItemKind ,
15
- ItemKind , Lifetime , Mutability , Node , Param , PatKind , QPath , TraitFn , TraitItem , TraitItemKind , TyKind , Unsafety ,
15
+ ItemKind , Lifetime , Mutability , Node , Param , PatKind , QPath , Safety , TraitFn , TraitItem , TraitItemKind , TyKind ,
16
16
} ;
17
17
use rustc_infer:: infer:: TyCtxtInferExt ;
18
18
use rustc_infer:: traits:: { Obligation , ObligationCause } ;
@@ -460,13 +460,19 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
460
460
}
461
461
None
462
462
} ) {
463
- if !lifetime. is_anonymous ( )
463
+ if let LifetimeName :: Param ( param_def_id) = lifetime. res
464
+ && !lifetime. is_anonymous ( )
464
465
&& fn_sig
465
466
. output ( )
466
467
. walk ( )
467
468
. filter_map ( |arg| {
468
469
arg. as_region ( ) . and_then ( |lifetime| match lifetime. kind ( ) {
469
- ty:: ReEarlyParam ( r) => Some ( r. def_id ) ,
470
+ ty:: ReEarlyParam ( r) => Some (
471
+ cx. tcx
472
+ . generics_of ( cx. tcx . parent ( param_def_id. to_def_id ( ) ) )
473
+ . region_param ( r, cx. tcx )
474
+ . def_id ,
475
+ ) ,
470
476
ty:: ReBound ( _, r) => r. kind . get_id ( ) ,
471
477
ty:: ReLateParam ( r) => r. bound_region . get_id ( ) ,
472
478
ty:: ReStatic
@@ -476,14 +482,7 @@ fn check_fn_args<'cx, 'tcx: 'cx>(
476
482
| ty:: ReError ( _) => None ,
477
483
} )
478
484
} )
479
- . any ( |def_id| {
480
- matches ! (
481
- lifetime. res,
482
- LifetimeName :: Param ( param_def_id) if def_id
483
- . as_local( )
484
- . is_some_and( |def_id| def_id == param_def_id) ,
485
- )
486
- } )
485
+ . any ( |def_id| def_id. as_local ( ) . is_some_and ( |def_id| def_id == param_def_id) )
487
486
{
488
487
// `&Cow<'a, T>` when the return type uses 'a is okay
489
488
return None ;
@@ -542,7 +541,7 @@ fn check_mut_from_ref<'tcx>(cx: &LateContext<'tcx>, sig: &FnSig<'_>, body: Optio
542
541
if let Some ( args) = args
543
542
&& !args. is_empty ( )
544
543
&& body. map_or ( true , |body| {
545
- sig. header . unsafety == Unsafety :: Unsafe || contains_unsafe_block ( cx, body. value )
544
+ sig. header . safety == Safety :: Unsafe || contains_unsafe_block ( cx, body. value )
546
545
} )
547
546
{
548
547
span_lint_and_then (
0 commit comments