|
1 | 1 | use crate::util::elaborate_drops::DropFlagState;
|
2 | 2 | use rustc_middle::mir::{self, Body, Location};
|
3 | 3 | use rustc_middle::ty::{self, TyCtxt};
|
4 |
| -use rustc_target::abi::VariantIdx; |
5 | 4 |
|
6 | 5 | use super::indexes::MovePathIndex;
|
7 | 6 | use super::move_paths::{InitKind, LookupResult, MoveData};
|
@@ -229,42 +228,3 @@ pub(crate) fn for_location_inits<'tcx, F>(
|
229 | 228 | }
|
230 | 229 | }
|
231 | 230 | }
|
232 |
| - |
233 |
| -/// Calls `handle_inactive_variant` for each descendant move path of `enum_place` that contains a |
234 |
| -/// `Downcast` to a variant besides the `active_variant`. |
235 |
| -/// |
236 |
| -/// NOTE: If there are no move paths corresponding to an inactive variant, |
237 |
| -/// `handle_inactive_variant` will not be called for that variant. |
238 |
| -pub(crate) fn on_all_inactive_variants<'tcx>( |
239 |
| - tcx: TyCtxt<'tcx>, |
240 |
| - body: &mir::Body<'tcx>, |
241 |
| - move_data: &MoveData<'tcx>, |
242 |
| - enum_place: mir::Place<'tcx>, |
243 |
| - active_variant: VariantIdx, |
244 |
| - mut handle_inactive_variant: impl FnMut(MovePathIndex), |
245 |
| -) { |
246 |
| - let enum_mpi = match move_data.rev_lookup.find(enum_place.as_ref()) { |
247 |
| - LookupResult::Exact(mpi) => mpi, |
248 |
| - LookupResult::Parent(_) => return, |
249 |
| - }; |
250 |
| - |
251 |
| - let enum_path = &move_data.move_paths[enum_mpi]; |
252 |
| - for (variant_mpi, variant_path) in enum_path.children(&move_data.move_paths) { |
253 |
| - // Because of the way we build the `MoveData` tree, each child should have exactly one more |
254 |
| - // projection than `enum_place`. This additional projection must be a downcast since the |
255 |
| - // base is an enum. |
256 |
| - let (downcast, base_proj) = variant_path.place.projection.split_last().unwrap(); |
257 |
| - assert_eq!(enum_place.projection.len(), base_proj.len()); |
258 |
| - |
259 |
| - let variant_idx = match *downcast { |
260 |
| - mir::ProjectionElem::Downcast(_, idx) => idx, |
261 |
| - _ => unreachable!(), |
262 |
| - }; |
263 |
| - |
264 |
| - if variant_idx != active_variant { |
265 |
| - on_all_children_bits(tcx, body, move_data, variant_mpi, |mpi| { |
266 |
| - handle_inactive_variant(mpi) |
267 |
| - }); |
268 |
| - } |
269 |
| - } |
270 |
| -} |
0 commit comments