diff options
| author | Masaki Hara <ackie.h.gmai@gmail.com> | 2018-09-11 23:30:55 +0900 |
|---|---|---|
| committer | Masaki Hara <ackie.h.gmai@gmail.com> | 2018-10-24 21:59:07 +0900 |
| commit | f2ef005d1d9bfb6a594dc08805eef271fb9bbcd4 (patch) | |
| tree | 8b874e8b74c382e56f7e1608902595f8ffd5f26d /src | |
| parent | 250979c0ae90aa9c309efc9dcdac9e559b72b74d (diff) | |
| download | rust-f2ef005d1d9bfb6a594dc08805eef271fb9bbcd4.tar.gz rust-f2ef005d1d9bfb6a594dc08805eef271fb9bbcd4.zip | |
Resolve to Instance::VtableShim when necessary.
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_codegen_llvm/callee.rs | 16 | ||||
| -rw-r--r-- | src/librustc_codegen_llvm/meth.rs | 2 | ||||
| -rw-r--r-- | src/librustc_mir/monomorphize/collector.rs | 2 |
3 files changed, 18 insertions, 2 deletions
diff --git a/src/librustc_codegen_llvm/callee.rs b/src/librustc_codegen_llvm/callee.rs index 82d85b6ead4..153e300a523 100644 --- a/src/librustc_codegen_llvm/callee.rs +++ b/src/librustc_codegen_llvm/callee.rs @@ -220,3 +220,19 @@ pub fn resolve_and_get_fn( ).unwrap() ) } + +pub fn resolve_and_get_fn_for_vtable( + cx: &CodegenCx<'ll, 'tcx>, + def_id: DefId, + substs: &'tcx Substs<'tcx>, +) -> &'ll Value { + get_fn( + cx, + ty::Instance::resolve_for_vtable( + cx.tcx, + ty::ParamEnv::reveal_all(), + def_id, + substs + ).unwrap() + ) +} diff --git a/src/librustc_codegen_llvm/meth.rs b/src/librustc_codegen_llvm/meth.rs index 29c2e71960c..d38f343d01f 100644 --- a/src/librustc_codegen_llvm/meth.rs +++ b/src/librustc_codegen_llvm/meth.rs @@ -89,7 +89,7 @@ pub fn get_vtable( let methods = tcx.vtable_methods(trait_ref.with_self_ty(tcx, ty)); let methods = methods.iter().cloned().map(|opt_mth| { opt_mth.map_or(nullptr, |(def_id, substs)| { - callee::resolve_and_get_fn(cx, def_id, substs) + callee::resolve_and_get_fn_for_vtable(cx, def_id, substs) }) }); diff --git a/src/librustc_mir/monomorphize/collector.rs b/src/librustc_mir/monomorphize/collector.rs index 66bf1b628ce..6062131c9d2 100644 --- a/src/librustc_mir/monomorphize/collector.rs +++ b/src/librustc_mir/monomorphize/collector.rs @@ -915,7 +915,7 @@ fn create_mono_items_for_vtable_methods<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>, // Walk all methods of the trait, including those of its supertraits let methods = tcx.vtable_methods(poly_trait_ref); let methods = methods.iter().cloned().filter_map(|method| method) - .map(|(def_id, substs)| ty::Instance::resolve( + .map(|(def_id, substs)| ty::Instance::resolve_for_vtable( tcx, ty::ParamEnv::reveal_all(), def_id, |
