@@ -15,17 +15,11 @@ pub(crate) fn provide(providers: &mut Providers) {
15
15
16
16
fn inferred_outlives_of ( tcx : TyCtxt < ' _ > , item_def_id : LocalDefId ) -> & [ ( ty:: Clause < ' _ > , Span ) ] {
17
17
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) => { }
26
20
DefKind :: AnonConst if tcx. features ( ) . generic_const_exprs ( ) => {
27
21
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 ( ) {
29
23
// In `generics_of` we set the generics' parent to be our parent's parent which means that
30
24
// we lose out on the predicates of our actual parent if we dont return those predicates here.
31
25
// (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
42
36
tcx. inferred_outlives_of ( item_def_id)
43
37
} else {
44
38
& [ ]
45
- }
39
+ } ;
46
40
}
47
- _ => & [ ] ,
41
+ _ => return & [ ] ,
48
42
}
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 ( & [ ] )
49
51
}
50
52
51
53
/// Compute a map from each applicable item in the local crate to its inferred/implied outlives-predicates.
0 commit comments