@@ -43,8 +43,8 @@ use rustc_hir::definitions::Definitions;
43
43
use rustc_hir:: intravisit:: Visitor ;
44
44
use rustc_hir:: lang_items:: LangItem ;
45
45
use 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 ,
48
48
} ;
49
49
use rustc_index:: vec:: { Idx , IndexVec } ;
50
50
use rustc_macros:: HashStable ;
@@ -1499,24 +1499,14 @@ impl<'tcx> TyCtxt<'tcx> {
1499
1499
}
1500
1500
1501
1501
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 .
1503
1503
let hir_id = self . hir ( ) . local_def_id_to_hir_id ( scope_def_id) ;
1504
1504
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 ,
1520
1510
}
1521
1511
1522
1512
let ret_ty = self . type_of ( scope_def_id) ;
0 commit comments