Skip to content

Commit

Permalink
Rename Instance.ty to Instance.monomorphic_ty
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron1011 committed Jan 5, 2020
1 parent 464b58c commit 33caf0b
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 16 deletions.
8 changes: 2 additions & 6 deletions src/librustc/ty/instance.rs
Expand Up @@ -73,17 +73,13 @@ impl<'tcx> Instance<'tcx> {
/// (e.g. when we are attempting to to do const-propagation).
/// In this case, `Instace.ty_env` should be used to provide
/// the `ParamEnv` for our generic context.
pub fn ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
pub fn monomorphic_ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
let ty = tcx.type_of(self.def.def_id());
// There shouldn't be any params - if there are, then
// Instance.ty_env should have been used to provide the proper
// ParamEnv
if self.substs.has_param_types() {
bug!(
"Instance.ty called for type {:?} with params in substs: {:?}",
ty,
self.substs
);
bug!("Instance.ty called for type {:?} with params in substs: {:?}", ty, self.substs);
}
tcx.subst_and_normalize_erasing_regions(self.substs, ty::ParamEnv::reveal_all(), &ty)
}
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/layout.rs
Expand Up @@ -2301,7 +2301,7 @@ impl<'tcx> ty::Instance<'tcx> {
// or should go through `FnAbi` instead, to avoid losing any
// adjustments `FnAbi::of_instance` might be performing.
fn fn_sig_for_fn_abi(&self, tcx: TyCtxt<'tcx>) -> ty::PolyFnSig<'tcx> {
let ty = self.ty(tcx);
let ty = self.monomorphic_ty(tcx);
match ty.kind {
ty::FnDef(..) |
// Shims currently have type FnPtr. Not sure this should remain.
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/callee.rs
Expand Up @@ -36,7 +36,7 @@ pub fn get_fn(cx: &CodegenCx<'ll, 'tcx>, instance: Instance<'tcx>) -> &'ll Value
}

let sym = tcx.symbol_name(instance).name.as_str();
debug!("get_fn({:?}: {:?}) => {}", instance, instance.ty(cx.tcx()), sym);
debug!("get_fn({:?}: {:?}) => {}", instance, instance.monomorphic_ty(cx.tcx()), sym);

let fn_abi = FnAbi::of_instance(cx, instance, &[]);

Expand Down
4 changes: 2 additions & 2 deletions src/librustc_codegen_llvm/consts.rs
Expand Up @@ -204,7 +204,7 @@ impl CodegenCx<'ll, 'tcx> {
def_id
);

let ty = instance.ty(self.tcx);
let ty = instance.monomorphic_ty(self.tcx);
let sym = self.tcx.symbol_name(instance).name;

debug!("get_static: sym={} instance={:?}", sym, instance);
Expand Down Expand Up @@ -361,7 +361,7 @@ impl StaticMethods for CodegenCx<'ll, 'tcx> {
};

let instance = Instance::mono(self.tcx, def_id);
let ty = instance.ty(self.tcx);
let ty = instance.monomorphic_ty(self.tcx);
let llty = self.layout_of(ty).llvm_type(self);
let g = if val_llty == llty {
g
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/debuginfo/metadata.rs
Expand Up @@ -2287,7 +2287,7 @@ pub fn create_global_var_metadata(cx: &CodegenCx<'ll, '_>, def_id: DefId, global
};

let is_local_to_unit = is_node_local_to_unit(cx, def_id);
let variable_type = Instance::mono(cx.tcx, def_id).ty(cx.tcx);
let variable_type = Instance::mono(cx.tcx, def_id).monomorphic_ty(cx.tcx);
let type_metadata = type_metadata(cx, variable_type, span);
let var_name = SmallCStr::new(&tcx.item_name(def_id).as_str());
let linkage_name = if no_mangle {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/intrinsic.rs
Expand Up @@ -89,7 +89,7 @@ impl IntrinsicCallMethods<'tcx> for Builder<'a, 'll, 'tcx> {
span: Span,
) {
let tcx = self.tcx;
let callee_ty = instance.ty(tcx);
let callee_ty = instance.monomorphic_ty(tcx);

let (def_id, substs) = match callee_ty.kind {
ty::FnDef(def_id, substs) => (def_id, substs),
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_codegen_llvm/mono_item.rs
Expand Up @@ -22,7 +22,7 @@ impl PreDefineMethods<'tcx> for CodegenCx<'ll, 'tcx> {
symbol_name: &str,
) {
let instance = Instance::mono(self.tcx, def_id);
let ty = instance.ty(self.tcx);
let ty = instance.monomorphic_ty(self.tcx);
let llty = self.layout_of(ty).llvm_type(self);

let g = self.define_global(symbol_name, llty).unwrap_or_else(|| {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc_mir/interpret/traits.rs
Expand Up @@ -140,7 +140,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
// to determine the type.
let drop_instance = self.memory.get_fn(drop_fn)?.as_instance()?;
trace!("Found drop fn: {:?}", drop_instance);
let fn_sig = drop_instance.ty(*self.tcx).fn_sig(*self.tcx);
let fn_sig = drop_instance.monomorphic_ty(*self.tcx).fn_sig(*self.tcx);
let fn_sig = self.tcx.normalize_erasing_late_bound_regions(self.param_env, &fn_sig);
// The drop function takes `*mut T` where `T` is the type being dropped, so get that.
let args = fn_sig.inputs();
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_mir/monomorphize/collector.rs
Expand Up @@ -358,7 +358,7 @@ fn collect_items_rec<'tcx>(
// Sanity check whether this ended up being collected accidentally
debug_assert!(should_monomorphize_locally(tcx, &instance));

let ty = instance.ty(tcx);
let ty = instance.monomorphic_ty(tcx);
visit_drop_use(tcx, ty, true, &mut neighbors);

recursion_depth_reset = None;
Expand Down Expand Up @@ -1002,7 +1002,8 @@ impl ItemLikeVisitor<'v> for RootCollector<'_, 'v> {
def_id_to_string(self.tcx, def_id)
);

let ty = Instance::new(def_id, InternalSubsts::empty()).ty(self.tcx);
let ty =
Instance::new(def_id, InternalSubsts::empty()).monomorphic_ty(self.tcx);
visit_drop_use(self.tcx, ty, true, self.output);
}
}
Expand Down

0 comments on commit 33caf0b

Please sign in to comment.