From 0d8f7164bb2a5b949e8b34e8bf08b19eb32b1144 Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Mon, 17 Oct 2016 16:22:42 +0200 Subject: [PATCH] Review feedback: expand comment and simplify some code. --- src/librustc_typeck/check/dropck.rs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/librustc_typeck/check/dropck.rs b/src/librustc_typeck/check/dropck.rs index 03842f3a0a05d..665931ec324ca 100644 --- a/src/librustc_typeck/check/dropck.rs +++ b/src/librustc_typeck/check/dropck.rs @@ -520,8 +520,9 @@ enum DropckKind<'tcx> { /// Assume all borrowed data access by dtor occurs as if Self has the /// type carried by this variant. In practice this means that some - /// of the type parameters are remapped to `()`, because the developer - /// has asserted that the destructor will not access their contents. + /// of the type parameters are remapped to `()` (and some lifetime + /// parameters remapped to `'static`), because the developer has asserted + /// that the destructor will not access their contents. RevisedSelf(Ty<'tcx>), } @@ -539,13 +540,8 @@ fn has_dtor_of_interest<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, // Find the `impl<..> Drop for _` to inspect any // attributes attached to the impl's generics. - let opt_dtor_method = adt_def.destructor(); - let dtor_method = if let Some(dtor_method) = opt_dtor_method { - dtor_method - } else { - return DropckKind::BorrowedDataMustStrictlyOutliveSelf; - }; - + let dtor_method = adt_def.destructor() + .expect("dtorck type without destructor impossible"); let method = tcx.impl_or_trait_item(dtor_method); let impl_id: DefId = method.container().id(); let revised_ty = revise_self_ty(tcx, adt_def, impl_id, substs);