@@ -15,17 +15,11 @@ pub(crate) fn provide(providers: &mut Providers) {
1515
1616fn inferred_outlives_of ( tcx : TyCtxt < ' _ > , item_def_id : LocalDefId ) -> & [ ( ty:: Clause < ' _ > , Span ) ] {
1717 match tcx. def_kind ( item_def_id) {
18- DefKind :: Struct | DefKind :: Enum | DefKind :: Union | DefKind :: Const => {
19- let crate_map = tcx. inferred_outlives_crate ( ( ) ) ;
20- crate_map. predicates . get ( & item_def_id. to_def_id ( ) ) . copied ( ) . unwrap_or ( & [ ] )
21- }
22- DefKind :: TyAlias if tcx. type_alias_is_lazy ( item_def_id) => {
23- let crate_map = tcx. inferred_outlives_crate ( ( ) ) ;
24- crate_map. predicates . get ( & item_def_id. to_def_id ( ) ) . copied ( ) . unwrap_or ( & [ ] )
25- }
18+ DefKind :: Struct | DefKind :: Enum | DefKind :: Union | DefKind :: Const => { }
19+ DefKind :: TyAlias if tcx. type_alias_is_lazy ( item_def_id) => { }
2620 DefKind :: AnonConst if tcx. features ( ) . generic_const_exprs ( ) => {
2721 let id = tcx. local_def_id_to_hir_id ( item_def_id) ;
28- if tcx. hir_opt_const_param_default_param_def_id ( id) . is_some ( ) {
22+ return if tcx. hir_opt_const_param_default_param_def_id ( id) . is_some ( ) {
2923 // In `generics_of` we set the generics' parent to be our parent's parent which means that
3024 // we lose out on the predicates of our actual parent if we dont return those predicates here.
3125 // (See comment in `generics_of` for more information on why the parent shenanigans is necessary)
@@ -42,10 +36,18 @@ fn inferred_outlives_of(tcx: TyCtxt<'_>, item_def_id: LocalDefId) -> &[(ty::Clau
4236 tcx. inferred_outlives_of ( item_def_id)
4337 } else {
4438 & [ ]
45- }
39+ } ;
4640 }
47- _ => & [ ] ,
41+ _ => return & [ ] ,
4842 }
43+
44+ // FIXME(fmease): Explainer. Maybe fast path:
45+ if tcx. generics_of ( item_def_id) . is_empty ( ) {
46+ return & [ ] ;
47+ }
48+
49+ let crate_map = tcx. inferred_outlives_crate ( ( ) ) ;
50+ crate_map. predicates . get ( & item_def_id. to_def_id ( ) ) . copied ( ) . unwrap_or ( & [ ] )
4951}
5052
5153/// Compute a map from each applicable item in the local crate to its inferred/implied outlives-predicates.
0 commit comments