@@ -337,20 +337,22 @@ impl LoweringContext<'_> {
337
337
ItemKind :: Mod ( ref m) => hir:: ItemKind :: Mod ( self . lower_mod ( m) ) ,
338
338
ItemKind :: ForeignMod ( ref nm) => hir:: ItemKind :: ForeignMod ( self . lower_foreign_mod ( nm) ) ,
339
339
ItemKind :: GlobalAsm ( ref ga) => hir:: ItemKind :: GlobalAsm ( self . lower_global_asm ( ga) ) ,
340
- ItemKind :: TyAlias ( ref t, ref generics) => hir:: ItemKind :: TyAlias (
341
- self . lower_ty ( t, ImplTraitContext :: disallowed ( ) ) ,
342
- self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ,
343
- ) ,
344
- ItemKind :: OpaqueTy ( ref b, ref generics) => hir:: ItemKind :: OpaqueTy (
345
- hir:: OpaqueTy {
346
- generics : self . lower_generics ( generics,
347
- ImplTraitContext :: OpaqueTy ( None ) ) ,
348
- bounds : self . lower_param_bounds ( b,
349
- ImplTraitContext :: OpaqueTy ( None ) ) ,
350
- impl_trait_fn : None ,
351
- origin : hir:: OpaqueTyOrigin :: TypeAlias ,
340
+ ItemKind :: TyAlias ( ref ty, ref generics) => match ty. kind . opaque_top_hack ( ) {
341
+ None => {
342
+ let ty = self . lower_ty ( ty, ImplTraitContext :: disallowed ( ) ) ;
343
+ let generics = self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ;
344
+ hir:: ItemKind :: TyAlias ( ty, generics)
352
345
} ,
353
- ) ,
346
+ Some ( bounds) => {
347
+ let ty = hir:: OpaqueTy {
348
+ generics : self . lower_generics ( generics, ImplTraitContext :: OpaqueTy ( None ) ) ,
349
+ bounds : self . lower_param_bounds ( bounds, ImplTraitContext :: OpaqueTy ( None ) ) ,
350
+ impl_trait_fn : None ,
351
+ origin : hir:: OpaqueTyOrigin :: TypeAlias ,
352
+ } ;
353
+ hir:: ItemKind :: OpaqueTy ( ty)
354
+ }
355
+ }
354
356
ItemKind :: Enum ( ref enum_definition, ref generics) => {
355
357
hir:: ItemKind :: Enum (
356
358
hir:: EnumDef {
@@ -916,16 +918,20 @@ impl LoweringContext<'_> {
916
918
917
919
( generics, hir:: ImplItemKind :: Method ( sig, body_id) )
918
920
}
919
- ImplItemKind :: TyAlias ( ref ty) => (
920
- self . lower_generics ( & i. generics , ImplTraitContext :: disallowed ( ) ) ,
921
- hir:: ImplItemKind :: TyAlias ( self . lower_ty ( ty, ImplTraitContext :: disallowed ( ) ) ) ,
922
- ) ,
923
- ImplItemKind :: OpaqueTy ( ref bounds) => (
924
- self . lower_generics ( & i. generics , ImplTraitContext :: disallowed ( ) ) ,
925
- hir:: ImplItemKind :: OpaqueTy (
926
- self . lower_param_bounds ( bounds, ImplTraitContext :: disallowed ( ) ) ,
927
- ) ,
928
- ) ,
921
+ ImplItemKind :: TyAlias ( ref ty) => {
922
+ let generics = self . lower_generics ( & i. generics , ImplTraitContext :: disallowed ( ) ) ;
923
+ let kind = match ty. kind . opaque_top_hack ( ) {
924
+ None => {
925
+ let ty = self . lower_ty ( ty, ImplTraitContext :: disallowed ( ) ) ;
926
+ hir:: ImplItemKind :: TyAlias ( ty)
927
+ }
928
+ Some ( bs) => {
929
+ let bounds = self . lower_param_bounds ( bs, ImplTraitContext :: disallowed ( ) ) ;
930
+ hir:: ImplItemKind :: OpaqueTy ( bounds)
931
+ }
932
+ } ;
933
+ ( generics, kind)
934
+ } ,
929
935
ImplItemKind :: Macro ( ..) => bug ! ( "`TyMac` should have been expanded by now" ) ,
930
936
} ;
931
937
@@ -950,11 +956,13 @@ impl LoweringContext<'_> {
950
956
span : i. span ,
951
957
vis : self . lower_visibility ( & i. vis , Some ( i. id ) ) ,
952
958
defaultness : self . lower_defaultness ( i. defaultness , true /* [1] */ ) ,
953
- kind : match i. kind {
959
+ kind : match & i. kind {
954
960
ImplItemKind :: Const ( ..) => hir:: AssocItemKind :: Const ,
955
- ImplItemKind :: TyAlias ( ..) => hir:: AssocItemKind :: Type ,
956
- ImplItemKind :: OpaqueTy ( ..) => hir:: AssocItemKind :: OpaqueTy ,
957
- ImplItemKind :: Method ( ref sig, _) => hir:: AssocItemKind :: Method {
961
+ ImplItemKind :: TyAlias ( ty) => match ty. kind . opaque_top_hack ( ) {
962
+ None => hir:: AssocItemKind :: Type ,
963
+ Some ( _) => hir:: AssocItemKind :: OpaqueTy ,
964
+ } ,
965
+ ImplItemKind :: Method ( sig, _) => hir:: AssocItemKind :: Method {
958
966
has_self : sig. decl . has_self ( ) ,
959
967
} ,
960
968
ImplItemKind :: Macro ( ..) => unimplemented ! ( ) ,
0 commit comments