From aaca5a38ee1a2144ba84bf863e59bafb89c37346 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Sat, 24 Nov 2018 17:23:22 +0100 Subject: [PATCH] Rename StaticMethods::static_ptrcast to ConstMethods::const_ptrcast --- src/librustc_codegen_llvm/callee.rs | 2 +- src/librustc_codegen_llvm/common.rs | 4 ++++ src/librustc_codegen_llvm/consts.rs | 4 ---- src/librustc_codegen_ssa/base.rs | 2 +- src/librustc_codegen_ssa/traits/consts.rs | 3 ++- src/librustc_codegen_ssa/traits/statics.rs | 1 - 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/librustc_codegen_llvm/callee.rs b/src/librustc_codegen_llvm/callee.rs index e79880e8de06..f13eeb6692c3 100644 --- a/src/librustc_codegen_llvm/callee.rs +++ b/src/librustc_codegen_llvm/callee.rs @@ -81,7 +81,7 @@ pub fn get_fn( // other weird situations. Annoying. if cx.val_ty(llfn) != llptrty { debug!("get_fn: casting {:?} to {:?}", llfn, llptrty); - cx.static_ptrcast(llfn, llptrty) + cx.const_ptrcast(llfn, llptrty) } else { debug!("get_fn: not casting pointer!"); llfn diff --git a/src/librustc_codegen_llvm/common.rs b/src/librustc_codegen_llvm/common.rs index b45a378538f0..f9850a08afec 100644 --- a/src/librustc_codegen_llvm/common.rs +++ b/src/librustc_codegen_llvm/common.rs @@ -366,6 +366,10 @@ impl ConstMethods<'tcx> for CodegenCx<'ll, 'tcx> { let llval = self.static_bitcast(llval, self.type_ptr_to(layout.llvm_type(self))); PlaceRef::new_sized(llval, layout, alloc.align) } + + fn const_ptrcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value { + consts::ptrcast(val, ty) + } } pub fn val_ty(v: &'ll Value) -> &'ll Type { diff --git a/src/librustc_codegen_llvm/consts.rs b/src/librustc_codegen_llvm/consts.rs index d9afded6834b..4c2d73282cb0 100644 --- a/src/librustc_codegen_llvm/consts.rs +++ b/src/librustc_codegen_llvm/consts.rs @@ -180,10 +180,6 @@ impl CodegenCx<'ll, 'tcx> { } impl StaticMethods for CodegenCx<'ll, 'tcx> { - fn static_ptrcast(&self, val: &'ll Value, ty: &'ll Type) -> &'ll Value { - ptrcast(val, ty) - } - fn static_addr_of_mut( &self, cv: &'ll Value, diff --git a/src/librustc_codegen_ssa/base.rs b/src/librustc_codegen_ssa/base.rs index 6425a19e4b61..266f78996b32 100644 --- a/src/librustc_codegen_ssa/base.rs +++ b/src/librustc_codegen_ssa/base.rs @@ -192,7 +192,7 @@ pub fn unsized_info<'tcx, Cx: CodegenMethods<'tcx>>( (_, &ty::Dynamic(ref data, ..)) => { let vtable_ptr = cx.layout_of(cx.tcx().mk_mut_ptr(target)) .field(cx, FAT_PTR_EXTRA); - cx.static_ptrcast(meth::get_vtable(cx, source, data.principal()), + cx.const_ptrcast(meth::get_vtable(cx, source, data.principal()), cx.backend_type(vtable_ptr)) } _ => bug!("unsized_info: invalid unsizing {:?} -> {:?}", diff --git a/src/librustc_codegen_ssa/traits/consts.rs b/src/librustc_codegen_ssa/traits/consts.rs index e30567c78faa..af49410794ef 100644 --- a/src/librustc_codegen_ssa/traits/consts.rs +++ b/src/librustc_codegen_ssa/traits/consts.rs @@ -17,7 +17,6 @@ use syntax::symbol::LocalInternedString; pub trait ConstMethods<'tcx>: BackendTypes { // Constant constructors - fn const_null(&self, t: Self::Type) -> Self::Value; fn const_undef(&self, t: Self::Type) -> Self::Value; fn const_int(&self, t: Self::Type, i: i64) -> Self::Value; @@ -61,4 +60,6 @@ pub trait ConstMethods<'tcx>: BackendTypes { alloc: &Allocation, offset: layout::Size, ) -> PlaceRef<'tcx, Self::Value>; + + fn const_ptrcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value; } diff --git a/src/librustc_codegen_ssa/traits/statics.rs b/src/librustc_codegen_ssa/traits/statics.rs index 7ea90dfcce09..0eeddd9a29e3 100644 --- a/src/librustc_codegen_ssa/traits/statics.rs +++ b/src/librustc_codegen_ssa/traits/statics.rs @@ -13,7 +13,6 @@ use rustc::hir::def_id::DefId; use rustc::ty::layout::Align; pub trait StaticMethods: BackendTypes { - fn static_ptrcast(&self, val: Self::Value, ty: Self::Type) -> Self::Value; fn static_addr_of_mut(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value; fn static_addr_of(&self, cv: Self::Value, align: Align, kind: Option<&str>) -> Self::Value; fn get_static(&self, def_id: DefId) -> Self::Value;