diff options
| author | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-04-17 21:18:56 +0300 |
|---|---|---|
| committer | Eduard-Mihai Burtescu <edy.burt@gmail.com> | 2017-04-20 14:39:31 +0300 |
| commit | 6563374ed2e518ea5fec2b7411dc4331772c46d2 (patch) | |
| tree | 6211971da9ad119e25d1b2c2e13960c65611a29d /src/librustc_trans | |
| parent | 3f5c311dc1dcb5bfe65d6eecd0dfda04d77c7594 (diff) | |
| download | rust-6563374ed2e518ea5fec2b7411dc4331772c46d2.tar.gz rust-6563374ed2e518ea5fec2b7411dc4331772c46d2.zip | |
rustc: replace interior_unsafe with a Freeze trait.
Diffstat (limited to 'src/librustc_trans')
| -rw-r--r-- | src/librustc_trans/abi.rs | 6 | ||||
| -rw-r--r-- | src/librustc_trans/consts.rs | 3 | ||||
| -rw-r--r-- | src/librustc_trans/context.rs | 4 |
3 files changed, 8 insertions, 5 deletions
diff --git a/src/librustc_trans/abi.rs b/src/librustc_trans/abi.rs index c4fdc46d030..e0a75f3caa7 100644 --- a/src/librustc_trans/abi.rs +++ b/src/librustc_trans/abi.rs @@ -746,13 +746,13 @@ impl<'a, 'tcx> FnType<'tcx> { // `&T` where `T` contains no `UnsafeCell<U>` is immutable, and can be marked as // both `readonly` and `noalias`, as LLVM's definition of `noalias` is based solely // on memory dependencies rather than pointer equality - let interior_unsafe = mt.ty.type_contents(ccx.tcx()).interior_unsafe(); + let is_freeze = ccx.shared().type_is_freeze(mt.ty); - if mt.mutbl != hir::MutMutable && !interior_unsafe { + if mt.mutbl != hir::MutMutable && is_freeze { arg.attrs.set(ArgAttribute::NoAlias); } - if mt.mutbl == hir::MutImmutable && !interior_unsafe { + if mt.mutbl == hir::MutImmutable && is_freeze { arg.attrs.set(ArgAttribute::ReadOnly); } diff --git a/src/librustc_trans/consts.rs b/src/librustc_trans/consts.rs index 7a53a03344f..eb3ac309be1 100644 --- a/src/librustc_trans/consts.rs +++ b/src/librustc_trans/consts.rs @@ -261,8 +261,7 @@ pub fn trans_static<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // As an optimization, all shared statics which do not have interior // mutability are placed into read-only memory. if m != hir::MutMutable { - let tcontents = ty.type_contents(ccx.tcx()); - if !tcontents.interior_unsafe() { + if ccx.shared().type_is_freeze(ty) { llvm::LLVMSetGlobalConstant(g, llvm::True); } } diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index c3770470bfd..fd9ff17cc64 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -399,6 +399,10 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { ty.is_sized(self.tcx, &self.empty_param_env, DUMMY_SP) } + pub fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool { + ty.is_freeze(self.tcx, &self.empty_param_env, DUMMY_SP) + } + pub fn exported_symbols<'a>(&'a self) -> &'a NodeSet { &self.exported_symbols } |
