@@ -82,9 +82,6 @@ pub struct Mir<'tcx> {
8282 /// in scope, but a separate set of locals.
8383 pub promoted : IndexVec < Promoted , Mir < ' tcx > > ,
8484
85- /// Return type of the function.
86- pub return_ty : Ty < ' tcx > ,
87-
8885 /// Yield type of the function, if it is a generator.
8986 pub yield_ty : Option < Ty < ' tcx > > ,
9087
@@ -135,7 +132,6 @@ impl<'tcx> Mir<'tcx> {
135132 visibility_scope_info : ClearOnDecode < IndexVec < VisibilityScope ,
136133 VisibilityScopeInfo > > ,
137134 promoted : IndexVec < Promoted , Mir < ' tcx > > ,
138- return_ty : Ty < ' tcx > ,
139135 yield_ty : Option < Ty < ' tcx > > ,
140136 local_decls : IndexVec < Local , LocalDecl < ' tcx > > ,
141137 arg_count : usize ,
@@ -145,14 +141,12 @@ impl<'tcx> Mir<'tcx> {
145141 // We need `arg_count` locals, and one for the return pointer
146142 assert ! ( local_decls. len( ) >= arg_count + 1 ,
147143 "expected at least {} locals, got {}" , arg_count + 1 , local_decls. len( ) ) ;
148- assert_eq ! ( local_decls[ RETURN_POINTER ] . ty, return_ty) ;
149144
150145 Mir {
151146 basic_blocks,
152147 visibility_scopes,
153148 visibility_scope_info,
154149 promoted,
155- return_ty,
156150 yield_ty,
157151 generator_drop : None ,
158152 generator_layout : None ,
@@ -273,6 +267,11 @@ impl<'tcx> Mir<'tcx> {
273267 & block. terminator ( ) . source_info
274268 }
275269 }
270+
271+ /// Return the return type, it always return first element from `local_decls` array
272+ pub fn return_ty ( & self ) -> Ty < ' tcx > {
273+ self . local_decls [ RETURN_POINTER ] . ty
274+ }
276275}
277276
278277#[ derive( Clone , Debug ) ]
@@ -299,7 +298,6 @@ impl_stable_hash_for!(struct Mir<'tcx> {
299298 visibility_scopes,
300299 visibility_scope_info,
301300 promoted,
302- return_ty,
303301 yield_ty,
304302 generator_drop,
305303 generator_layout,
@@ -1744,7 +1742,6 @@ impl<'tcx> TypeFoldable<'tcx> for Mir<'tcx> {
17441742 visibility_scopes : self . visibility_scopes . clone ( ) ,
17451743 visibility_scope_info : self . visibility_scope_info . clone ( ) ,
17461744 promoted : self . promoted . fold_with ( folder) ,
1747- return_ty : self . return_ty . fold_with ( folder) ,
17481745 yield_ty : self . yield_ty . fold_with ( folder) ,
17491746 generator_drop : self . generator_drop . fold_with ( folder) ,
17501747 generator_layout : self . generator_layout . fold_with ( folder) ,
@@ -1763,7 +1760,6 @@ impl<'tcx> TypeFoldable<'tcx> for Mir<'tcx> {
17631760 self . generator_layout . visit_with ( visitor) ||
17641761 self . yield_ty . visit_with ( visitor) ||
17651762 self . promoted . visit_with ( visitor) ||
1766- self . return_ty . visit_with ( visitor) ||
17671763 self . local_decls . visit_with ( visitor)
17681764 }
17691765}
0 commit comments