From 199e60aa220da58f3ce10fe0cc30ce715da3f0c9 Mon Sep 17 00:00:00 2001 From: Eli Friedman Date: Tue, 16 Jun 2015 13:04:01 -0700 Subject: [PATCH] Remove unused type InteriorSafety. --- src/librustc/middle/mem_categorization.rs | 21 ++++--------------- src/librustc/middle/ty.rs | 4 ---- .../borrowck/gather_loans/mod.rs | 20 ++++-------------- 3 files changed, 8 insertions(+), 37 deletions(-) diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index 6d8e412c8a5..9d0a1821deb 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -65,7 +65,6 @@ pub use self::InteriorKind::*; pub use self::FieldName::*; pub use self::ElementKind::*; pub use self::MutabilityCategory::*; -pub use self::InteriorSafety::*; pub use self::AliasableReason::*; pub use self::Note::*; pub use self::deref_kind::*; @@ -1385,12 +1384,6 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { } } -#[derive(Copy, Clone, Debug)] -pub enum InteriorSafety { - InteriorUnsafe, - InteriorSafe -} - #[derive(Clone, Debug)] pub enum Aliasability { FreelyAliasable(AliasableReason), @@ -1404,8 +1397,8 @@ pub enum AliasableReason { AliasableClosure(ast::NodeId), // Aliasable due to capture Fn closure env AliasableOther, UnaliasableImmutable, // Created as needed upon seeing ImmutableUnique - AliasableStatic(InteriorSafety), - AliasableStaticMut(InteriorSafety), + AliasableStatic, + AliasableStaticMut, } impl<'tcx> cmt_<'tcx> { @@ -1469,16 +1462,10 @@ impl<'tcx> cmt_<'tcx> { } cat_static_item(..) => { - let int_safe = if ty::type_interior_is_unsafe(ctxt, self.ty) { - InteriorUnsafe - } else { - InteriorSafe - }; - if self.mutbl.is_mutable() { - FreelyAliasable(AliasableStaticMut(int_safe)) + FreelyAliasable(AliasableStaticMut) } else { - FreelyAliasable(AliasableStatic(int_safe)) + FreelyAliasable(AliasableStatic) } } diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index c24f1d3e7be..e71babf142a 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -3733,10 +3733,6 @@ impl fmt::Debug for TypeContents { } } -pub fn type_interior_is_unsafe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool { - type_contents(cx, ty).interior_unsafe() -} - pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents { return memoized(&cx.tc_cache, ty, |ty| { tc_ty(cx, ty, &mut FnvHashMap()) diff --git a/src/librustc_borrowck/borrowck/gather_loans/mod.rs b/src/librustc_borrowck/borrowck/gather_loans/mod.rs index 733d486d2d2..012e01507de 100644 --- a/src/librustc_borrowck/borrowck/gather_loans/mod.rs +++ b/src/librustc_borrowck/borrowck/gather_loans/mod.rs @@ -191,23 +191,11 @@ fn check_aliasability<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>, /* Uniquely accessible path -- OK for `&` and `&mut` */ Ok(()) } - (mc::Aliasability::FreelyAliasable(mc::AliasableStatic(safety)), ty::ImmBorrow) => { - // Borrow of an immutable static item: - match safety { - mc::InteriorUnsafe => { - // If the static item contains an Unsafe, it has interior - // mutability. In such cases, another phase of the compiler - // will ensure that the type is `Sync` and then trans will - // not put it in rodata, so this is ok to allow. - Ok(()) - } - mc::InteriorSafe => { - // Immutable static can be borrowed, no problem. - Ok(()) - } - } + (mc::Aliasability::FreelyAliasable(mc::AliasableStatic), ty::ImmBorrow) => { + // Borrow of an immutable static item. + Ok(()) } - (mc::Aliasability::FreelyAliasable(mc::AliasableStaticMut(..)), _) => { + (mc::Aliasability::FreelyAliasable(mc::AliasableStaticMut), _) => { // Even touching a static mut is considered unsafe. We assume the // user knows what they're doing in these cases. Ok(())