@@ -715,13 +715,21 @@ fn convert_trait_item(tcx: TyCtxt<'_>, trait_item_id: hir::HirId) {
715715 tcx. generics_of ( def_id) ;
716716
717717 match trait_item. kind {
718- hir:: TraitItemKind :: Const ( ..)
719- | hir:: TraitItemKind :: Type ( _, Some ( _) )
720- | hir:: TraitItemKind :: Method ( ..) => {
718+ hir:: TraitItemKind :: Method ( ..) => {
721719 tcx. type_of ( def_id) ;
722- if let hir:: TraitItemKind :: Method ( ..) = trait_item. kind {
723- tcx. fn_sig ( def_id) ;
724- }
720+ tcx. fn_sig ( def_id) ;
721+ }
722+
723+ hir:: TraitItemKind :: Const ( .., Some ( _) ) => {
724+ tcx. type_of ( def_id) ;
725+ }
726+
727+ hir:: TraitItemKind :: Const ( ..) | hir:: TraitItemKind :: Type ( _, Some ( _) ) => {
728+ tcx. type_of ( def_id) ;
729+ // Account for `const C: _;` and `type T = _;`.
730+ let mut visitor = PlaceholderHirTyCollector :: default ( ) ;
731+ visitor. visit_trait_item ( trait_item) ;
732+ placeholder_type_error ( tcx, DUMMY_SP , & [ ] , visitor. 0 , false ) ;
725733 }
726734
727735 hir:: TraitItemKind :: Type ( _, None ) => { }
@@ -735,8 +743,18 @@ fn convert_impl_item(tcx: TyCtxt<'_>, impl_item_id: hir::HirId) {
735743 tcx. generics_of ( def_id) ;
736744 tcx. type_of ( def_id) ;
737745 tcx. predicates_of ( def_id) ;
738- if let hir:: ImplItemKind :: Method ( ..) = tcx. hir ( ) . expect_impl_item ( impl_item_id) . kind {
739- tcx. fn_sig ( def_id) ;
746+ let impl_item = tcx. hir ( ) . expect_impl_item ( impl_item_id) ;
747+ match impl_item. kind {
748+ hir:: ImplItemKind :: Method ( ..) => {
749+ tcx. fn_sig ( def_id) ;
750+ }
751+ hir:: ImplItemKind :: TyAlias ( _) | hir:: ImplItemKind :: OpaqueTy ( _) => {
752+ // Account for `type T = _;`
753+ let mut visitor = PlaceholderHirTyCollector :: default ( ) ;
754+ visitor. visit_impl_item ( impl_item) ;
755+ placeholder_type_error ( tcx, DUMMY_SP , & [ ] , visitor. 0 , false ) ;
756+ }
757+ hir:: ImplItemKind :: Const ( ..) => { }
740758 }
741759}
742760
0 commit comments