@@ -134,76 +134,70 @@ impl<'tcx> Lvalue<'tcx> {
134
134
}
135
135
136
136
impl < ' 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 >
138
138
{
139
139
match * self {
140
- Rvalue :: Use ( ref operand) => Some ( operand. ty ( mir, tcx) ) ,
140
+ Rvalue :: Use ( ref operand) => operand. ty ( mir, tcx) ,
141
141
Rvalue :: Repeat ( ref operand, ref count) => {
142
142
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 ) ;
144
144
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 )
146
146
}
147
147
Rvalue :: Ref ( reg, bk, ref lv) => {
148
148
let lv_ty = lv. ty ( mir, tcx) . to_ty ( tcx) ;
149
- Some ( tcx. mk_ref ( reg,
149
+ tcx. mk_ref ( reg,
150
150
ty:: TypeAndMut {
151
151
ty : lv_ty,
152
152
mutbl : bk. to_mutbl_lossy ( )
153
153
}
154
- ) )
154
+ )
155
155
}
156
- Rvalue :: Len ( ..) => Some ( tcx. types . usize ) ,
157
- Rvalue :: Cast ( .., ty) => Some ( ty ) ,
156
+ Rvalue :: Len ( ..) => tcx. types . usize ,
157
+ Rvalue :: Cast ( .., ty) => ty ,
158
158
Rvalue :: BinaryOp ( op, ref lhs, ref rhs) => {
159
159
let lhs_ty = lhs. ty ( mir, tcx) ;
160
160
let rhs_ty = rhs. ty ( mir, tcx) ;
161
- Some ( op. ty ( tcx, lhs_ty, rhs_ty) )
161
+ op. ty ( tcx, lhs_ty, rhs_ty)
162
162
}
163
163
Rvalue :: CheckedBinaryOp ( op, ref lhs, ref rhs) => {
164
164
let lhs_ty = lhs. ty ( mir, tcx) ;
165
165
let rhs_ty = rhs. ty ( mir, tcx) ;
166
166
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 )
169
168
}
170
169
Rvalue :: UnaryOp ( _, ref operand) => {
171
- Some ( operand. ty ( mir, tcx) )
170
+ operand. ty ( mir, tcx)
172
171
}
173
172
Rvalue :: Discriminant ( ref lval) => {
174
173
let ty = lval. ty ( mir, tcx) . to_ty ( tcx) ;
175
174
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)
177
176
} else {
178
177
// Undefined behaviour, bug for now; may want to return something for
179
178
// the `discriminant` intrinsic later.
180
179
bug ! ( "Rvalue::Discriminant on Lvalue of type {:?}" , ty) ;
181
180
}
182
181
}
183
182
Rvalue :: Box ( t) => {
184
- Some ( tcx. mk_box ( t) )
183
+ tcx. mk_box ( t)
185
184
}
186
185
Rvalue :: Aggregate ( ref ak, ref ops) => {
187
186
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 ( ) )
195
189
}
196
190
AggregateKind :: Tuple => {
197
- Some ( tcx. mk_tup (
191
+ tcx. mk_tup (
198
192
ops. iter ( ) . map ( |op| op. ty ( mir, tcx) ) ,
199
193
false
200
- ) )
194
+ )
201
195
}
202
196
AggregateKind :: Adt ( def, _, substs, _) => {
203
- Some ( tcx. item_type ( def. did ) . subst ( tcx, substs) )
197
+ tcx. item_type ( def. did ) . subst ( tcx, substs)
204
198
}
205
199
AggregateKind :: Closure ( did, substs) => {
206
- Some ( tcx. mk_closure_from_closure_substs ( did, substs) )
200
+ tcx. mk_closure_from_closure_substs ( did, substs)
207
201
}
208
202
}
209
203
}
0 commit comments