-
Notifications
You must be signed in to change notification settings - Fork 349
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rustup to rustc 1.17.0-nightly (60a0edc6c 2017-02-26) #147
Changes from all commits
8878a40
8405770
41d59b1
4cb1f63
64d196a
da6f136
adb3fbb
80be25e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,10 @@ use std::collections::{btree_map, BTreeMap, HashMap, HashSet, VecDeque, BTreeSet | |
use std::{fmt, iter, ptr, mem, io}; | ||
|
||
use rustc::hir::def_id::DefId; | ||
use rustc::ty::{self, BareFnTy, ClosureTy, ClosureSubsts, TyCtxt}; | ||
use rustc::ty::{self, PolyFnSig, ClosureSubsts}; | ||
use rustc::ty::subst::Substs; | ||
use rustc::ty::layout::{self, TargetDataLayout}; | ||
|
||
use syntax::abi::Abi; | ||
|
||
use error::{EvalError, EvalResult}; | ||
use value::PrimVal; | ||
|
||
|
@@ -109,8 +107,7 @@ impl Pointer { | |
pub struct FunctionDefinition<'tcx> { | ||
pub def_id: DefId, | ||
pub substs: &'tcx Substs<'tcx>, | ||
pub abi: Abi, | ||
pub sig: &'tcx ty::FnSig<'tcx>, | ||
pub sig: PolyFnSig<'tcx>, | ||
} | ||
|
||
/// Either a concrete function, or a glue function | ||
|
@@ -127,18 +124,14 @@ pub enum Function<'tcx> { | |
DropGlue(ty::Ty<'tcx>), | ||
/// Glue required to treat the ptr part of a fat pointer | ||
/// as a function pointer | ||
FnPtrAsTraitObject(&'tcx ty::FnSig<'tcx>), | ||
FnPtrAsTraitObject(PolyFnSig<'tcx>), | ||
/// Glue for Closures | ||
Closure(FunctionDefinition<'tcx>), | ||
/// Glue for noncapturing closures casted to function pointers | ||
NonCaptureClosureAsFnPtr(FunctionDefinition<'tcx>), | ||
} | ||
|
||
impl<'tcx> Function<'tcx> { | ||
pub fn expect_concrete(self) -> EvalResult<'tcx, FunctionDefinition<'tcx>> { | ||
match self { | ||
Function::Concrete(fn_def) => Ok(fn_def), | ||
other => Err(EvalError::ExpectedConcreteFunction(other)), | ||
} | ||
} | ||
pub fn expect_drop_glue_real_ty(self) -> EvalResult<'tcx, ty::Ty<'tcx>> { | ||
match self { | ||
Function::DropGlue(real_ty) => Ok(real_ty), | ||
|
@@ -221,50 +214,43 @@ impl<'a, 'tcx> Memory<'a, 'tcx> { | |
self.alloc_map.iter() | ||
} | ||
|
||
pub fn create_closure_ptr(&mut self, tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, substs: ClosureSubsts<'tcx>, fn_ty: ClosureTy<'tcx>) -> Pointer { | ||
// FIXME: this is a hack | ||
let fn_ty = tcx.mk_bare_fn(ty::BareFnTy { | ||
unsafety: fn_ty.unsafety, | ||
abi: fn_ty.abi, | ||
sig: fn_ty.sig, | ||
}); | ||
pub fn create_closure_ptr(&mut self, def_id: DefId, substs: ClosureSubsts<'tcx>, sig: PolyFnSig<'tcx>) -> Pointer { | ||
self.create_fn_alloc(Function::Closure(FunctionDefinition { | ||
def_id, | ||
substs: substs.substs, | ||
abi: fn_ty.abi, | ||
// FIXME: why doesn't this compile? | ||
//sig: tcx.erase_late_bound_regions(&fn_ty.sig), | ||
sig: fn_ty.sig.skip_binder(), | ||
sig, | ||
})) | ||
} | ||
|
||
pub fn create_fn_ptr_from_noncapture_closure(&mut self, def_id: DefId, substs: ClosureSubsts<'tcx>, sig: PolyFnSig<'tcx>) -> Pointer { | ||
self.create_fn_alloc(Function::NonCaptureClosureAsFnPtr(FunctionDefinition { | ||
def_id, | ||
substs: substs.substs, | ||
sig, | ||
})) | ||
} | ||
|
||
pub fn create_fn_as_trait_glue(&mut self, _tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, substs: &'tcx Substs<'tcx>, fn_ty: &'tcx BareFnTy<'tcx>) -> Pointer { | ||
pub fn create_fn_as_trait_glue(&mut self, def_id: DefId, substs: &'tcx Substs, sig: PolyFnSig<'tcx>) -> Pointer { | ||
self.create_fn_alloc(Function::FnDefAsTraitObject(FunctionDefinition { | ||
def_id, | ||
substs, | ||
abi: fn_ty.abi, | ||
// FIXME: why doesn't this compile? | ||
//sig: tcx.erase_late_bound_regions(&fn_ty.sig), | ||
sig: fn_ty.sig.skip_binder(), | ||
sig, | ||
})) | ||
} | ||
|
||
pub fn create_fn_ptr_as_trait_glue(&mut self, fn_ty: &'tcx BareFnTy<'tcx>) -> Pointer { | ||
self.create_fn_alloc(Function::FnPtrAsTraitObject(fn_ty.sig.skip_binder())) | ||
pub fn create_fn_ptr_as_trait_glue(&mut self, sig: PolyFnSig<'tcx>) -> Pointer { | ||
self.create_fn_alloc(Function::FnPtrAsTraitObject(sig)) | ||
} | ||
|
||
pub fn create_drop_glue(&mut self, ty: ty::Ty<'tcx>) -> Pointer { | ||
self.create_fn_alloc(Function::DropGlue(ty)) | ||
} | ||
|
||
pub fn create_fn_ptr(&mut self, _tcx: TyCtxt<'a, 'tcx, 'tcx>, def_id: DefId, substs: &'tcx Substs<'tcx>, fn_ty: &'tcx BareFnTy<'tcx>) -> Pointer { | ||
pub fn create_fn_ptr(&mut self, def_id: DefId, substs: &'tcx Substs, sig: PolyFnSig<'tcx>) -> Pointer { | ||
self.create_fn_alloc(Function::Concrete(FunctionDefinition { | ||
def_id, | ||
substs, | ||
abi: fn_ty.abi, | ||
// FIXME: why doesn't this compile? | ||
//sig: tcx.erase_late_bound_regions(&fn_ty.sig), | ||
sig: fn_ty.sig.skip_binder(), | ||
sig, | ||
})) | ||
} | ||
|
||
|
@@ -535,6 +521,10 @@ impl<'a, 'tcx> Memory<'a, 'tcx> { | |
trace!("{} closure glue for {}", msg, dump_fn_def(fn_def)); | ||
continue; | ||
}, | ||
(None, Some(&Function::NonCaptureClosureAsFnPtr(fn_def))) => { | ||
trace!("{} non-capture closure as fn ptr glue for {}", msg, dump_fn_def(fn_def)); | ||
continue; | ||
}, | ||
(None, None) => { | ||
trace!("{} (deallocated)", msg); | ||
continue; | ||
|
@@ -606,12 +596,7 @@ impl<'a, 'tcx> Memory<'a, 'tcx> { | |
|
||
fn dump_fn_def<'tcx>(fn_def: FunctionDefinition<'tcx>) -> String { | ||
let name = ty::tls::with(|tcx| tcx.item_path_str(fn_def.def_id)); | ||
let abi = if fn_def.abi == Abi::Rust { | ||
format!("") | ||
} else { | ||
format!("extern {} ", fn_def.abi) | ||
}; | ||
format!("function pointer: {}: {}{}", name, abi, fn_def.sig) | ||
format!("function pointer: {}: {}", name, fn_def.sig.skip_binder()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think skipping the binder is needed here at all! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes it is :) There's no Display impl for Binder There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Oh, right, it's |
||
} | ||
|
||
/// Byte accessors | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tempted to make this the way to refer to a
TyFnDef
(now that it hasSubsts
), what do you think?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's unreachable ^^ At least in the run-pass tests that we run. We only use this function in
mir::Literal::Value
, and I think that can only contain primitivesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I know, it's because we use
Item
right now, and work around the awkwardness of it everywhere.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh... you mean changing it that
Literal::Item
stops referring to functions. Sounds good.