Skip to content

Commit c0fc6a8

Browse files
committed
simplify constant value pair field access
1 parent b5ace9a commit c0fc6a8

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

src/librustc_mir/transform/const_prop.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -183,12 +183,7 @@ impl<'b, 'a, 'tcx:'b> ConstPropagator<'b, 'a, 'tcx> {
183183
trace!("layout computed");
184184
use rustc_data_structures::indexed_vec::Idx;
185185
let field_index = field.index();
186-
let val = if field_index == 0 {
187-
a
188-
} else {
189-
assert_eq!(field_index, 1);
190-
b
191-
};
186+
let val = [a, b][field_index];
192187
let field = base_layout.field(&*self, field_index).ok()?;
193188
trace!("projection resulted in: {:?}", val);
194189
Some((Value::ByVal(val), field.ty, span))

0 commit comments

Comments
 (0)