|
5 | 5 | use rustc_const_eval::const_eval::CheckAlignment;
|
6 | 6 | use rustc_const_eval::interpret::{ConstValue, ImmTy, Immediate, InterpCx, Scalar};
|
7 | 7 | use rustc_data_structures::fx::FxHashMap;
|
| 8 | +use rustc_hir::def::DefKind; |
8 | 9 | use rustc_middle::mir::visit::{MutVisitor, Visitor};
|
9 | 10 | use rustc_middle::mir::*;
|
10 | 11 | use rustc_middle::ty::{self, Ty, TyCtxt};
|
@@ -85,6 +86,30 @@ impl<'tcx> ValueAnalysis<'tcx> for ConstAnalysis<'tcx> {
|
85 | 86 | state: &mut State<Self::Value>,
|
86 | 87 | ) {
|
87 | 88 | match rvalue {
|
| 89 | + Rvalue::Aggregate(kind, operands) => { |
| 90 | + let target = self.map().find(target.as_ref()); |
| 91 | + if let Some(target) = target { |
| 92 | + state.flood_idx_with(target, self.map(), FlatSet::Bottom); |
| 93 | + let field_based = match **kind { |
| 94 | + AggregateKind::Tuple | AggregateKind::Closure(..) => true, |
| 95 | + AggregateKind::Adt(def_id, ..) => { |
| 96 | + matches!(self.tcx.def_kind(def_id), DefKind::Struct) |
| 97 | + } |
| 98 | + _ => false, |
| 99 | + }; |
| 100 | + if field_based { |
| 101 | + for (field_index, operand) in operands.iter().enumerate() { |
| 102 | + if let Some(field) = self |
| 103 | + .map() |
| 104 | + .apply(target, TrackElem::Field(Field::from_usize(field_index))) |
| 105 | + { |
| 106 | + let result = self.handle_operand(operand, state); |
| 107 | + state.assign_idx(field, result, self.map()); |
| 108 | + } |
| 109 | + } |
| 110 | + } |
| 111 | + } |
| 112 | + } |
88 | 113 | Rvalue::CheckedBinaryOp(op, box (left, right)) => {
|
89 | 114 | let target = self.map().find(target.as_ref());
|
90 | 115 | if let Some(target) = target {
|
|
0 commit comments