Move type_has_metadata to trans_utils

This commit is contained in:
Paul Liétar 2017-10-27 23:36:18 +02:00
parent 5341d64f66
commit 1e9e3191ab
5 changed files with 17 additions and 15 deletions

View File

@ -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".
*

View File

@ -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> {

View File

@ -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>

View File

@ -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;

View File

@ -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);