@@ -284,7 +284,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
284284 . alloc_from_iter ( fm. items . iter ( ) . map ( |x| self . lower_foreign_item_ref ( x) ) ) ,
285285 } ,
286286 ItemKind :: GlobalAsm ( asm) => hir:: ItemKind :: GlobalAsm ( self . lower_inline_asm ( span, asm) ) ,
287- ItemKind :: TyAlias ( box TyAlias { generics, where_clauses, ty : Some ( ty ) , .. } ) => {
287+ ItemKind :: TyAlias ( box TyAlias { generics, where_clauses, ty, .. } ) => {
288288 // We lower
289289 //
290290 // type Foo = impl Trait
@@ -299,18 +299,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
299299 & generics,
300300 id,
301301 & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
302- |this| this. lower_ty ( ty, & ImplTraitContext :: TypeAliasesOpaqueTy ) ,
303- ) ;
304- hir:: ItemKind :: TyAlias ( ty, generics)
305- }
306- ItemKind :: TyAlias ( box TyAlias { generics, where_clauses, ty : None , .. } ) => {
307- let mut generics = generics. clone ( ) ;
308- add_ty_alias_where_clause ( & mut generics, * where_clauses, true ) ;
309- let ( generics, ty) = self . lower_generics (
310- & generics,
311- id,
312- & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
313- |this| this. arena . alloc ( this. ty ( span, hir:: TyKind :: Err ) ) ,
302+ |this| match ty {
303+ None => {
304+ let guar = this. tcx . sess . delay_span_bug (
305+ span,
306+ "expected to lower type alias type, but it was missing" ,
307+ ) ;
308+ this. arena . alloc ( this. ty ( span, hir:: TyKind :: Err ( guar) ) )
309+ }
310+ Some ( ty) => this. lower_ty ( ty, & ImplTraitContext :: TypeAliasesOpaqueTy ) ,
311+ } ,
314312 ) ;
315313 hir:: ItemKind :: TyAlias ( ty, generics)
316314 }
@@ -847,7 +845,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
847845 & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
848846 |this| match ty {
849847 None => {
850- let ty = this. arena . alloc ( this. ty ( i. span , hir:: TyKind :: Err ) ) ;
848+ let guar = this. tcx . sess . delay_span_bug (
849+ i. span ,
850+ "expected to lower associated type, but it was missing" ,
851+ ) ;
852+ let ty = this. arena . alloc ( this. ty ( i. span , hir:: TyKind :: Err ( guar) ) ) ;
851853 hir:: ImplItemKind :: Type ( ty)
852854 }
853855 Some ( ty) => {
0 commit comments