diff options
| author | Paul Liétar <lietar@google.com> | 2017-10-27 23:36:18 +0200 |
|---|---|---|
| committer | Paul Liétar <lietar@google.com> | 2017-10-27 23:36:18 +0200 |
| commit | 1e9e3191ab01ad16e8a839efeea5cac2999140af (patch) | |
| tree | f255b7046a970dc7319a5d628eca334899ccbe57 | |
| parent | 5341d64f667956530e537f7b7cca26b9f0c39275 (diff) | |
Move type_has_metadata to trans_utils
| -rw-r--r-- | src/librustc_trans/common.rs | 13 | ||||
| -rw-r--r-- | src/librustc_trans/context.rs | 3 | ||||
| -rw-r--r-- | src/librustc_trans_utils/common.rs | 13 | ||||
| -rw-r--r-- | src/librustc_trans_utils/lib.rs | 2 | ||||
| -rw-r--r-- | src/librustc_trans_utils/trans_item.rs | 1 |
5 files changed, 17 insertions, 15 deletions
diff --git a/src/librustc_trans/common.rs b/src/librustc_trans/common.rs index 7c1b0b07d28..e3856cabcf9 100644 --- a/src/librustc_trans/common.rs +++ b/src/librustc_trans/common.rs @@ -152,19 +152,6 @@ pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bo ty.is_freeze(tcx, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP) } -pub fn type_has_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool { - if type_is_sized(tcx, ty) { - return false; - } - - let tail = tcx.struct_tail(ty); - match tail.sty { - ty::TyForeign(..) => false, - ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true, - _ => bug!("unexpected unsized tail: {:?}", tail.sty), - } -} - /* * A note on nomenclature of linking: "extern", "foreign", and "upcall". * diff --git a/src/librustc_trans/context.rs b/src/librustc_trans/context.rs index aca5fda2665..9df057c77a9 100644 --- a/src/librustc_trans/context.rs +++ b/src/librustc_trans/context.rs @@ -32,6 +32,7 @@ use rustc::session::Session; use rustc::ty::layout::{LayoutCx, LayoutError, LayoutTyper, TyLayout}; use rustc::ty::{self, Ty, TyCtxt}; use rustc::util::nodemap::FxHashMap; +use rustc_trans_utils; use std::ffi::{CStr, CString}; use std::cell::{Cell, RefCell}; @@ -302,7 +303,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> { } pub fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool { - common::type_has_metadata(self.tcx, ty) + rustc_trans_utils::common::type_has_metadata(self.tcx, ty) } pub fn tcx(&self) -> TyCtxt<'b, 'tcx, 'tcx> { diff --git a/src/librustc_trans_utils/common.rs b/src/librustc_trans_utils/common.rs index 634e37220e2..ec9c5b1119b 100644 --- a/src/librustc_trans_utils/common.rs +++ b/src/librustc_trans_utils/common.rs @@ -25,6 +25,19 @@ pub fn type_is_sized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> boo ty.is_sized(tcx, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP) } +pub fn type_has_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool { + if type_is_sized(tcx, ty) { + return false; + } + + let tail = tcx.struct_tail(ty); + match tail.sty { + ty::TyForeign(..) => false, + ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true, + _ => bug!("unexpected unsized tail: {:?}", tail.sty), + } +} + pub fn requests_inline<'a, 'tcx>( tcx: TyCtxt<'a, 'tcx, 'tcx>, instance: &ty::Instance<'tcx> diff --git a/src/librustc_trans_utils/lib.rs b/src/librustc_trans_utils/lib.rs index bc8f8d5a6da..bcc59a4d06a 100644 --- a/src/librustc_trans_utils/lib.rs +++ b/src/librustc_trans_utils/lib.rs @@ -50,7 +50,7 @@ use rustc::util::nodemap::NodeSet; use syntax::attr; -mod common; +pub mod common; pub mod link; pub mod collector; pub mod trans_item; diff --git a/src/librustc_trans_utils/trans_item.rs b/src/librustc_trans_utils/trans_item.rs index 0ada39d7d27..817ceefeb7f 100644 --- a/src/librustc_trans_utils/trans_item.rs +++ b/src/librustc_trans_utils/trans_item.rs @@ -335,6 +335,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> { output); } }, + ty::TyForeign(did) => self.push_def_path(did, output), ty::TyFnDef(..) | ty::TyFnPtr(_) => { let sig = t.fn_sig(self.tcx); |
