@@ -134,76 +134,70 @@ impl<'tcx> Lvalue<'tcx> {
134134}
135135
136136impl < ' tcx > Rvalue < ' tcx > {
137- pub fn ty < ' a , ' gcx > ( & self , mir : & Mir < ' tcx > , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> Option < Ty < ' tcx > >
137+ pub fn ty < ' a , ' gcx > ( & self , mir : & Mir < ' tcx > , tcx : TyCtxt < ' a , ' gcx , ' tcx > ) -> Ty < ' tcx >
138138 {
139139 match * self {
140- Rvalue :: Use ( ref operand) => Some ( operand. ty ( mir, tcx) ) ,
140+ Rvalue :: Use ( ref operand) => operand. ty ( mir, tcx) ,
141141 Rvalue :: Repeat ( ref operand, ref count) => {
142142 let op_ty = operand. ty ( mir, tcx) ;
143- let count = count. value . as_u64 ( tcx. sess . target . uint_type ) ;
143+ let count = count. as_u64 ( tcx. sess . target . uint_type ) ;
144144 assert_eq ! ( count as usize as u64 , count) ;
145- Some ( tcx. mk_array ( op_ty, count as usize ) )
145+ tcx. mk_array ( op_ty, count as usize )
146146 }
147147 Rvalue :: Ref ( reg, bk, ref lv) => {
148148 let lv_ty = lv. ty ( mir, tcx) . to_ty ( tcx) ;
149- Some ( tcx. mk_ref ( reg,
149+ tcx. mk_ref ( reg,
150150 ty:: TypeAndMut {
151151 ty : lv_ty,
152152 mutbl : bk. to_mutbl_lossy ( )
153153 }
154- ) )
154+ )
155155 }
156- Rvalue :: Len ( ..) => Some ( tcx. types . usize ) ,
157- Rvalue :: Cast ( .., ty) => Some ( ty ) ,
156+ Rvalue :: Len ( ..) => tcx. types . usize ,
157+ Rvalue :: Cast ( .., ty) => ty ,
158158 Rvalue :: BinaryOp ( op, ref lhs, ref rhs) => {
159159 let lhs_ty = lhs. ty ( mir, tcx) ;
160160 let rhs_ty = rhs. ty ( mir, tcx) ;
161- Some ( op. ty ( tcx, lhs_ty, rhs_ty) )
161+ op. ty ( tcx, lhs_ty, rhs_ty)
162162 }
163163 Rvalue :: CheckedBinaryOp ( op, ref lhs, ref rhs) => {
164164 let lhs_ty = lhs. ty ( mir, tcx) ;
165165 let rhs_ty = rhs. ty ( mir, tcx) ;
166166 let ty = op. ty ( tcx, lhs_ty, rhs_ty) ;
167- let ty = tcx. intern_tup ( & [ ty, tcx. types . bool ] , false ) ;
168- Some ( ty)
167+ tcx. intern_tup ( & [ ty, tcx. types . bool ] , false )
169168 }
170169 Rvalue :: UnaryOp ( _, ref operand) => {
171- Some ( operand. ty ( mir, tcx) )
170+ operand. ty ( mir, tcx)
172171 }
173172 Rvalue :: Discriminant ( ref lval) => {
174173 let ty = lval. ty ( mir, tcx) . to_ty ( tcx) ;
175174 if let ty:: TyAdt ( adt_def, _) = ty. sty {
176- Some ( adt_def. repr . discr_type ( ) . to_ty ( tcx) )
175+ adt_def. repr . discr_type ( ) . to_ty ( tcx)
177176 } else {
178177 // Undefined behaviour, bug for now; may want to return something for
179178 // the `discriminant` intrinsic later.
180179 bug ! ( "Rvalue::Discriminant on Lvalue of type {:?}" , ty) ;
181180 }
182181 }
183182 Rvalue :: Box ( t) => {
184- Some ( tcx. mk_box ( t) )
183+ tcx. mk_box ( t)
185184 }
186185 Rvalue :: Aggregate ( ref ak, ref ops) => {
187186 match * ak {
188- AggregateKind :: Array => {
189- if let Some ( operand) = ops. get ( 0 ) {
190- let ty = operand. ty ( mir, tcx) ;
191- Some ( tcx. mk_array ( ty, ops. len ( ) ) )
192- } else {
193- None
194- }
187+ AggregateKind :: Array ( ty) => {
188+ tcx. mk_array ( ty, ops. len ( ) )
195189 }
196190 AggregateKind :: Tuple => {
197- Some ( tcx. mk_tup (
191+ tcx. mk_tup (
198192 ops. iter ( ) . map ( |op| op. ty ( mir, tcx) ) ,
199193 false
200- ) )
194+ )
201195 }
202196 AggregateKind :: Adt ( def, _, substs, _) => {
203- Some ( tcx. item_type ( def. did ) . subst ( tcx, substs) )
197+ tcx. item_type ( def. did ) . subst ( tcx, substs)
204198 }
205199 AggregateKind :: Closure ( did, substs) => {
206- Some ( tcx. mk_closure_from_closure_substs ( did, substs) )
200+ tcx. mk_closure_from_closure_substs ( did, substs)
207201 }
208202 }
209203 }
0 commit comments