]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_ssa/callee.rs
Rollup merge of #58440 - gnzlbg:v6, r=japaric
[rust.git] / src / librustc_codegen_ssa / callee.rs
1 use crate::traits::*;
2 use rustc::ty;
3 use rustc::ty::subst::Substs;
4 use rustc::hir::def_id::DefId;
5
6 pub fn resolve_and_get_fn<'tcx, Cx: CodegenMethods<'tcx>>(
7     cx: &Cx,
8     def_id: DefId,
9     substs: &'tcx Substs<'tcx>,
10 ) -> Cx::Value {
11     cx.get_fn(
12         ty::Instance::resolve(
13             cx.tcx(),
14             ty::ParamEnv::reveal_all(),
15             def_id,
16             substs
17         ).unwrap()
18     )
19 }
20
21 pub fn resolve_and_get_fn_for_vtable<'tcx,
22     Cx: Backend<'tcx> + MiscMethods<'tcx> + TypeMethods<'tcx>
23 >(
24     cx: &Cx,
25     def_id: DefId,
26     substs: &'tcx Substs<'tcx>,
27 ) -> Cx::Value {
28     cx.get_fn(
29         ty::Instance::resolve_for_vtable(
30             cx.tcx(),
31             ty::ParamEnv::reveal_all(),
32             def_id,
33             substs
34         ).unwrap()
35     )
36 }