Skip to content

Commit 1e9e319

Browse files
author
Paul Liétar
committed
Move type_has_metadata to trans_utils
1 parent 5341d64 commit 1e9e319

File tree

5 files changed

+17
-15
lines changed

5 files changed

+17
-15
lines changed

src/librustc_trans/common.rs

-13
Original file line numberDiff line numberDiff line change
@@ -152,19 +152,6 @@ pub fn type_is_freeze<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bo
152152
ty.is_freeze(tcx, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP)
153153
}
154154

155-
pub fn type_has_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
156-
if type_is_sized(tcx, ty) {
157-
return false;
158-
}
159-
160-
let tail = tcx.struct_tail(ty);
161-
match tail.sty {
162-
ty::TyForeign(..) => false,
163-
ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true,
164-
_ => bug!("unexpected unsized tail: {:?}", tail.sty),
165-
}
166-
}
167-
168155
/*
169156
* A note on nomenclature of linking: "extern", "foreign", and "upcall".
170157
*

src/librustc_trans/context.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ use rustc::session::Session;
3232
use rustc::ty::layout::{LayoutCx, LayoutError, LayoutTyper, TyLayout};
3333
use rustc::ty::{self, Ty, TyCtxt};
3434
use rustc::util::nodemap::FxHashMap;
35+
use rustc_trans_utils;
3536

3637
use std::ffi::{CStr, CString};
3738
use std::cell::{Cell, RefCell};
@@ -302,7 +303,7 @@ impl<'b, 'tcx> SharedCrateContext<'b, 'tcx> {
302303
}
303304

304305
pub fn type_has_metadata(&self, ty: Ty<'tcx>) -> bool {
305-
common::type_has_metadata(self.tcx, ty)
306+
rustc_trans_utils::common::type_has_metadata(self.tcx, ty)
306307
}
307308

308309
pub fn tcx(&self) -> TyCtxt<'b, 'tcx, 'tcx> {

src/librustc_trans_utils/common.rs

+13
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,19 @@ pub fn type_is_sized<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> boo
2525
ty.is_sized(tcx, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP)
2626
}
2727

28+
pub fn type_has_metadata<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, ty: Ty<'tcx>) -> bool {
29+
if type_is_sized(tcx, ty) {
30+
return false;
31+
}
32+
33+
let tail = tcx.struct_tail(ty);
34+
match tail.sty {
35+
ty::TyForeign(..) => false,
36+
ty::TyStr | ty::TySlice(..) | ty::TyDynamic(..) => true,
37+
_ => bug!("unexpected unsized tail: {:?}", tail.sty),
38+
}
39+
}
40+
2841
pub fn requests_inline<'a, 'tcx>(
2942
tcx: TyCtxt<'a, 'tcx, 'tcx>,
3043
instance: &ty::Instance<'tcx>

src/librustc_trans_utils/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ use rustc::util::nodemap::NodeSet;
5050

5151
use syntax::attr;
5252

53-
mod common;
53+
pub mod common;
5454
pub mod link;
5555
pub mod collector;
5656
pub mod trans_item;

src/librustc_trans_utils/trans_item.rs

+1
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ impl<'a, 'tcx> DefPathBasedNames<'a, 'tcx> {
335335
output);
336336
}
337337
},
338+
ty::TyForeign(did) => self.push_def_path(did, output),
338339
ty::TyFnDef(..) |
339340
ty::TyFnPtr(_) => {
340341
let sig = t.fn_sig(self.tcx);

0 commit comments

Comments
 (0)