version = "0.1.0"
dependencies = [
"byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "compiletest_rs 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
- "env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "compiletest_rs 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
+ "env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"log_settings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "compiletest_rs"
-version = "0.2.0"
+version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
[[package]]
name = "env_logger"
-version = "0.3.3"
+version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex 0.1.71 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
version = "0.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "winapi 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
+ "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)",
"winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "libc"
-version = "0.2.12"
+version = "0.2.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
- "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex"
-version = "0.1.71"
+version = "0.1.73"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"aho-corasick 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)",
"memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)",
- "regex-syntax 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
+ "regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"thread_local 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)",
"utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
name = "regex-syntax"
-version = "0.3.3"
+version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
+ "libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "winapi"
-version = "0.2.7"
+version = "0.2.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
version = "0.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
+[metadata]
+"checksum aho-corasick 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2b3fb52b09c1710b961acb35390d514be82e4ac96a9969a8e38565a29b878dc9"
+"checksum byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "96c8b41881888cc08af32d47ac4edd52bc7fa27fef774be47a92443756451304"
+"checksum compiletest_rs 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "0bcddebf582c5c035cce855a89596eb686cc40b9e77da1026fba735dcca2fbd3"
+"checksum env_logger 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "82dcb9ceed3868a03b335657b85a159736c961900f7e7747d3b0b97b9ccb5ccb"
+"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d"
+"checksum lazy_static 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "49247ec2a285bb3dcb23cbd9c35193c025e7251bfce77c1d5da97e6362dffe7f"
+"checksum libc 0.2.15 (registry+https://github.com/rust-lang/crates.io-index)" = "23e3757828fa702a20072c37ff47938e9dd331b92fac6e223d26d4b7a55f7ee2"
+"checksum log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "ab83497bf8bf4ed2a74259c1c802351fcd67a65baa86394b6ba73c36f4838054"
+"checksum log_settings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3d382732ea0fbc09790c4899db3255bdea0fc78b54bf234bd18a63bb603915b6"
+"checksum memchr 0.1.11 (registry+https://github.com/rust-lang/crates.io-index)" = "d8b629fb514376c675b98c1421e80b151d3817ac42d7c667717d282761418d20"
+"checksum regex 0.1.73 (registry+https://github.com/rust-lang/crates.io-index)" = "56b7ee9f764ecf412c6e2fff779bca4b22980517ae335a21aeaf4e32625a5df2"
+"checksum regex-syntax 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "31040aad7470ad9d8c46302dcffba337bb4289ca5da2e3cd6e37b64109a85199"
+"checksum rustc-serialize 0.3.19 (registry+https://github.com/rust-lang/crates.io-index)" = "6159e4e6e559c81bd706afe9c8fd68f547d3e851ce12e76b1de7914bab61691b"
+"checksum thread-id 2.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a9539db560102d1cef46b8b78ce737ff0bb64e7e18d35b2a5688f7d097d0ff03"
+"checksum thread_local 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "55dd963dbaeadc08aa7266bf7f91c3154a7805e32bb94b820b769d2ef3b4744d"
+"checksum utf8-ranges 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "a1ca13c08c41c9c3e04224ed9ff80461d97e121589ff27c753a16cb10830ae0f"
+"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a"
+"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc"
let tcx = state.tcx.unwrap();
let mir_map = state.mir_map.unwrap();
- let (node_id, _) = state.session.entry_fn.borrow()
+ let (entry_node_id, _) = state.session.entry_fn.borrow()
.expect("no main or start function found");
+ let entry_def_id = tcx.map.local_def_id(entry_node_id);
let krate = state.hir_crate.as_ref().unwrap();
let mut memory_size = 100*1024*1024; // 100MB
}
}
- let mut mir_map = MirMap { map: mir_map.map.clone() };
- run_mir_passes(tcx, &mut mir_map);
- eval_main(tcx, &mir_map, node_id, memory_size, step_limit, stack_limit);
+ let mut mir_map_copy = MirMap::new(tcx.dep_graph.clone());
+ for def_id in mir_map.map.keys() {
+ mir_map_copy.map.insert(def_id, mir_map.map.get(&def_id).unwrap().clone());
+ }
+ run_mir_passes(tcx, &mut mir_map_copy);
+ eval_main(tcx, &mir_map_copy, entry_def_id, memory_size, step_limit, stack_limit);
state.session.abort_if_errors();
});
use rustc::hir::def_id::DefId;
use rustc::mir::mir_map::MirMap;
use rustc::mir::repr as mir;
-use rustc::traits::ProjectionMode;
+use rustc::traits::Reveal;
use rustc::ty::layout::{self, Layout, Size};
use rustc::ty::subst::{self, Subst, Substs};
use rustc::ty::{self, Ty, TyCtxt};
use std::ops::Deref;
use std::rc::Rc;
use std::iter;
-use syntax::ast;
use syntax::codemap::{self, DUMMY_SP};
use error::{EvalError, EvalResult};
}
}
- pub fn alloc_ret_ptr(&mut self, output_ty: ty::FnOutput<'tcx>, substs: &'tcx Substs<'tcx>) -> EvalResult<'tcx, Option<Pointer>> {
- match output_ty {
- ty::FnConverging(ty) => {
- let size = self.type_size_with_substs(ty, substs);
- let align = self.type_align_with_substs(ty, substs);
- self.memory.allocate(size, align).map(Some)
- }
- ty::FnDiverging => Ok(None),
- }
+ pub fn alloc_ret_ptr(&mut self, ty: Ty<'tcx>, substs: &'tcx Substs<'tcx>) -> EvalResult<'tcx, Pointer> {
+ let size = self.type_size_with_substs(ty, substs);
+ let align = self.type_align_with_substs(ty, substs);
+ self.memory.allocate(size, align)
}
pub fn memory(&self) -> &Memory<'a, 'tcx> {
}
pub fn load_mir(&self, def_id: DefId) -> CachedMir<'a, 'tcx> {
- match self.tcx.map.as_local_node_id(def_id) {
- Some(node_id) => CachedMir::Ref(self.mir_map.map.get(&node_id).unwrap()),
- None => {
- let mut mir_cache = self.mir_cache.borrow_mut();
- if let Some(mir) = mir_cache.get(&def_id) {
- return CachedMir::Owned(mir.clone());
- }
-
- let cs = &self.tcx.sess.cstore;
- let mir = cs.maybe_get_item_mir(self.tcx, def_id).unwrap_or_else(|| {
- panic!("no mir for `{}`", self.tcx.item_path_str(def_id));
- });
- let cached = Rc::new(mir);
- mir_cache.insert(def_id, cached.clone());
- CachedMir::Owned(cached)
+ if def_id.is_local() {
+ CachedMir::Ref(self.mir_map.map.get(&def_id).unwrap())
+ } else {
+ let mut mir_cache = self.mir_cache.borrow_mut();
+ if let Some(mir) = mir_cache.get(&def_id) {
+ return CachedMir::Owned(mir.clone());
}
+
+ let cs = &self.tcx.sess.cstore;
+ let mir = cs.maybe_get_item_mir(self.tcx, def_id).unwrap_or_else(|| {
+ panic!("no mir for `{}`", self.tcx.item_path_str(def_id));
+ });
+ let cached = Rc::new(mir);
+ mir_cache.insert(def_id, cached.clone());
+ CachedMir::Owned(cached)
}
}
// TODO(solson): Is this inefficient? Needs investigation.
let ty = self.monomorphize(ty, substs);
- self.tcx.normalizing_infer_ctxt(ProjectionMode::Any).enter(|infcx| {
+ self.tcx.normalizing_infer_ctxt(Reveal::All).enter(|infcx| {
// TODO(solson): Report this error properly.
ty.layout(&infcx).unwrap()
})
Temp(i) => self.frame().locals[self.frame().temp_offset + i.index()],
Static(def_id) => {
- let substs = self.tcx.mk_substs(subst::Substs::empty());
+ let substs = subst::Substs::empty(self.tcx);
let cid = ConstantId {
def_id: def_id,
substs: substs,
}
fn lvalue_ty(&self, lvalue: &mir::Lvalue<'tcx>) -> Ty<'tcx> {
- self.monomorphize(self.mir().lvalue_ty(self.tcx, lvalue).to_ty(self.tcx), self.substs())
+ self.monomorphize(lvalue.ty(&self.mir(), self.tcx).to_ty(self.tcx), self.substs())
}
fn operand_ty(&self, operand: &mir::Operand<'tcx>) -> Ty<'tcx> {
- self.monomorphize(self.mir().operand_ty(self.tcx, operand), self.substs())
+ self.monomorphize(operand.ty(&self.mir(), self.tcx), self.substs())
}
fn move_(&mut self, src: Pointer, dest: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, ()> {
pub fn eval_main<'a, 'tcx: 'a>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
mir_map: &'a MirMap<'tcx>,
- node_id: ast::NodeId,
+ def_id: DefId,
memory_size: usize,
step_limit: u64,
stack_limit: usize,
) {
- let mir = mir_map.map.get(&node_id).expect("no mir for main function");
- let def_id = tcx.map.local_def_id(node_id);
+ let mir = mir_map.map.get(&def_id).expect("no mir for main function");
let mut ecx = EvalContext::new(tcx, mir_map, memory_size, stack_limit);
- let substs = tcx.mk_substs(subst::Substs::empty());
+ let substs = subst::Substs::empty(tcx);
let return_ptr = ecx.alloc_ret_ptr(mir.return_ty, substs)
- .expect("should at least be able to allocate space for the main function's return value")
- .expect("main function should not be diverging");
+ .expect("should at least be able to allocate space for the main function's return value");
ecx.push_stack_frame(def_id, mir.span, CachedMir::Ref(mir), substs, Some(return_ptr))
- .expect("could not allocate first stack frame");
+ .expect("could not allocate first stack frame");
if mir.arg_decls.len() == 2 {
// start function
struct Instance<'tcx>(DefId, &'tcx subst::Substs<'tcx>);
impl<'tcx> fmt::Display for Instance<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
- ppaux::parameterized(f, self.1, self.0, ppaux::Ns::Value, &[],
- |tcx| Some(tcx.lookup_item_type(self.0).generics))
+ ppaux::parameterized(f, self.1, self.0, ppaux::Ns::Value, &[])
}
}
err.span_note(span, &format!("inside call to {}", Instance(def_id, substs)));
fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> EvalResult<'tcx, ()> {
trace!("{:?}", stmt);
- let mir::StatementKind::Assign(ref lvalue, ref rvalue) = stmt.kind;
- self.eval_assignment(lvalue, rvalue)?;
+
+ use rustc::mir::repr::StatementKind::*;
+ match stmt.kind {
+ Assign(ref lvalue, ref rvalue) => self.eval_assignment(lvalue, rvalue)?,
+ SetDiscriminant { .. } => unimplemented!(),
+
+ // Miri can safely ignore these. Only translation needs them.
+ StorageLive(_) | StorageDead(_) => {}
+ }
+
self.frame_mut().stmt += 1;
Ok(())
}
let mir = self.ecx.load_mir(def_id);
self.try(|this| {
let ptr = this.ecx.alloc_ret_ptr(mir.return_ty, substs)?;
- let ptr = ptr.expect("there's no such thing as an unreachable static");
this.ecx.statics.insert(cid.clone(), ptr);
this.ecx.push_stack_frame(def_id, span, mir, substs, Some(ptr))
});
let return_ty = mir.return_ty;
self.try(|this| {
let return_ptr = this.ecx.alloc_ret_ptr(return_ty, cid.substs)?;
- let return_ptr = return_ptr.expect("there's no such thing as an unreachable static");
let mir = CachedMir::Owned(Rc::new(mir));
this.ecx.statics.insert(cid.clone(), return_ptr);
this.ecx.push_stack_frame(this.def_id, constant.span, mir, this.substs, Some(return_ptr))
fn visit_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>, context: LvalueContext) {
self.super_lvalue(lvalue, context);
if let mir::Lvalue::Static(def_id) = *lvalue {
- let substs = self.ecx.tcx.mk_substs(subst::Substs::empty());
+ let substs = subst::Substs::empty(self.ecx.tcx);
let span = self.span;
self.global_item(def_id, substs, span);
}
use rustc::hir::def_id::DefId;
use rustc::mir::repr as mir;
-use rustc::traits::{self, ProjectionMode};
+use rustc::traits::{self, Reveal};
use rustc::ty::fold::TypeFoldable;
use rustc::ty::layout::Layout;
-use rustc::ty::subst::{self, Substs};
+use rustc::ty::subst::Substs;
use rustc::ty::{self, Ty, TyCtxt, BareFnTy};
use std::rc::Rc;
use std::iter;
use syntax::abi::Abi;
match fn_ty.abi {
Abi::RustIntrinsic => {
- let name = self.tcx.item_name(def_id).as_str();
- match fn_ty.sig.0.output {
- ty::FnConverging(ty) => {
- let layout = self.type_layout(ty);
- let ret = return_ptr.unwrap();
- self.call_intrinsic(&name, substs, args, ret, layout)
- }
- ty::FnDiverging => unimplemented!(),
- }
+ let ty = fn_ty.sig.0.output;
+ let layout = self.type_layout(ty);
+ let ret = return_ptr.unwrap();
+ self.call_intrinsic(def_id, substs, args, ret, layout)
}
Abi::C => {
- match fn_ty.sig.0.output {
- ty::FnConverging(ty) => {
- let size = self.type_size(ty);
- self.call_c_abi(def_id, args, return_ptr.unwrap(), size)
- }
- ty::FnDiverging => unimplemented!(),
- }
+ let ty = fn_ty.sig.0.output;
+ let size = self.type_size(ty);
+ self.call_c_abi(def_id, args, return_ptr.unwrap(), size)
}
Abi::Rust | Abi::RustCall => {
// FnMut closure via FnOnce::call_once.
// Only trait methods can have a Self parameter.
- let (resolved_def_id, resolved_substs) = if substs.self_ty().is_some() {
- self.trait_method(def_id, substs)
- } else {
- (def_id, substs)
- };
+ let (resolved_def_id, resolved_substs) =
+ if let Some(trait_id) = self.tcx.trait_of_item(def_id) {
+ self.trait_method(trait_id, def_id, substs)
+ } else {
+ (def_id, substs)
+ };
let mut arg_srcs = Vec::new();
for arg in args {
fn call_intrinsic(
&mut self,
- name: &str,
+ def_id: DefId,
substs: &'tcx Substs<'tcx>,
args: &[mir::Operand<'tcx>],
dest: Pointer,
.map(|arg| self.eval_operand(arg))
.collect();
let args_ptrs = args_res?;
-
let pointer_size = self.memory.pointer_size();
- match name {
+ match &self.tcx.item_name(def_id).as_str()[..] {
"add_with_overflow" => self.intrinsic_with_overflow(mir::BinOp::Add, &args[0], &args[1], dest, dest_layout)?,
"sub_with_overflow" => self.intrinsic_with_overflow(mir::BinOp::Sub, &args[0], &args[1], dest, dest_layout)?,
"mul_with_overflow" => self.intrinsic_with_overflow(mir::BinOp::Mul, &args[0], &args[1], dest, dest_layout)?,
"assume" => {}
"copy_nonoverlapping" => {
- let elem_ty = *substs.types.get(subst::FnSpace, 0);
+ let elem_ty = substs.types[0];
let elem_size = self.type_size(elem_ty);
let elem_align = self.type_align(elem_ty);
let src = self.memory.read_ptr(args_ptrs[0])?;
}
"discriminant_value" => {
- let ty = *substs.types.get(subst::FnSpace, 0);
+ let ty = substs.types[0];
let adt_ptr = self.memory.read_ptr(args_ptrs[0])?;
let discr_val = self.read_discriminant_value(adt_ptr, ty)?;
self.memory.write_uint(dest, discr_val, 8)?;
"init" => self.memory.write_repeat(dest, 0, dest_layout.size(&self.tcx.data_layout).bytes() as usize)?,
"min_align_of" => {
- let elem_ty = *substs.types.get(subst::FnSpace, 0);
+ let elem_ty = substs.types[0];
let elem_align = self.type_align(elem_ty);
self.memory.write_uint(dest, elem_align as u64, pointer_size)?;
}
"move_val_init" => {
- let ty = *substs.types.get(subst::FnSpace, 0);
+ let ty = substs.types[0];
let ptr = self.memory.read_ptr(args_ptrs[0])?;
self.move_(args_ptrs[1], ptr, ty)?;
}
"offset" => {
- let pointee_ty = *substs.types.get(subst::FnSpace, 0);
+ let pointee_ty = substs.types[0];
let pointee_size = self.type_size(pointee_ty) as isize;
let ptr_arg = args_ptrs[0];
let offset = self.memory.read_isize(args_ptrs[1])?;
"overflowing_sub" => {
self.intrinsic_overflowing(mir::BinOp::Sub, &args[0], &args[1], dest)?;
}
+
"overflowing_mul" => {
self.intrinsic_overflowing(mir::BinOp::Mul, &args[0], &args[1], dest)?;
}
+
"overflowing_add" => {
self.intrinsic_overflowing(mir::BinOp::Add, &args[0], &args[1], dest)?;
}
"size_of" => {
- let ty = *substs.types.get(subst::FnSpace, 0);
+ let ty = substs.types[0];
let size = self.type_size(ty) as u64;
self.memory.write_uint(dest, size, pointer_size)?;
}
"size_of_val" => {
- let ty = *substs.types.get(subst::FnSpace, 0);
+ let ty = substs.types[0];
if self.type_is_sized(ty) {
let size = self.type_size(ty) as u64;
self.memory.write_uint(dest, size, pointer_size)?;
}
"transmute" => {
- let ty = *substs.types.get(subst::FnSpace, 0);
+ let ty = substs.types[0];
self.move_(args_ptrs[0], dest, ty)?;
}
"uninit" => self.memory.mark_definedness(dest, dest_layout.size(&self.tcx.data_layout).bytes() as usize, false)?,
fn fulfill_obligation(&self, trait_ref: ty::PolyTraitRef<'tcx>) -> traits::Vtable<'tcx, ()> {
// Do the initial selection for the obligation. This yields the shallow result we are
// looking for -- that is, what specific impl.
- self.tcx.normalizing_infer_ctxt(ProjectionMode::Any).enter(|infcx| {
+ self.tcx.normalizing_infer_ctxt(Reveal::All).enter(|infcx| {
let mut selcx = traits::SelectionContext::new(&infcx);
let obligation = traits::Obligation::new(
/// Trait method, which has to be resolved to an impl method.
fn trait_method(
&self,
+ trait_id: DefId,
def_id: DefId,
substs: &'tcx Substs<'tcx>
) -> (DefId, &'tcx Substs<'tcx>) {
- let method_item = self.tcx.impl_or_trait_item(def_id);
- let trait_id = method_item.container().id();
- let trait_ref = ty::Binder(substs.to_trait_ref(self.tcx, trait_id));
+ let trait_ref = ty::TraitRef::from_method(self.tcx, trait_id, substs);
+ let trait_ref = self.tcx.normalize_associated_type(&ty::Binder(trait_ref));
+
match self.fulfill_obligation(trait_ref) {
traits::VtableImpl(vtable_impl) => {
let impl_did = vtable_impl.impl_def_id;
let mname = self.tcx.item_name(def_id);
// Create a concatenated set of substitutions which includes those from the impl
// and those from the method:
- let impl_substs = vtable_impl.substs.with_method_from(substs);
- let substs = self.tcx.mk_substs(impl_substs);
- let mth = get_impl_method(self.tcx, impl_did, substs, mname);
+ let mth = get_impl_method(self.tcx, substs, impl_did, vtable_impl.substs, mname);
(mth.method.def_id, mth.substs)
}
/// Locates the applicable definition of a method, given its name.
fn get_impl_method<'a, 'tcx>(
tcx: TyCtxt<'a, 'tcx, 'tcx>,
- impl_def_id: DefId,
substs: &'tcx Substs<'tcx>,
+ impl_def_id: DefId,
+ impl_substs: &'tcx Substs<'tcx>,
name: ast::Name,
) -> ImplMethod<'tcx> {
assert!(!substs.types.needs_infer());
match trait_def.ancestors(impl_def_id).fn_defs(tcx, name).next() {
Some(node_item) => {
- let substs = tcx.normalizing_infer_ctxt(ProjectionMode::Any).enter(|infcx| {
+ let substs = tcx.normalizing_infer_ctxt(Reveal::All).enter(|infcx| {
+ let substs = substs.rebase_onto(tcx, trait_def_id, impl_substs);
let substs = traits::translate_substs(&infcx, impl_def_id,
substs, node_item.node);
tcx.lift(&substs).unwrap_or_else(|| {
-fn main() { //~ ERROR tried to call a function of type
+fn main() {
fn f() {}
- let g = unsafe {
+ let g = unsafe { //~ ERROR tried to call a function of type
std::mem::transmute::<fn(), fn(i32)>(f)
};
#![feature(box_syntax)]
-// FIXME: This span is wrong.
-fn main() { //~ ERROR: tried to treat a memory pointer as a function pointer
+fn main() {
let x = box 42;
unsafe {
let f = std::mem::transmute::<Box<i32>, fn()>(x);
+ //~^ ERROR: tried to treat a memory pointer as a function pointer
f()
}
}