Skip to content

Commit 531c27d

Browse files
MaikKleinarielb1
authored andcommitted
Move common.rs functionality into TyCtxt
1 parent 98b9eba commit 531c27d

File tree

7 files changed

+14
-103
lines changed

7 files changed

+14
-103
lines changed

src/librustc/ty/instance.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ pub enum InstanceDef<'tcx> {
4545
CloneShim(DefId, Ty<'tcx>),
4646
}
4747

48+
impl<'a, 'tcx> Instance<'tcx> {
49+
pub fn ty(&self,
50+
tcx: TyCtxt<'a, 'tcx, 'tcx>)
51+
-> Ty<'tcx>
52+
{
53+
self.def.def_ty(tcx).subst(tcx, self.substs)
54+
}
55+
}
56+
4857
impl<'tcx> InstanceDef<'tcx> {
4958
#[inline]
5059
pub fn def_id(&self) -> DefId {

src/librustc/ty/mod.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2471,11 +2471,6 @@ impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24712471
}
24722472
}
24732473

2474-
impl<'a, 'tcx> TyCtxt<'a, 'tcx, 'tcx> {
2475-
pub fn is_sized(self, ty: Ty<'tcx>) -> bool {
2476-
ty.is_sized(self, ty::ParamEnv::empty(traits::Reveal::All), DUMMY_SP)
2477-
}
2478-
}
24792474
impl<'a, 'gcx, 'tcx> TyCtxt<'a, 'gcx, 'tcx> {
24802475
pub fn with_freevars<T, F>(self, fid: NodeId, f: F) -> T where
24812476
F: FnOnce(&[hir::Freevar]) -> T,

src/librustc_mir/monomorphize/collector.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,6 @@ use rustc::ty::adjustment::CustomCoerceUnsized;
203203
use rustc::mir::{self, Location};
204204
use rustc::mir::visit::Visitor as MirVisitor;
205205

206-
use common::{def_ty, instance_ty, type_has_metadata};
207206
use monomorphize::{self, Instance};
208207
use rustc::util::nodemap::{FxHashSet, FxHashMap, DefIdMap};
209208

@@ -371,7 +370,7 @@ fn collect_items_rec<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
371370
// Sanity check whether this ended up being collected accidentally
372371
debug_assert!(should_trans_locally(tcx, &instance));
373372

374-
let ty = instance_ty(tcx, &instance);
373+
let ty = instance.ty(tcx);
375374
visit_drop_use(tcx, ty, true, &mut neighbors);
376375

377376
recursion_depth_reset = None;
@@ -916,7 +915,7 @@ impl<'b, 'a, 'v> ItemLikeVisitor<'v> for RootCollector<'b, 'a, 'v> {
916915
debug!("RootCollector: ADT drop-glue for {}",
917916
def_id_to_string(self.tcx, def_id));
918917

919-
let ty = def_ty(self.tcx, def_id, Substs::empty());
918+
let ty = Instance::new(def_id, Substs::empty()).ty(self.tcx);
920919
visit_drop_use(self.tcx, ty, true, self.output);
921920
}
922921
}

src/librustc_mir/monomorphize/common.rs

Whitespace-only changes.

src/librustc_mir/monomorphize/mono_item.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
//! item-path. This is used for unit testing the code that generates
1515
//! paths etc in all kinds of annoying scenarios.
1616
17-
use rustc_trans_utils::common;
1817
use monomorphize::Instance;
1918
use rustc::hir;
2019
use rustc::hir::def_id::DefId;
@@ -98,7 +97,7 @@ pub trait TransItemExt<'a, 'tcx>: fmt::Debug {
9897
// If this function isn't inlined or otherwise has explicit
9998
// linkage, then we'll be creating a globally shared version.
10099
if self.explicit_linkage(tcx).is_some() ||
101-
!common::requests_inline(tcx, instance)
100+
!tcx.requires_local_instance(instance)
102101
{
103102
return InstantiationMode::GloballyShared { may_conflict: false }
104103
}

src/librustc_trans_utils/common.rs

Lines changed: 0 additions & 92 deletions
This file was deleted.

src/librustc_trans_utils/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,8 @@ use rustc::hir::def_id::LOCAL_CRATE;
4444
use rustc::hir::map as hir_map;
4545
use rustc::util::nodemap::NodeSet;
4646

47-
pub mod common;
47+
use syntax::attr;
48+
4849
pub mod link;
4950
pub mod trans_crate;
5051

0 commit comments

Comments
 (0)