mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-20 20:44:52 +00:00
Move type_has_metadata to trans_utils
This commit is contained in:
parent
5341d64f66
commit
1e9e3191ab
@ -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)
|
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".
|
* A note on nomenclature of linking: "extern", "foreign", and "upcall".
|
||||||
*
|
*
|
||||||
|
@ -32,6 +32,7 @@ use rustc::session::Session;
|
|||||||
use rustc::ty::layout::{LayoutCx, LayoutError, LayoutTyper, TyLayout};
|
use rustc::ty::layout::{LayoutCx, LayoutError, LayoutTyper, TyLayout};
|
||||||
use rustc::ty::{self, Ty, TyCtxt};
|
use rustc::ty::{self, Ty, TyCtxt};
|
||||||
use rustc::util::nodemap::FxHashMap;
|
use rustc::util::nodemap::FxHashMap;
|
||||||
|
use rustc_trans_utils;
|
||||||
|
|
||||||
use std::ffi::{CStr, CString};
|
use std::ffi::{CStr, CString};
|
||||||
use std::cell::{Cell, RefCell};
|
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 {
|
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> {
|
pub fn tcx(&self) -> TyCtxt<'b, 'tcx, 'tcx> {
|
||||||
|
@ -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)
|
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>(
|
pub fn requests_inline<'a, 'tcx>(
|
||||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||||
instance: &ty::Instance<'tcx>
|
instance: &ty::Instance<'tcx>
|
||||||
|
@ -50,7 +50,7 @@ use rustc::util::nodemap::NodeSet;
|
|||||||
|
|
||||||
use syntax::attr;
|
use syntax::attr;
|
||||||
|
|
||||||
mod common;
|
pub mod common;
|
||||||
pub mod link;
|
pub mod link;
|
||||||
pub mod collector;
|
pub mod collector;
|
||||||
pub mod trans_item;
|
pub mod trans_item;
|
||||||
|
@ -335,6 +335,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
|
|||||||
output);
|
output);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
ty::TyForeign(did) => self.push_def_path(did, output),
|
||||||
ty::TyFnDef(..) |
|
ty::TyFnDef(..) |
|
||||||
ty::TyFnPtr(_) => {
|
ty::TyFnPtr(_) => {
|
||||||
let sig = t.fn_sig(self.tcx);
|
let sig = t.fn_sig(self.tcx);
|
||||||
|
Loading…
Reference in New Issue
Block a user