@@ -43,8 +43,8 @@ use rustc_hir::definitions::Definitions;
4343use rustc_hir:: intravisit:: Visitor ;
4444use rustc_hir:: lang_items:: LangItem ;
4545use rustc_hir:: {
46- Constness , HirId , ItemKind , ItemLocalId , ItemLocalMap , ItemLocalSet , Node , TraitCandidate ,
47- TraitItemKind ,
46+ Constness , ExprKind , HirId , ImplItemKind , ItemKind , ItemLocalId , ItemLocalMap , ItemLocalSet ,
47+ Node , TraitCandidate , TraitItemKind ,
4848} ;
4949use rustc_index:: vec:: { Idx , IndexVec } ;
5050use rustc_macros:: HashStable ;
@@ -1499,24 +1499,14 @@ impl<'tcx> TyCtxt<'tcx> {
14991499 }
15001500
15011501 pub fn return_type_impl_trait ( self , scope_def_id : LocalDefId ) -> Option < ( Ty < ' tcx > , Span ) > {
1502- // HACK: `type_of()` will fail on these (#55796), so return `None` .
1502+ // `type_of()` will fail on these (#55796, #86483 ), so only allow `fn`s or closures .
15031503 let hir_id = self . hir ( ) . local_def_id_to_hir_id ( scope_def_id) ;
15041504 match self . hir ( ) . get ( hir_id) {
1505- Node :: Item ( item) => {
1506- match item. kind {
1507- ItemKind :: Fn ( ..) => { /* `type_of()` will work */ }
1508- _ => {
1509- return None ;
1510- }
1511- }
1512- }
1513- Node :: TraitItem ( item) => {
1514- // #86483: Return early if it doesn't have a concrete type.
1515- if let TraitItemKind :: Type ( _, None ) = item. kind {
1516- return None ;
1517- }
1518- }
1519- _ => { /* `type_of()` will work or panic */ }
1505+ Node :: Item ( & hir:: Item { kind : ItemKind :: Fn ( ..) , .. } ) => { }
1506+ Node :: TraitItem ( & hir:: TraitItem { kind : TraitItemKind :: Fn ( ..) , .. } ) => { }
1507+ Node :: ImplItem ( & hir:: ImplItem { kind : ImplItemKind :: Fn ( ..) , .. } ) => { }
1508+ Node :: Expr ( & hir:: Expr { kind : ExprKind :: Closure ( ..) , .. } ) => { }
1509+ _ => return None ,
15201510 }
15211511
15221512 let ret_ty = self . type_of ( scope_def_id) ;
0 commit comments