Skip to content

Commit

Permalink
cleanup: Refactor away DtorKind
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed Jan 30, 2017
1 parent 4a4f8ff commit a5d725c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 25 deletions.
25 changes: 1 addition & 24 deletions src/librustc/ty/mod.rs
Expand Up @@ -9,7 +9,6 @@
// except according to those terms.

pub use self::Variance::*;
pub use self::DtorKind::*;
pub use self::AssociatedItemContainer::*;
pub use self::BorrowKind::*;
pub use self::IntVarValue::*;
Expand Down Expand Up @@ -120,21 +119,6 @@ pub struct Resolutions {
pub maybe_unused_trait_imports: NodeSet,
}

#[derive(Copy, Clone)]
pub enum DtorKind {
NoDtor,
TraitDtor
}

impl DtorKind {
pub fn is_present(&self) -> bool {
match *self {
TraitDtor => true,
_ => false
}
}
}

#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub enum AssociatedItemContainer {
TraitContainer(DefId),
Expand Down Expand Up @@ -1480,7 +1464,7 @@ impl<'a, 'gcx, 'tcx> AdtDef {

/// Returns whether this type has a destructor.
pub fn has_dtor(&self) -> bool {
self.dtor_kind().is_present()
self.destructor.get().is_some()
}

/// Asserts this is a struct and returns the struct's unique
Expand Down Expand Up @@ -1543,13 +1527,6 @@ impl<'a, 'gcx, 'tcx> AdtDef {
self.destructor.set(Some(dtor));
}

pub fn dtor_kind(&self) -> DtorKind {
match self.destructor.get() {
Some(_) => TraitDtor,
None => NoDtor,
}
}

/// Returns a simpler type such that `Self: Sized` if and only
/// if that type is Sized, or `TyErr` if this type is recursive.
///
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans/glue.rs
Expand Up @@ -235,7 +235,7 @@ pub fn implement_drop_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, g: DropGlueKi
bcx.call(dtor, &[ptr.llval], None);
bcx
}
ty::TyAdt(def, ..) if def.dtor_kind().is_present() && !skip_dtor => {
ty::TyAdt(def, ..) if def.has_dtor() && !skip_dtor => {
let shallow_drop = def.is_union();
let tcx = bcx.tcx();

Expand Down

0 comments on commit a5d725c

Please sign in to comment.