]> git.lizzy.rs Git - rust.git/commitdiff
Simplified logic and corrected shallow to deep.
authorDavid Wood <david@davidtw.co>
Mon, 5 Feb 2018 17:04:25 +0000 (17:04 +0000)
committerDavid Wood <david@davidtw.co>
Wed, 14 Feb 2018 18:17:53 +0000 (18:17 +0000)
src/librustc_mir/borrow_check/mod.rs

index af834ede1ee3368d37d655608f9a80cddc77b2a1..46f94f2388ffe305e67014d4acf6013c3fd369cc 100644 (file)
@@ -727,35 +727,17 @@ fn visit_terminator_drop(
             // See #47703.
             ty::TyAdt(def, substs) if def.is_struct() && !def.has_dtor(self.tcx) => {
                 for (index, field) in def.all_fields().enumerate() {
-                    let field_ty = field.ty(self.tcx, substs);
-                    let proj = Projection {
-                        base: drop_place.clone(),
-                        elem: ProjectionElem::Field(Field::new(index), field_ty),
-                    };
-                    let place = Place::Projection(Box::new(proj));
-
-                    match field_ty.sty {
-                        // It may be the case that this issue occurs with a struct within a
-                        // struct, so we recurse to handle that.
-                        ty::TyAdt(def, _) if def.is_struct() && !def.has_dtor(self.tcx) => {
-                            self.visit_terminator_drop(
-                                loc,
-                                term,
-                                flow_state,
-                                &place,
-                                span,
-                            );
-                        },
-                        _ => {
-                            self.access_place(
-                                ContextKind::Drop.new(loc),
-                                (&place, span),
-                                (Shallow(None), Write(WriteKind::StorageDeadOrDrop)),
-                                LocalMutationIsAllowed::Yes,
-                                flow_state,
-                            );
-                        },
-                    }
+                    let place = drop_place.clone();
+                    let place = place.field(Field::new(index), field.ty(self.tcx, substs));
+                    let place = place.deref();
+
+                    self.visit_terminator_drop(
+                        loc,
+                        term,
+                        flow_state,
+                        &place,
+                        span,
+                    );
                 }
             },
             _ => {