From b06836e71a1358021c24a000be26612b5fcbee79 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 13 Nov 2018 12:53:29 +0200 Subject: [PATCH] [eddyb/rebase cleanup] move type_{needs_drop,is_sized,is_freeze} to rustc_codegen_utils --- src/librustc_codegen_llvm/type_.rs | 7 ++++--- src/librustc_codegen_utils/common.rs | 17 ++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/src/librustc_codegen_llvm/type_.rs b/src/librustc_codegen_llvm/type_.rs index d63b19ae7eb..56dac0175e5 100644 --- a/src/librustc_codegen_llvm/type_.rs +++ b/src/librustc_codegen_llvm/type_.rs @@ -27,6 +27,7 @@ use rustc::ty::layout::TyLayout; use rustc_target::abi::call::{CastTarget, FnType, Reg}; use rustc_data_structures::small_c_str::SmallCStr; use common; +use rustc_codegen_utils; use rustc_codegen_utils::common::TypeKind; use type_of::LayoutLlvmExt; use abi::{LlvmType, FnTypeExt}; @@ -363,15 +364,15 @@ impl DerivedTypeMethods<'tcx> for CodegenCx<'ll, 'tcx> { } fn type_needs_drop(&self, ty: Ty<'tcx>) -> bool { - common::type_needs_drop(self.tcx(), ty) + rustc_codegen_utils::common::type_needs_drop(self.tcx(), ty) } fn type_is_sized(&self, ty: Ty<'tcx>) -> bool { - common::type_is_sized(self.tcx(), ty) + rustc_codegen_utils::common::type_is_sized(self.tcx(), ty) } fn type_is_freeze(&self, ty: Ty<'tcx>) -> bool { - common::type_is_freeze(self.tcx(), ty) + rustc_codegen_utils::common::type_is_freeze(self.tcx(), ty) } fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool { diff --git a/src/librustc_codegen_utils/common.rs b/src/librustc_codegen_utils/common.rs index 5dc138b31ff..c274fa4345a 100644 --- a/src/librustc_codegen_utils/common.rs +++ b/src/librustc_codegen_utils/common.rs @@ -7,9 +7,24 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. - #![allow(non_camel_case_types, non_snake_case)] +use rustc::ty::{self, Ty, TyCtxt}; +use syntax_pos::DUMMY_SP; + + +pub fn type_needs_drop<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool { + ty.needs_drop(tcx, ty::ParamEnv::reveal_all()) +} + +pub fn type_is_sized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool { + ty.is_sized(tcx.at(DUMMY_SP), ty::ParamEnv::reveal_all()) +} + +pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool { + ty.is_freeze(tcx, ty::ParamEnv::reveal_all(), DUMMY_SP) +} + pub enum IntPredicate { IntEQ, IntNE,