@@ -1018,9 +1018,11 @@ pub(super) fn const_conditions<'tcx>(
10181018 Node :: Item ( item) => match item. kind {
10191019 hir:: ItemKind :: Impl ( impl_) => ( impl_. generics , None , false ) ,
10201020 hir:: ItemKind :: Fn { generics, .. } => ( generics, None , false ) ,
1021- hir:: ItemKind :: TraitAlias ( _, _, generics, supertraits)
1022- | hir:: ItemKind :: Trait ( _, _, _, _, generics, supertraits, _) => {
1023- ( generics, Some ( ( item. owner_id . def_id , supertraits) ) , false )
1021+ hir:: ItemKind :: Trait ( _, _, _, _, generics, supertraits, _) => {
1022+ ( generics, Some ( ( Some ( item. owner_id . def_id ) , supertraits) ) , false )
1023+ }
1024+ hir:: ItemKind :: TraitAlias ( _, _, generics, supertraits) => {
1025+ ( generics, Some ( ( None , supertraits) ) , false )
10241026 }
10251027 _ => bug ! ( "const_conditions called on wrong item: {def_id:?}" ) ,
10261028 } ,
@@ -1076,12 +1078,14 @@ pub(super) fn const_conditions<'tcx>(
10761078 }
10771079
10781080 if let Some ( ( def_id, supertraits) ) = trait_def_id_and_supertraits {
1079- // We've checked above that the trait is conditionally const.
1080- bounds. push ( (
1081- ty:: Binder :: dummy ( ty:: TraitRef :: identity ( tcx, def_id. to_def_id ( ) ) )
1082- . to_host_effect_clause ( tcx, ty:: BoundConstness :: Maybe ) ,
1083- DUMMY_SP ,
1084- ) ) ;
1081+ if let Some ( def_id) = def_id {
1082+ // We've checked above that the trait is conditionally const.
1083+ bounds. push ( (
1084+ ty:: Binder :: dummy ( ty:: TraitRef :: identity ( tcx, def_id. to_def_id ( ) ) )
1085+ . to_host_effect_clause ( tcx, ty:: BoundConstness :: Maybe ) ,
1086+ DUMMY_SP ,
1087+ ) ) ;
1088+ }
10851089
10861090 icx. lowerer ( ) . lower_bounds (
10871091 tcx. types . self_param ,
0 commit comments