}
pub(super) fn resolve(&self, def_id: DefId, substs: &'tcx Substs<'tcx>) -> EvalResult<'tcx, ty::Instance<'tcx>> {
- let substs = self.tcx.trans_apply_param_substs(self.substs(), &substs);
+ trace!("resolve: {:?}, {:#?}", def_id, substs);
+ trace!("substs: {:#?}", self.substs());
+ trace!("param_env: {:#?}", self.param_env);
+ let substs = self.tcx.trans_apply_param_substs_env(self.substs(), self.param_env, &substs);
ty::Instance::resolve(
*self.tcx,
self.param_env,
bug!("reifying a fn ptr that requires \
const arguments");
}
- let instance = self.resolve(def_id, substs)?;
- let fn_ptr = self.memory.create_fn_alloc(instance);
+ let instance: EvalResult<'tcx, _> = ty::Instance::resolve(
+ *self.tcx,
+ self.param_env,
+ def_id,
+ substs,
+ ).ok_or(EvalErrorKind::TypeckError.into());
+ let fn_ptr = self.memory.create_fn_alloc(instance?);
let valty = ValTy {
value: Value::ByVal(PrimVal::Ptr(fn_ptr)),
ty: dest_ty,
--- /dev/null
+// Copyright 2018 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+struct CustomAutoRooterVFTable {
+ trace: unsafe extern "C" fn(this: *mut i32, trc: *mut u32),
+}
+
+unsafe trait CustomAutoTraceable: Sized {
+ const vftable: CustomAutoRooterVFTable = CustomAutoRooterVFTable {
+ trace: Self::trace,
+ };
+
+ unsafe extern "C" fn trace(this: *mut i32, trc: *mut u32) {
+ let this = this as *const Self;
+ let this = this.as_ref().unwrap();
+ Self::do_trace(this, trc);
+ }
+
+ fn do_trace(&self, trc: *mut u32);
+}
+
+unsafe impl CustomAutoTraceable for () {
+ fn do_trace(&self, _: *mut u32) {
+ // nop
+ }
+}
+
+fn main() {
+ let _ = <()>::vftable;
+}