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