Skip to content

Commit

Permalink
Move type_has_metadata to trans_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Liétar committed Oct 27, 2017
1 parent 5341d64 commit 1e9e319
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 15 deletions.
13 changes: 0 additions & 13 deletions src/librustc_trans/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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".
*
Expand Down
3 changes: 2 additions & 1 deletion src/librustc_trans/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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> {
Expand Down
13 changes: 13 additions & 0 deletions src/librustc_trans_utils/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_trans_utils/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_trans_utils/trans_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1e9e319

Please sign in to comment.