]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_ssa/callee.rs
Auto merge of #55705 - ethanboxx:master, r=SimonSapin
[rust.git] / src / librustc_codegen_ssa / callee.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use traits::*;
12 use rustc::ty;
13 use rustc::ty::subst::Substs;
14 use rustc::hir::def_id::DefId;
15
16 pub fn resolve_and_get_fn<'tcx, Cx: CodegenMethods<'tcx>>(
17     cx: &Cx,
18     def_id: DefId,
19     substs: &'tcx Substs<'tcx>,
20 ) -> Cx::Value {
21     cx.get_fn(
22         ty::Instance::resolve(
23             cx.tcx(),
24             ty::ParamEnv::reveal_all(),
25             def_id,
26             substs
27         ).unwrap()
28     )
29 }
30
31 pub fn resolve_and_get_fn_for_vtable<'tcx,
32     Cx: Backend<'tcx> + MiscMethods<'tcx> + TypeMethods<'tcx>
33 >(
34     cx: &Cx,
35     def_id: DefId,
36     substs: &'tcx Substs<'tcx>,
37 ) -> Cx::Value {
38     cx.get_fn(
39         ty::Instance::resolve_for_vtable(
40             cx.tcx(),
41             ty::ParamEnv::reveal_all(),
42             def_id,
43             substs
44         ).unwrap()
45     )
46 }