1
Fork 0

Remove "unboxed" attribute in code referring to new closures.

This commit is contained in:
Eduard Burtescu 2015-01-24 22:00:03 +02:00
parent 458a6a2f6e
commit 11ef6f1349
54 changed files with 513 additions and 565 deletions

View file

@ -1732,7 +1732,7 @@ impl LintPass for Stability {
ty::MethodStatic(def_id) => { ty::MethodStatic(def_id) => {
def_id def_id
} }
ty::MethodStaticUnboxedClosure(def_id) => { ty::MethodStaticClosure(def_id) => {
def_id def_id
} }
ty::MethodTypeParam(ty::MethodParam { ty::MethodTypeParam(ty::MethodParam {
@ -1940,7 +1940,7 @@ impl LintPass for UnconditionalRecursion {
ty::MethodTraitObject(_) => return false, ty::MethodTraitObject(_) => return false,
// This `did` refers directly to the method definition. // This `did` refers directly to the method definition.
ty::MethodStatic(did) | ty::MethodStaticUnboxedClosure(did) => did, ty::MethodStatic(did) | ty::MethodStaticClosure(did) => did,
// MethodTypeParam are methods from traits: // MethodTypeParam are methods from traits:

View file

@ -139,7 +139,7 @@ pub enum astencode_tag { // Reserves 0x40 -- 0x5f
tag_table_adjustments = 0x51, tag_table_adjustments = 0x51,
tag_table_moves_map = 0x52, tag_table_moves_map = 0x52,
tag_table_capture_map = 0x53, tag_table_capture_map = 0x53,
tag_table_unboxed_closures = 0x54, tag_table_closures = 0x54,
tag_table_upvar_borrow_map = 0x55, tag_table_upvar_borrow_map = 0x55,
tag_table_capture_modes = 0x56, tag_table_capture_modes = 0x56,
tag_table_object_cast_map = 0x57, tag_table_object_cast_map = 0x57,
@ -225,10 +225,10 @@ pub struct LinkMeta {
pub crate_hash: Svh, pub crate_hash: Svh,
} }
pub const tag_unboxed_closures: uint = 0x95; pub const tag_closures: uint = 0x95;
pub const tag_unboxed_closure: uint = 0x96; pub const tag_closure: uint = 0x96;
pub const tag_unboxed_closure_type: uint = 0x97; pub const tag_closure_type: uint = 0x97;
pub const tag_unboxed_closure_kind: uint = 0x98; pub const tag_closure_kind: uint = 0x98;
pub const tag_struct_fields: uint = 0x99; pub const tag_struct_fields: uint = 0x99;
pub const tag_struct_field: uint = 0x9a; pub const tag_struct_field: uint = 0x9a;

View file

@ -618,13 +618,12 @@ fn encode_visibility(rbml_w: &mut Encoder, visibility: ast::Visibility) {
rbml_w.end_tag(); rbml_w.end_tag();
} }
fn encode_unboxed_closure_kind(rbml_w: &mut Encoder, fn encode_closure_kind(rbml_w: &mut Encoder, kind: ty::ClosureKind) {
kind: ty::UnboxedClosureKind) { rbml_w.start_tag(tag_closure_kind);
rbml_w.start_tag(tag_unboxed_closure_kind);
let ch = match kind { let ch = match kind {
ty::FnUnboxedClosureKind => 'f', ty::FnClosureKind => 'f',
ty::FnMutUnboxedClosureKind => 'm', ty::FnMutClosureKind => 'm',
ty::FnOnceUnboxedClosureKind => 'o', ty::FnOnceClosureKind => 'o',
}; };
rbml_w.wr_str(&ch.to_string()[]); rbml_w.wr_str(&ch.to_string()[]);
rbml_w.end_tag(); rbml_w.end_tag();
@ -1838,24 +1837,19 @@ fn encode_macro_defs(rbml_w: &mut Encoder,
rbml_w.end_tag(); rbml_w.end_tag();
} }
fn encode_unboxed_closures<'a>( fn encode_closures<'a>(ecx: &'a EncodeContext, rbml_w: &'a mut Encoder) {
ecx: &'a EncodeContext, rbml_w.start_tag(tag_closures);
rbml_w: &'a mut Encoder) { for (closure_id, closure) in ecx.tcx.closures.borrow().iter() {
rbml_w.start_tag(tag_unboxed_closures); if closure_id.krate != ast::LOCAL_CRATE {
for (unboxed_closure_id, unboxed_closure) in ecx.tcx
.unboxed_closures
.borrow()
.iter() {
if unboxed_closure_id.krate != ast::LOCAL_CRATE {
continue continue
} }
rbml_w.start_tag(tag_unboxed_closure); rbml_w.start_tag(tag_closure);
encode_def_id(rbml_w, *unboxed_closure_id); encode_def_id(rbml_w, *closure_id);
rbml_w.start_tag(tag_unboxed_closure_type); rbml_w.start_tag(tag_closure_type);
write_closure_type(ecx, rbml_w, &unboxed_closure.closure_type); write_closure_type(ecx, rbml_w, &closure.closure_type);
rbml_w.end_tag(); rbml_w.end_tag();
encode_unboxed_closure_kind(rbml_w, unboxed_closure.kind); encode_closure_kind(rbml_w, closure.kind);
rbml_w.end_tag(); rbml_w.end_tag();
} }
rbml_w.end_tag(); rbml_w.end_tag();
@ -2069,7 +2063,7 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter,
native_lib_bytes: u64, native_lib_bytes: u64,
plugin_registrar_fn_bytes: u64, plugin_registrar_fn_bytes: u64,
macro_defs_bytes: u64, macro_defs_bytes: u64,
unboxed_closure_bytes: u64, closure_bytes: u64,
impl_bytes: u64, impl_bytes: u64,
misc_bytes: u64, misc_bytes: u64,
item_bytes: u64, item_bytes: u64,
@ -2084,7 +2078,7 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter,
native_lib_bytes: 0, native_lib_bytes: 0,
plugin_registrar_fn_bytes: 0, plugin_registrar_fn_bytes: 0,
macro_defs_bytes: 0, macro_defs_bytes: 0,
unboxed_closure_bytes: 0, closure_bytes: 0,
impl_bytes: 0, impl_bytes: 0,
misc_bytes: 0, misc_bytes: 0,
item_bytes: 0, item_bytes: 0,
@ -2156,8 +2150,8 @@ fn encode_metadata_inner(wr: &mut SeekableMemWriter,
// Encode the types of all unboxed closures in this crate. // Encode the types of all unboxed closures in this crate.
i = rbml_w.writer.tell().unwrap(); i = rbml_w.writer.tell().unwrap();
encode_unboxed_closures(&ecx, &mut rbml_w); encode_closures(&ecx, &mut rbml_w);
stats.unboxed_closure_bytes = rbml_w.writer.tell().unwrap() - i; stats.closure_bytes = rbml_w.writer.tell().unwrap() - i;
// Encode the def IDs of impls, for coherence checking. // Encode the def IDs of impls, for coherence checking.
i = rbml_w.writer.tell().unwrap(); i = rbml_w.writer.tell().unwrap();

View file

@ -58,7 +58,7 @@ pub enum DefIdSource {
RegionParameter, RegionParameter,
// Identifies an unboxed closure // Identifies an unboxed closure
UnboxedClosureSource ClosureSource
} }
// type conv_did = impl FnMut(DefIdSource, ast::DefId) -> ast::DefId; // type conv_did = impl FnMut(DefIdSource, ast::DefId) -> ast::DefId;
@ -537,11 +537,11 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
} }
'k' => { 'k' => {
assert_eq!(next(st), '['); assert_eq!(next(st), '[');
let did = parse_def_(st, UnboxedClosureSource, conv); let did = parse_def_(st, ClosureSource, conv);
let region = parse_region_(st, conv); let region = parse_region_(st, conv);
let substs = parse_substs_(st, conv); let substs = parse_substs_(st, conv);
assert_eq!(next(st), ']'); assert_eq!(next(st), ']');
return ty::mk_unboxed_closure(st.tcx, did, return ty::mk_closure(st.tcx, did,
st.tcx.mk_region(region), st.tcx.mk_substs(substs)); st.tcx.mk_region(region), st.tcx.mk_substs(substs));
} }
'P' => { 'P' => {

View file

@ -139,7 +139,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
enc_substs(w, cx, substs); enc_substs(w, cx, substs);
mywrite!(w, "]"); mywrite!(w, "]");
} }
ty::ty_unboxed_closure(def, region, substs) => { ty::ty_closure(def, region, substs) => {
mywrite!(w, "k[{}|", (cx.ds)(def)); mywrite!(w, "k[{}|", (cx.ds)(def));
enc_region(w, cx, *region); enc_region(w, cx, *region);
enc_substs(w, cx, substs); enc_substs(w, cx, substs);

View file

@ -21,7 +21,7 @@ use metadata::encoder as e;
use middle::region; use middle::region;
use metadata::tydecode; use metadata::tydecode;
use metadata::tydecode::{DefIdSource, NominalType, TypeWithId, TypeParameter}; use metadata::tydecode::{DefIdSource, NominalType, TypeWithId, TypeParameter};
use metadata::tydecode::{RegionParameter, UnboxedClosureSource}; use metadata::tydecode::{RegionParameter, ClosureSource};
use metadata::tyencode; use metadata::tyencode;
use middle::mem_categorization::Typer; use middle::mem_categorization::Typer;
use middle::subst; use middle::subst;
@ -618,8 +618,8 @@ impl<'tcx> tr for MethodOrigin<'tcx> {
fn tr(&self, dcx: &DecodeContext) -> MethodOrigin<'tcx> { fn tr(&self, dcx: &DecodeContext) -> MethodOrigin<'tcx> {
match *self { match *self {
ty::MethodStatic(did) => ty::MethodStatic(did.tr(dcx)), ty::MethodStatic(did) => ty::MethodStatic(did.tr(dcx)),
ty::MethodStaticUnboxedClosure(did) => { ty::MethodStaticClosure(did) => {
ty::MethodStaticUnboxedClosure(did.tr(dcx)) ty::MethodStaticClosure(did.tr(dcx))
} }
ty::MethodTypeParam(ref mp) => { ty::MethodTypeParam(ref mp) => {
ty::MethodTypeParam( ty::MethodTypeParam(
@ -643,24 +643,23 @@ impl<'tcx> tr for MethodOrigin<'tcx> {
} }
} }
pub fn encode_unboxed_closure_kind(ebml_w: &mut Encoder, pub fn encode_closure_kind(ebml_w: &mut Encoder, kind: ty::ClosureKind) {
kind: ty::UnboxedClosureKind) {
use serialize::Encoder; use serialize::Encoder;
ebml_w.emit_enum("UnboxedClosureKind", |ebml_w| { ebml_w.emit_enum("ClosureKind", |ebml_w| {
match kind { match kind {
ty::FnUnboxedClosureKind => { ty::FnClosureKind => {
ebml_w.emit_enum_variant("FnUnboxedClosureKind", 0, 3, |_| { ebml_w.emit_enum_variant("FnClosureKind", 0, 3, |_| {
Ok(()) Ok(())
}) })
} }
ty::FnMutUnboxedClosureKind => { ty::FnMutClosureKind => {
ebml_w.emit_enum_variant("FnMutUnboxedClosureKind", 1, 3, |_| { ebml_w.emit_enum_variant("FnMutClosureKind", 1, 3, |_| {
Ok(()) Ok(())
}) })
} }
ty::FnOnceUnboxedClosureKind => { ty::FnOnceClosureKind => {
ebml_w.emit_enum_variant("FnOnceUnboxedClosureKind", ebml_w.emit_enum_variant("FnOnceClosureKind",
2, 2,
3, 3,
|_| { |_| {
@ -736,7 +735,7 @@ impl<'tcx, 'a> vtable_decoder_helpers<'tcx> for reader::Decoder<'a> {
this.read_enum_variant(&["vtable_static", this.read_enum_variant(&["vtable_static",
"vtable_param", "vtable_param",
"vtable_error", "vtable_error",
"vtable_unboxed_closure"], "vtable_closure"],
|this, i| { |this, i| {
Ok(match i { Ok(match i {
0 => { 0 => {
@ -763,7 +762,7 @@ impl<'tcx, 'a> vtable_decoder_helpers<'tcx> for reader::Decoder<'a> {
) )
} }
2 => { 2 => {
ty::vtable_unboxed_closure( ty::vtable_closure(
this.read_enum_variant_arg(0u, |this| { this.read_enum_variant_arg(0u, |this| {
Ok(this.read_def_id_nodcx(cdata)) Ok(this.read_def_id_nodcx(cdata))
}).unwrap() }).unwrap()
@ -865,8 +864,8 @@ impl<'a, 'tcx> rbml_writer_helpers<'tcx> for Encoder<'a> {
}) })
} }
ty::MethodStaticUnboxedClosure(def_id) => { ty::MethodStaticClosure(def_id) => {
this.emit_enum_variant("MethodStaticUnboxedClosure", 1, 1, |this| { this.emit_enum_variant("MethodStaticClosure", 1, 1, |this| {
Ok(this.emit_def_id(def_id)) Ok(this.emit_def_id(def_id))
}) })
} }
@ -1322,15 +1321,12 @@ fn encode_side_tables_for_id(ecx: &e::EncodeContext,
}) })
} }
for unboxed_closure in tcx.unboxed_closures for closure in tcx.closures.borrow().get(&ast_util::local_def(id)).iter() {
.borrow() rbml_w.tag(c::tag_table_closures, |rbml_w| {
.get(&ast_util::local_def(id))
.iter() {
rbml_w.tag(c::tag_table_unboxed_closures, |rbml_w| {
rbml_w.id(id); rbml_w.id(id);
rbml_w.tag(c::tag_table_val, |rbml_w| { rbml_w.tag(c::tag_table_val, |rbml_w| {
rbml_w.emit_closure_type(ecx, &unboxed_closure.closure_type); rbml_w.emit_closure_type(ecx, &closure.closure_type);
encode_unboxed_closure_kind(rbml_w, unboxed_closure.kind) encode_closure_kind(rbml_w, closure.kind)
}) })
}) })
} }
@ -1369,8 +1365,8 @@ trait rbml_decoder_decoder_helpers<'tcx> {
-> subst::Substs<'tcx>; -> subst::Substs<'tcx>;
fn read_auto_adjustment<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) fn read_auto_adjustment<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
-> ty::AutoAdjustment<'tcx>; -> ty::AutoAdjustment<'tcx>;
fn read_unboxed_closure<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) fn read_closure<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
-> ty::UnboxedClosure<'tcx>; -> ty::Closure<'tcx>;
fn read_auto_deref_ref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) fn read_auto_deref_ref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
-> ty::AutoDerefRef<'tcx>; -> ty::AutoDerefRef<'tcx>;
fn read_autoref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>) fn read_autoref<'a, 'b>(&mut self, dcx: &DecodeContext<'a, 'b, 'tcx>)
@ -1436,7 +1432,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
-> ty::MethodOrigin<'tcx> -> ty::MethodOrigin<'tcx>
{ {
self.read_enum("MethodOrigin", |this| { self.read_enum("MethodOrigin", |this| {
let variants = &["MethodStatic", "MethodStaticUnboxedClosure", let variants = &["MethodStatic", "MethodStaticClosure",
"MethodTypeParam", "MethodTraitObject"]; "MethodTypeParam", "MethodTraitObject"];
this.read_enum_variant(variants, |this, i| { this.read_enum_variant(variants, |this, i| {
Ok(match i { Ok(match i {
@ -1447,7 +1443,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
1 => { 1 => {
let def_id = this.read_def_id(dcx); let def_id = this.read_def_id(dcx);
ty::MethodStaticUnboxedClosure(def_id) ty::MethodStaticClosure(def_id)
} }
2 => { 2 => {
@ -1797,8 +1793,8 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
}).unwrap() }).unwrap()
} }
fn read_unboxed_closure<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>) fn read_closure<'b, 'c>(&mut self, dcx: &DecodeContext<'b, 'c, 'tcx>)
-> ty::UnboxedClosure<'tcx> { -> ty::Closure<'tcx> {
let closure_type = self.read_opaque(|this, doc| { let closure_type = self.read_opaque(|this, doc| {
Ok(tydecode::parse_ty_closure_data( Ok(tydecode::parse_ty_closure_data(
doc.data, doc.data,
@ -1808,21 +1804,21 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
|s, a| this.convert_def_id(dcx, s, a))) |s, a| this.convert_def_id(dcx, s, a)))
}).unwrap(); }).unwrap();
let variants = &[ let variants = &[
"FnUnboxedClosureKind", "FnClosureKind",
"FnMutUnboxedClosureKind", "FnMutClosureKind",
"FnOnceUnboxedClosureKind" "FnOnceClosureKind"
]; ];
let kind = self.read_enum("UnboxedClosureKind", |this| { let kind = self.read_enum("ClosureKind", |this| {
this.read_enum_variant(variants, |_, i| { this.read_enum_variant(variants, |_, i| {
Ok(match i { Ok(match i {
0 => ty::FnUnboxedClosureKind, 0 => ty::FnClosureKind,
1 => ty::FnMutUnboxedClosureKind, 1 => ty::FnMutClosureKind,
2 => ty::FnOnceUnboxedClosureKind, 2 => ty::FnOnceClosureKind,
_ => panic!("bad enum variant for ty::UnboxedClosureKind"), _ => panic!("bad enum variant for ty::ClosureKind"),
}) })
}) })
}).unwrap(); }).unwrap();
ty::UnboxedClosure { ty::Closure {
closure_type: closure_type, closure_type: closure_type,
kind: kind, kind: kind,
} }
@ -1864,7 +1860,7 @@ impl<'a, 'tcx> rbml_decoder_decoder_helpers<'tcx> for reader::Decoder<'a> {
-> ast::DefId { -> ast::DefId {
let r = match source { let r = match source {
NominalType | TypeWithId | RegionParameter => dcx.tr_def_id(did), NominalType | TypeWithId | RegionParameter => dcx.tr_def_id(did),
TypeParameter | UnboxedClosureSource => dcx.tr_intern_def_id(did) TypeParameter | ClosureSource => dcx.tr_intern_def_id(did)
}; };
debug!("convert_def_id(source={:?}, did={:?})={:?}", source, did, r); debug!("convert_def_id(source={:?}, did={:?})={:?}", source, did, r);
return r; return r;
@ -1959,14 +1955,11 @@ fn decode_side_tables(dcx: &DecodeContext,
let adj: ty::AutoAdjustment = val_dsr.read_auto_adjustment(dcx); let adj: ty::AutoAdjustment = val_dsr.read_auto_adjustment(dcx);
dcx.tcx.adjustments.borrow_mut().insert(id, adj); dcx.tcx.adjustments.borrow_mut().insert(id, adj);
} }
c::tag_table_unboxed_closures => { c::tag_table_closures => {
let unboxed_closure = let closure =
val_dsr.read_unboxed_closure(dcx); val_dsr.read_closure(dcx);
dcx.tcx dcx.tcx.closures.borrow_mut().insert(ast_util::local_def(id),
.unboxed_closures closure);
.borrow_mut()
.insert(ast_util::local_def(id),
unboxed_closure);
} }
_ => { _ => {
dcx.tcx.sess.bug( dcx.tcx.sess.bug(

View file

@ -100,7 +100,7 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> {
None => self.check_def_id(def_id) None => self.check_def_id(def_id)
} }
} }
ty::MethodStaticUnboxedClosure(_) => {} ty::MethodStaticClosure(_) => {}
ty::MethodTypeParam(ty::MethodParam { ty::MethodTypeParam(ty::MethodParam {
ref trait_ref, ref trait_ref,
method_num: index, method_num: index,

View file

@ -26,7 +26,7 @@ use middle::mem_categorization::Typer;
use middle::ty::{self}; use middle::ty::{self};
use middle::ty::{MethodCall, MethodObject, MethodTraitObject}; use middle::ty::{MethodCall, MethodObject, MethodTraitObject};
use middle::ty::{MethodOrigin, MethodParam, MethodTypeParam}; use middle::ty::{MethodOrigin, MethodParam, MethodTypeParam};
use middle::ty::{MethodStatic, MethodStaticUnboxedClosure}; use middle::ty::{MethodStatic, MethodStaticClosure};
use util::ppaux::Repr; use util::ppaux::Repr;
use std::marker; use std::marker;
@ -257,13 +257,13 @@ impl OverloadedCallType {
OverloadedCallType::from_trait_id(tcx, trait_ref.def_id) OverloadedCallType::from_trait_id(tcx, trait_ref.def_id)
} }
fn from_unboxed_closure(tcx: &ty::ctxt, closure_did: ast::DefId) fn from_closure(tcx: &ty::ctxt, closure_did: ast::DefId)
-> OverloadedCallType { -> OverloadedCallType {
let trait_did = let trait_did =
tcx.unboxed_closures tcx.closures
.borrow() .borrow()
.get(&closure_did) .get(&closure_did)
.expect("OverloadedCallType::from_unboxed_closure: didn't \ .expect("OverloadedCallType::from_closure: didn't \
find closure id") find closure id")
.kind .kind
.trait_did(tcx); .trait_did(tcx);
@ -276,8 +276,8 @@ impl OverloadedCallType {
MethodStatic(def_id) => { MethodStatic(def_id) => {
OverloadedCallType::from_method_id(tcx, def_id) OverloadedCallType::from_method_id(tcx, def_id)
} }
MethodStaticUnboxedClosure(def_id) => { MethodStaticClosure(def_id) => {
OverloadedCallType::from_unboxed_closure(tcx, def_id) OverloadedCallType::from_closure(tcx, def_id)
} }
MethodTypeParam(MethodParam { ref trait_ref, .. }) | MethodTypeParam(MethodParam { ref trait_ref, .. }) |
MethodTraitObject(MethodObject { ref trait_ref, .. }) => { MethodTraitObject(MethodObject { ref trait_ref, .. }) => {

View file

@ -28,7 +28,7 @@ pub enum SimplifiedType {
TupleSimplifiedType(uint), TupleSimplifiedType(uint),
TraitSimplifiedType(ast::DefId), TraitSimplifiedType(ast::DefId),
StructSimplifiedType(ast::DefId), StructSimplifiedType(ast::DefId),
UnboxedClosureSimplifiedType(ast::DefId), ClosureSimplifiedType(ast::DefId),
FunctionSimplifiedType(uint), FunctionSimplifiedType(uint),
ParameterSimplifiedType, ParameterSimplifiedType,
} }
@ -74,8 +74,8 @@ pub fn simplify_type(tcx: &ty::ctxt,
let def_id = tcx.lang_items.owned_box().unwrap(); let def_id = tcx.lang_items.owned_box().unwrap();
Some(StructSimplifiedType(def_id)) Some(StructSimplifiedType(def_id))
} }
ty::ty_unboxed_closure(def_id, _, _) => { ty::ty_closure(def_id, _, _) => {
Some(UnboxedClosureSimplifiedType(def_id)) Some(ClosureSimplifiedType(def_id))
} }
ty::ty_tup(ref tys) => { ty::ty_tup(ref tys) => {
Some(TupleSimplifiedType(tys.len())) Some(TupleSimplifiedType(tys.len()))

View file

@ -514,15 +514,15 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
Ok(ty::mk_struct(tcx, a_id, tcx.mk_substs(substs))) Ok(ty::mk_struct(tcx, a_id, tcx.mk_substs(substs)))
} }
(&ty::ty_unboxed_closure(a_id, a_region, a_substs), (&ty::ty_closure(a_id, a_region, a_substs),
&ty::ty_unboxed_closure(b_id, b_region, b_substs)) &ty::ty_closure(b_id, b_region, b_substs))
if a_id == b_id => { if a_id == b_id => {
// All ty_unboxed_closure types with the same id represent // All ty_closure types with the same id represent
// the (anonymous) type of the same closure expression. So // the (anonymous) type of the same closure expression. So
// all of their regions should be equated. // all of their regions should be equated.
let region = try!(this.equate().regions(*a_region, *b_region)); let region = try!(this.equate().regions(*a_region, *b_region));
let substs = try!(this.substs_variances(None, a_substs, b_substs)); let substs = try!(this.substs_variances(None, a_substs, b_substs));
Ok(ty::mk_unboxed_closure(tcx, a_id, tcx.mk_region(region), tcx.mk_substs(substs))) Ok(ty::mk_closure(tcx, a_id, tcx.mk_region(region), tcx.mk_substs(substs)))
} }
(&ty::ty_uniq(a_inner), &ty::ty_uniq(b_inner)) => { (&ty::ty_uniq(a_inner), &ty::ty_uniq(b_inner)) => {

View file

@ -151,7 +151,7 @@ impl<'a, 'tcx> TypeFolder<'tcx> for TypeFreshener<'a, 'tcx> {
ty::ty_bare_fn(..) | ty::ty_bare_fn(..) |
ty::ty_trait(..) | ty::ty_trait(..) |
ty::ty_struct(..) | ty::ty_struct(..) |
ty::ty_unboxed_closure(..) | ty::ty_closure(..) |
ty::ty_tup(..) | ty::ty_tup(..) |
ty::ty_projection(..) | ty::ty_projection(..) |
ty::ty_param(..) => { ty::ty_param(..) => {

View file

@ -113,11 +113,11 @@ impl LanguageItems {
} }
} }
pub fn fn_trait_kind(&self, id: ast::DefId) -> Option<ty::UnboxedClosureKind> { pub fn fn_trait_kind(&self, id: ast::DefId) -> Option<ty::ClosureKind> {
let def_id_kinds = [ let def_id_kinds = [
(self.fn_trait(), ty::FnUnboxedClosureKind), (self.fn_trait(), ty::FnClosureKind),
(self.fn_mut_trait(), ty::FnMutUnboxedClosureKind), (self.fn_mut_trait(), ty::FnMutClosureKind),
(self.fn_once_trait(), ty::FnOnceUnboxedClosureKind), (self.fn_once_trait(), ty::FnOnceClosureKind),
]; ];
for &(opt_def_id, kind) in def_id_kinds.iter() { for &(opt_def_id, kind) in def_id_kinds.iter() {

View file

@ -114,7 +114,7 @@ use middle::mem_categorization::Typer;
use middle::pat_util; use middle::pat_util;
use middle::region::CodeExtent; use middle::region::CodeExtent;
use middle::ty; use middle::ty;
use middle::ty::UnboxedClosureTyper; use middle::ty::ClosureTyper;
use lint; use lint;
use util::nodemap::NodeMap; use util::nodemap::NodeMap;
@ -1519,8 +1519,8 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> {
fn fn_ret(&self, id: NodeId) -> ty::PolyFnOutput<'tcx> { fn fn_ret(&self, id: NodeId) -> ty::PolyFnOutput<'tcx> {
let fn_ty = ty::node_id_to_type(self.ir.tcx, id); let fn_ty = ty::node_id_to_type(self.ir.tcx, id);
match fn_ty.sty { match fn_ty.sty {
ty::ty_unboxed_closure(closure_def_id, _, substs) => ty::ty_closure(closure_def_id, _, substs) =>
self.ir.tcx.unboxed_closure_type(closure_def_id, substs).sig.output(), self.ir.tcx.closure_type(closure_def_id, substs).sig.output(),
_ => _ =>
ty::ty_fn_ret(fn_ty), ty::ty_fn_ret(fn_ty),
} }

View file

@ -105,7 +105,7 @@ pub enum categorization<'tcx> {
pub struct Upvar { pub struct Upvar {
pub id: ty::UpvarId, pub id: ty::UpvarId,
// Unboxed closure kinds are used even for old-style closures for simplicity // Unboxed closure kinds are used even for old-style closures for simplicity
pub kind: ty::UnboxedClosureKind, pub kind: ty::ClosureKind,
// Is this from an unboxed closure? Used only for diagnostics. // Is this from an unboxed closure? Used only for diagnostics.
pub is_unboxed: bool pub is_unboxed: bool
} }
@ -269,7 +269,7 @@ pub type McResult<T> = Result<T, ()>;
/// In the borrow checker, in contrast, type checking is complete and we /// In the borrow checker, in contrast, type checking is complete and we
/// know that no errors have occurred, so we simply consult the tcx and we /// know that no errors have occurred, so we simply consult the tcx and we
/// can be sure that only `Ok` results will occur. /// can be sure that only `Ok` results will occur.
pub trait Typer<'tcx> : ty::UnboxedClosureTyper<'tcx> { pub trait Typer<'tcx> : ty::ClosureTyper<'tcx> {
fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>; fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx>;
fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>>; fn node_ty(&self, id: ast::NodeId) -> McResult<Ty<'tcx>>;
fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult<Ty<'tcx>>; fn expr_ty_adjusted(&self, expr: &ast::Expr) -> McResult<Ty<'tcx>>;
@ -596,8 +596,8 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
def::DefUpvar(var_id, fn_node_id, _) => { def::DefUpvar(var_id, fn_node_id, _) => {
let ty = try!(self.node_ty(fn_node_id)); let ty = try!(self.node_ty(fn_node_id));
match ty.sty { match ty.sty {
ty::ty_unboxed_closure(closure_id, _, _) => { ty::ty_closure(closure_id, _, _) => {
let kind = self.typer.unboxed_closure_kind(closure_id); let kind = self.typer.closure_kind(closure_id);
let mode = self.typer.capture_mode(fn_node_id); let mode = self.typer.capture_mode(fn_node_id);
self.cat_upvar(id, span, var_id, fn_node_id, kind, mode, true) self.cat_upvar(id, span, var_id, fn_node_id, kind, mode, true)
} }
@ -631,7 +631,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
span: Span, span: Span,
var_id: ast::NodeId, var_id: ast::NodeId,
fn_node_id: ast::NodeId, fn_node_id: ast::NodeId,
kind: ty::UnboxedClosureKind, kind: ty::ClosureKind,
mode: ast::CaptureClause, mode: ast::CaptureClause,
is_unboxed: bool) is_unboxed: bool)
-> McResult<cmt<'tcx>> { -> McResult<cmt<'tcx>> {
@ -666,12 +666,12 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> {
// Construct information about env pointer dereference, if any // Construct information about env pointer dereference, if any
let mutbl = match kind { let mutbl = match kind {
ty::FnOnceUnboxedClosureKind => None, // None, env is by-value ty::FnOnceClosureKind => None, // None, env is by-value
ty::FnMutUnboxedClosureKind => match mode { // Depends on capture type ty::FnMutClosureKind => match mode { // Depends on capture type
ast::CaptureByValue => Some(var_mutbl), // Mutable if the original var is ast::CaptureByValue => Some(var_mutbl), // Mutable if the original var is
ast::CaptureByRef => Some(McDeclared) // Mutable regardless ast::CaptureByRef => Some(McDeclared) // Mutable regardless
}, },
ty::FnUnboxedClosureKind => Some(McImmutable) // Never mutable ty::FnClosureKind => Some(McImmutable) // Never mutable
}; };
let env_info = mutbl.map(|env_mutbl| { let env_info = mutbl.map(|env_mutbl| {
// Look up the node ID of the closure body so we can construct // Look up the node ID of the closure body so we can construct
@ -1566,7 +1566,7 @@ fn element_kind(t: Ty) -> ElementKind {
} }
} }
impl<'tcx> Repr<'tcx> for ty::UnboxedClosureKind { impl<'tcx> Repr<'tcx> for ty::ClosureKind {
fn repr(&self, _: &ty::ctxt) -> String { fn repr(&self, _: &ty::ctxt) -> String {
format!("Upvar({:?})", self) format!("Upvar({:?})", self)
} }
@ -1581,9 +1581,9 @@ impl<'tcx> Repr<'tcx> for Upvar {
impl<'tcx> UserString<'tcx> for Upvar { impl<'tcx> UserString<'tcx> for Upvar {
fn user_string(&self, _: &ty::ctxt) -> String { fn user_string(&self, _: &ty::ctxt) -> String {
let kind = match self.kind { let kind = match self.kind {
ty::FnUnboxedClosureKind => "Fn", ty::FnClosureKind => "Fn",
ty::FnMutUnboxedClosureKind => "FnMut", ty::FnMutClosureKind => "FnMut",
ty::FnOnceUnboxedClosureKind => "FnOnce", ty::FnOnceClosureKind => "FnOnce",
}; };
format!("captured outer variable in an `{}` closure", kind) format!("captured outer variable in an `{}` closure", kind)
} }

View file

@ -138,7 +138,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
tt.principal_def_id().krate == ast::LOCAL_CRATE tt.principal_def_id().krate == ast::LOCAL_CRATE
} }
ty::ty_unboxed_closure(..) | ty::ty_closure(..) |
ty::ty_infer(..) | ty::ty_infer(..) |
ty::ty_open(..) | ty::ty_open(..) |
ty::ty_err => { ty::ty_err => {

View file

@ -110,7 +110,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
/// `projection_ty` again. /// `projection_ty` again.
pub fn normalize_projection_type<'a>(&mut self, pub fn normalize_projection_type<'a>(&mut self,
infcx: &InferCtxt<'a,'tcx>, infcx: &InferCtxt<'a,'tcx>,
typer: &ty::UnboxedClosureTyper<'tcx>, typer: &ty::ClosureTyper<'tcx>,
projection_ty: ty::ProjectionTy<'tcx>, projection_ty: ty::ProjectionTy<'tcx>,
cause: ObligationCause<'tcx>) cause: ObligationCause<'tcx>)
-> Ty<'tcx> -> Ty<'tcx>
@ -186,7 +186,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
pub fn select_all_or_error<'a>(&mut self, pub fn select_all_or_error<'a>(&mut self,
infcx: &InferCtxt<'a,'tcx>, infcx: &InferCtxt<'a,'tcx>,
typer: &ty::UnboxedClosureTyper<'tcx>) typer: &ty::ClosureTyper<'tcx>)
-> Result<(),Vec<FulfillmentError<'tcx>>> -> Result<(),Vec<FulfillmentError<'tcx>>>
{ {
try!(self.select_where_possible(infcx, typer)); try!(self.select_where_possible(infcx, typer));
@ -211,7 +211,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
/// results in `O(n^2)` performance (#18208). /// results in `O(n^2)` performance (#18208).
pub fn select_new_obligations<'a>(&mut self, pub fn select_new_obligations<'a>(&mut self,
infcx: &InferCtxt<'a,'tcx>, infcx: &InferCtxt<'a,'tcx>,
typer: &ty::UnboxedClosureTyper<'tcx>) typer: &ty::ClosureTyper<'tcx>)
-> Result<(),Vec<FulfillmentError<'tcx>>> -> Result<(),Vec<FulfillmentError<'tcx>>>
{ {
let mut selcx = SelectionContext::new(infcx, typer); let mut selcx = SelectionContext::new(infcx, typer);
@ -220,7 +220,7 @@ impl<'tcx> FulfillmentContext<'tcx> {
pub fn select_where_possible<'a>(&mut self, pub fn select_where_possible<'a>(&mut self,
infcx: &InferCtxt<'a,'tcx>, infcx: &InferCtxt<'a,'tcx>,
typer: &ty::UnboxedClosureTyper<'tcx>) typer: &ty::ClosureTyper<'tcx>)
-> Result<(),Vec<FulfillmentError<'tcx>>> -> Result<(),Vec<FulfillmentError<'tcx>>>
{ {
let mut selcx = SelectionContext::new(infcx, typer); let mut selcx = SelectionContext::new(infcx, typer);

View file

@ -236,7 +236,7 @@ pub enum Vtable<'tcx, N> {
/// ID is the ID of the closure expression. This is a `VtableImpl` /// ID is the ID of the closure expression. This is a `VtableImpl`
/// in spirit, but the impl is generated by the compiler and does /// in spirit, but the impl is generated by the compiler and does
/// not appear in the source. /// not appear in the source.
VtableUnboxedClosure(ast::DefId, subst::Substs<'tcx>), VtableClosure(ast::DefId, subst::Substs<'tcx>),
/// Same as above, but for a fn pointer type with the given signature. /// Same as above, but for a fn pointer type with the given signature.
VtableFnPointer(ty::Ty<'tcx>), VtableFnPointer(ty::Ty<'tcx>),
@ -296,7 +296,7 @@ pub fn predicates_for_generics<'tcx>(tcx: &ty::ctxt<'tcx>,
/// conservative towards *no impl*, which is the opposite of the /// conservative towards *no impl*, which is the opposite of the
/// `evaluate` methods). /// `evaluate` methods).
pub fn evaluate_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>, pub fn evaluate_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
typer: &ty::UnboxedClosureTyper<'tcx>, typer: &ty::ClosureTyper<'tcx>,
ty: Ty<'tcx>, ty: Ty<'tcx>,
bound: ty::BuiltinBound, bound: ty::BuiltinBound,
span: Span) span: Span)
@ -361,7 +361,7 @@ pub fn evaluate_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
} }
pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>, pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
typer: &ty::UnboxedClosureTyper<'tcx>, typer: &ty::ClosureTyper<'tcx>,
ty: Ty<'tcx>, ty: Ty<'tcx>,
bound: ty::BuiltinBound, bound: ty::BuiltinBound,
span: Span) span: Span)
@ -446,7 +446,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
match *self { match *self {
VtableImpl(ref i) => i.iter_nested(), VtableImpl(ref i) => i.iter_nested(),
VtableFnPointer(..) => (&[]).iter(), VtableFnPointer(..) => (&[]).iter(),
VtableUnboxedClosure(..) => (&[]).iter(), VtableClosure(..) => (&[]).iter(),
VtableParam(ref n) => n.iter(), VtableParam(ref n) => n.iter(),
VtableObject(_) => (&[]).iter(), VtableObject(_) => (&[]).iter(),
VtableBuiltin(ref i) => i.iter_nested(), VtableBuiltin(ref i) => i.iter_nested(),
@ -457,7 +457,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
match *self { match *self {
VtableImpl(ref i) => VtableImpl(i.map_nested(op)), VtableImpl(ref i) => VtableImpl(i.map_nested(op)),
VtableFnPointer(ref sig) => VtableFnPointer((*sig).clone()), VtableFnPointer(ref sig) => VtableFnPointer((*sig).clone()),
VtableUnboxedClosure(d, ref s) => VtableUnboxedClosure(d, s.clone()), VtableClosure(d, ref s) => VtableClosure(d, s.clone()),
VtableParam(ref n) => VtableParam(n.iter().map(op).collect()), VtableParam(ref n) => VtableParam(n.iter().map(op).collect()),
VtableObject(ref p) => VtableObject(p.clone()), VtableObject(ref p) => VtableObject(p.clone()),
VtableBuiltin(ref b) => VtableBuiltin(b.map_nested(op)), VtableBuiltin(ref b) => VtableBuiltin(b.map_nested(op)),
@ -470,7 +470,7 @@ impl<'tcx, N> Vtable<'tcx, N> {
match self { match self {
VtableImpl(i) => VtableImpl(i.map_move_nested(op)), VtableImpl(i) => VtableImpl(i.map_move_nested(op)),
VtableFnPointer(sig) => VtableFnPointer(sig), VtableFnPointer(sig) => VtableFnPointer(sig),
VtableUnboxedClosure(d, s) => VtableUnboxedClosure(d, s), VtableClosure(d, s) => VtableClosure(d, s),
VtableParam(n) => VtableParam(n.into_iter().map(op).collect()), VtableParam(n) => VtableParam(n.into_iter().map(op).collect()),
VtableObject(p) => VtableObject(p), VtableObject(p) => VtableObject(p),
VtableBuiltin(no) => VtableBuiltin(no.map_move_nested(op)), VtableBuiltin(no) => VtableBuiltin(no.map_move_nested(op)),

View file

@ -579,7 +579,7 @@ fn assemble_candidates_from_impls<'cx,'tcx>(
// in `assemble_candidates_from_param_env`. // in `assemble_candidates_from_param_env`.
} }
super::VtableBuiltin(..) | super::VtableBuiltin(..) |
super::VtableUnboxedClosure(..) | super::VtableClosure(..) |
super::VtableFnPointer(..) => { super::VtableFnPointer(..) => {
// These traits have no associated types. // These traits have no associated types.
selcx.tcx().sess.span_bug( selcx.tcx().sess.span_bug(

View file

@ -25,7 +25,7 @@ use super::{ObligationCauseCode, BuiltinDerivedObligation};
use super::{SelectionError, Unimplemented, Overflow, OutputTypeParameterMismatch}; use super::{SelectionError, Unimplemented, Overflow, OutputTypeParameterMismatch};
use super::{Selection}; use super::{Selection};
use super::{SelectionResult}; use super::{SelectionResult};
use super::{VtableBuiltin, VtableImpl, VtableParam, VtableUnboxedClosure, use super::{VtableBuiltin, VtableImpl, VtableParam, VtableClosure,
VtableFnPointer, VtableObject}; VtableFnPointer, VtableObject};
use super::{VtableImplData, VtableObjectData, VtableBuiltinData}; use super::{VtableImplData, VtableObjectData, VtableBuiltinData};
use super::object_safety; use super::object_safety;
@ -47,7 +47,7 @@ use util::ppaux::Repr;
pub struct SelectionContext<'cx, 'tcx:'cx> { pub struct SelectionContext<'cx, 'tcx:'cx> {
infcx: &'cx InferCtxt<'cx, 'tcx>, infcx: &'cx InferCtxt<'cx, 'tcx>,
closure_typer: &'cx (ty::UnboxedClosureTyper<'tcx>+'cx), closure_typer: &'cx (ty::ClosureTyper<'tcx>+'cx),
/// Freshener used specifically for skolemizing entries on the /// Freshener used specifically for skolemizing entries on the
/// obligation stack. This ensures that all entries on the stack /// obligation stack. This ensures that all entries on the stack
@ -143,7 +143,7 @@ enum SelectionCandidate<'tcx> {
/// Implementation of a `Fn`-family trait by one of the /// Implementation of a `Fn`-family trait by one of the
/// anonymous types generated for a `||` expression. /// anonymous types generated for a `||` expression.
UnboxedClosureCandidate(/* closure */ ast::DefId, Substs<'tcx>), ClosureCandidate(/* closure */ ast::DefId, Substs<'tcx>),
/// Implementation of a `Fn`-family trait by one of the anonymous /// Implementation of a `Fn`-family trait by one of the anonymous
/// types generated for a fn pointer type (e.g., `fn(int)->int`) /// types generated for a fn pointer type (e.g., `fn(int)->int`)
@ -181,7 +181,7 @@ enum EvaluationResult<'tcx> {
impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx>, pub fn new(infcx: &'cx InferCtxt<'cx, 'tcx>,
closure_typer: &'cx ty::UnboxedClosureTyper<'tcx>) closure_typer: &'cx ty::ClosureTyper<'tcx>)
-> SelectionContext<'cx, 'tcx> { -> SelectionContext<'cx, 'tcx> {
SelectionContext { SelectionContext {
infcx: infcx, infcx: infcx,
@ -192,7 +192,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
} }
pub fn intercrate(infcx: &'cx InferCtxt<'cx, 'tcx>, pub fn intercrate(infcx: &'cx InferCtxt<'cx, 'tcx>,
closure_typer: &'cx ty::UnboxedClosureTyper<'tcx>) closure_typer: &'cx ty::ClosureTyper<'tcx>)
-> SelectionContext<'cx, 'tcx> { -> SelectionContext<'cx, 'tcx> {
SelectionContext { SelectionContext {
infcx: infcx, infcx: infcx,
@ -751,7 +751,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
// For the time being, we ignore user-defined impls for builtin-bounds, other than // For the time being, we ignore user-defined impls for builtin-bounds, other than
// `Copy`. // `Copy`.
// (And unboxed candidates only apply to the Fn/FnMut/etc traits.) // (And unboxed candidates only apply to the Fn/FnMut/etc traits.)
try!(self.assemble_unboxed_closure_candidates(obligation, &mut candidates)); try!(self.assemble_closure_candidates(obligation, &mut candidates));
try!(self.assemble_fn_pointer_candidates(obligation, &mut candidates)); try!(self.assemble_fn_pointer_candidates(obligation, &mut candidates));
try!(self.assemble_candidates_from_impls(obligation, &mut candidates)); try!(self.assemble_candidates_from_impls(obligation, &mut candidates));
self.assemble_candidates_from_object_ty(obligation, &mut candidates); self.assemble_candidates_from_object_ty(obligation, &mut candidates);
@ -948,7 +948,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
/// Note: the type parameters on an unboxed closure candidate are modeled as *output* type /// Note: the type parameters on an unboxed closure candidate are modeled as *output* type
/// parameters and hence do not affect whether this trait is a match or not. They will be /// parameters and hence do not affect whether this trait is a match or not. They will be
/// unified during the confirmation step. /// unified during the confirmation step.
fn assemble_unboxed_closure_candidates(&mut self, fn assemble_closure_candidates(&mut self,
obligation: &TraitObligation<'tcx>, obligation: &TraitObligation<'tcx>,
candidates: &mut SelectionCandidateSet<'tcx>) candidates: &mut SelectionCandidateSet<'tcx>)
-> Result<(),SelectionError<'tcx>> -> Result<(),SelectionError<'tcx>>
@ -960,7 +960,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let self_ty = self.infcx.shallow_resolve(obligation.self_ty()); let self_ty = self.infcx.shallow_resolve(obligation.self_ty());
let (closure_def_id, substs) = match self_ty.sty { let (closure_def_id, substs) = match self_ty.sty {
ty::ty_unboxed_closure(id, _, ref substs) => (id, substs.clone()), ty::ty_closure(id, _, ref substs) => (id, substs.clone()),
ty::ty_infer(ty::TyVar(_)) => { ty::ty_infer(ty::TyVar(_)) => {
candidates.ambiguous = true; candidates.ambiguous = true;
return Ok(()); return Ok(());
@ -973,12 +973,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
kind, kind,
obligation.repr(self.tcx())); obligation.repr(self.tcx()));
let closure_kind = self.closure_typer.unboxed_closure_kind(closure_def_id); let closure_kind = self.closure_typer.closure_kind(closure_def_id);
debug!("closure_kind = {:?}", closure_kind); debug!("closure_kind = {:?}", closure_kind);
if closure_kind == kind { if closure_kind == kind {
candidates.vec.push(UnboxedClosureCandidate(closure_def_id, substs.clone())); candidates.vec.push(ClosureCandidate(closure_def_id, substs.clone()));
} }
Ok(()) Ok(())
@ -1453,7 +1453,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
Ok(If(tys.clone())) Ok(If(tys.clone()))
} }
ty::ty_unboxed_closure(def_id, _, substs) => { ty::ty_closure(def_id, _, substs) => {
// FIXME -- This case is tricky. In the case of by-ref // FIXME -- This case is tricky. In the case of by-ref
// closures particularly, we need the results of // closures particularly, we need the results of
// inference to decide how to reflect the type of each // inference to decide how to reflect the type of each
@ -1471,7 +1471,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
return Ok(ParameterBuiltin); return Ok(ParameterBuiltin);
} }
match self.closure_typer.unboxed_closure_upvars(def_id, substs) { match self.closure_typer.closure_upvars(def_id, substs) {
Some(upvars) => { Some(upvars) => {
Ok(If(upvars.iter().map(|c| c.ty).collect())) Ok(If(upvars.iter().map(|c| c.ty).collect()))
} }
@ -1616,9 +1616,9 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
Ok(VtableImpl(vtable_impl)) Ok(VtableImpl(vtable_impl))
} }
UnboxedClosureCandidate(closure_def_id, substs) => { ClosureCandidate(closure_def_id, substs) => {
try!(self.confirm_unboxed_closure_candidate(obligation, closure_def_id, &substs)); try!(self.confirm_closure_candidate(obligation, closure_def_id, &substs));
Ok(VtableUnboxedClosure(closure_def_id, substs)) Ok(VtableClosure(closure_def_id, substs))
} }
ObjectCandidate => { ObjectCandidate => {
@ -1894,20 +1894,20 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
Ok(self_ty) Ok(self_ty)
} }
fn confirm_unboxed_closure_candidate(&mut self, fn confirm_closure_candidate(&mut self,
obligation: &TraitObligation<'tcx>, obligation: &TraitObligation<'tcx>,
closure_def_id: ast::DefId, closure_def_id: ast::DefId,
substs: &Substs<'tcx>) substs: &Substs<'tcx>)
-> Result<(),SelectionError<'tcx>> -> Result<(),SelectionError<'tcx>>
{ {
debug!("confirm_unboxed_closure_candidate({},{},{})", debug!("confirm_closure_candidate({},{},{})",
obligation.repr(self.tcx()), obligation.repr(self.tcx()),
closure_def_id.repr(self.tcx()), closure_def_id.repr(self.tcx()),
substs.repr(self.tcx())); substs.repr(self.tcx()));
let closure_type = self.closure_typer.unboxed_closure_type(closure_def_id, substs); let closure_type = self.closure_typer.closure_type(closure_def_id, substs);
debug!("confirm_unboxed_closure_candidate: closure_def_id={} closure_type={}", debug!("confirm_closure_candidate: closure_def_id={} closure_type={}",
closure_def_id.repr(self.tcx()), closure_def_id.repr(self.tcx()),
closure_type.repr(self.tcx())); closure_type.repr(self.tcx()));
@ -1923,7 +1923,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
substs: self.tcx().mk_substs(trait_substs), substs: self.tcx().mk_substs(trait_substs),
})); }));
debug!("confirm_unboxed_closure_candidate(closure_def_id={}, trait_ref={})", debug!("confirm_closure_candidate(closure_def_id={}, trait_ref={})",
closure_def_id.repr(self.tcx()), closure_def_id.repr(self.tcx()),
trait_ref.repr(self.tcx())); trait_ref.repr(self.tcx()));
@ -2259,15 +2259,15 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
fn fn_family_trait_kind(&self, fn fn_family_trait_kind(&self,
trait_def_id: ast::DefId) trait_def_id: ast::DefId)
-> Option<ty::UnboxedClosureKind> -> Option<ty::ClosureKind>
{ {
let tcx = self.tcx(); let tcx = self.tcx();
if Some(trait_def_id) == tcx.lang_items.fn_trait() { if Some(trait_def_id) == tcx.lang_items.fn_trait() {
Some(ty::FnUnboxedClosureKind) Some(ty::FnClosureKind)
} else if Some(trait_def_id) == tcx.lang_items.fn_mut_trait() { } else if Some(trait_def_id) == tcx.lang_items.fn_mut_trait() {
Some(ty::FnMutUnboxedClosureKind) Some(ty::FnMutClosureKind)
} else if Some(trait_def_id) == tcx.lang_items.fn_once_trait() { } else if Some(trait_def_id) == tcx.lang_items.fn_once_trait() {
Some(ty::FnOnceUnboxedClosureKind) Some(ty::FnOnceClosureKind)
} else { } else {
None None
} }
@ -2318,8 +2318,8 @@ impl<'tcx> Repr<'tcx> for SelectionCandidate<'tcx> {
ObjectCandidate => { ObjectCandidate => {
format!("ObjectCandidate") format!("ObjectCandidate")
} }
UnboxedClosureCandidate(c, ref s) => { ClosureCandidate(c, ref s) => {
format!("UnboxedClosureCandidate({:?},{})", c, s.repr(tcx)) format!("ClosureCandidate({:?},{})", c, s.repr(tcx))
} }
} }
} }

View file

@ -367,8 +367,8 @@ impl<'tcx, N:Repr<'tcx>> Repr<'tcx> for super::Vtable<'tcx, N> {
super::VtableImpl(ref v) => super::VtableImpl(ref v) =>
v.repr(tcx), v.repr(tcx),
super::VtableUnboxedClosure(ref d, ref s) => super::VtableClosure(ref d, ref s) =>
format!("VtableUnboxedClosure({},{})", format!("VtableClosure({},{})",
d.repr(tcx), d.repr(tcx),
s.repr(tcx)), s.repr(tcx)),

View file

@ -16,7 +16,7 @@ pub use self::BuiltinBound::*;
pub use self::InferTy::*; pub use self::InferTy::*;
pub use self::InferRegion::*; pub use self::InferRegion::*;
pub use self::ImplOrTraitItemId::*; pub use self::ImplOrTraitItemId::*;
pub use self::UnboxedClosureKind::*; pub use self::ClosureKind::*;
pub use self::ast_ty_to_ty_cache_entry::*; pub use self::ast_ty_to_ty_cache_entry::*;
pub use self::Variance::*; pub use self::Variance::*;
pub use self::AutoAdjustment::*; pub use self::AutoAdjustment::*;
@ -434,7 +434,7 @@ pub enum MethodOrigin<'tcx> {
MethodStatic(ast::DefId), MethodStatic(ast::DefId),
// fully statically resolved unboxed closure invocation // fully statically resolved unboxed closure invocation
MethodStaticUnboxedClosure(ast::DefId), MethodStaticClosure(ast::DefId),
// method invoked on a type parameter with a bounded trait // method invoked on a type parameter with a bounded trait
MethodTypeParam(MethodParam<'tcx>), MethodTypeParam(MethodParam<'tcx>),
@ -569,7 +569,7 @@ pub enum vtable_origin<'tcx> {
Vtable automatically generated for an unboxed closure. The def ID is the Vtable automatically generated for an unboxed closure. The def ID is the
ID of the closure expression. ID of the closure expression.
*/ */
vtable_unboxed_closure(ast::DefId), vtable_closure(ast::DefId),
/* /*
Asked to determine the vtable for ty_err. This is the value used Asked to determine the vtable for ty_err. This is the value used
@ -788,7 +788,7 @@ pub struct ctxt<'tcx> {
/// Records the type of each unboxed closure. The def ID is the ID of the /// Records the type of each unboxed closure. The def ID is the ID of the
/// expression defining the unboxed closure. /// expression defining the unboxed closure.
pub unboxed_closures: RefCell<DefIdMap<UnboxedClosure<'tcx>>>, pub closures: RefCell<DefIdMap<Closure<'tcx>>>,
pub node_lint_levels: RefCell<FnvHashMap<(ast::NodeId, lint::LintId), pub node_lint_levels: RefCell<FnvHashMap<(ast::NodeId, lint::LintId),
lint::LevelSource>>, lint::LevelSource>>,
@ -913,7 +913,7 @@ impl<'tcx> ctxt<'tcx> {
sty_debug_print!( sty_debug_print!(
self, self,
ty_enum, ty_uniq, ty_vec, ty_ptr, ty_rptr, ty_bare_fn, ty_trait, ty_enum, ty_uniq, ty_vec, ty_ptr, ty_rptr, ty_bare_fn, ty_trait,
ty_struct, ty_unboxed_closure, ty_tup, ty_param, ty_open, ty_infer, ty_projection); ty_struct, ty_closure, ty_tup, ty_param, ty_open, ty_infer, ty_projection);
println!("Substs interner: #{}", self.substs_interner.borrow().len()); println!("Substs interner: #{}", self.substs_interner.borrow().len());
println!("BareFnTy interner: #{}", self.bare_fn_interner.borrow().len()); println!("BareFnTy interner: #{}", self.bare_fn_interner.borrow().len());
@ -1376,7 +1376,7 @@ pub enum sty<'tcx> {
ty_trait(Box<TyTrait<'tcx>>), ty_trait(Box<TyTrait<'tcx>>),
ty_struct(DefId, &'tcx Substs<'tcx>), ty_struct(DefId, &'tcx Substs<'tcx>),
ty_unboxed_closure(DefId, &'tcx Region, &'tcx Substs<'tcx>), ty_closure(DefId, &'tcx Region, &'tcx Substs<'tcx>),
ty_tup(Vec<Ty<'tcx>>), ty_tup(Vec<Ty<'tcx>>),
@ -2266,28 +2266,28 @@ pub struct ItemSubsts<'tcx> {
/// Records information about each unboxed closure. /// Records information about each unboxed closure.
#[derive(Clone)] #[derive(Clone)]
pub struct UnboxedClosure<'tcx> { pub struct Closure<'tcx> {
/// The type of the unboxed closure. /// The type of the unboxed closure.
pub closure_type: ClosureTy<'tcx>, pub closure_type: ClosureTy<'tcx>,
/// The kind of unboxed closure this is. /// The kind of unboxed closure this is.
pub kind: UnboxedClosureKind, pub kind: ClosureKind,
} }
#[derive(Clone, Copy, PartialEq, Eq, Show)] #[derive(Clone, Copy, PartialEq, Eq, Show)]
pub enum UnboxedClosureKind { pub enum ClosureKind {
FnUnboxedClosureKind, FnClosureKind,
FnMutUnboxedClosureKind, FnMutClosureKind,
FnOnceUnboxedClosureKind, FnOnceClosureKind,
} }
impl UnboxedClosureKind { impl ClosureKind {
pub fn trait_did(&self, cx: &ctxt) -> ast::DefId { pub fn trait_did(&self, cx: &ctxt) -> ast::DefId {
let result = match *self { let result = match *self {
FnUnboxedClosureKind => cx.lang_items.require(FnTraitLangItem), FnClosureKind => cx.lang_items.require(FnTraitLangItem),
FnMutUnboxedClosureKind => { FnMutClosureKind => {
cx.lang_items.require(FnMutTraitLangItem) cx.lang_items.require(FnMutTraitLangItem)
} }
FnOnceUnboxedClosureKind => { FnOnceClosureKind => {
cx.lang_items.require(FnOnceTraitLangItem) cx.lang_items.require(FnOnceTraitLangItem)
} }
}; };
@ -2298,23 +2298,21 @@ impl UnboxedClosureKind {
} }
} }
pub trait UnboxedClosureTyper<'tcx> { pub trait ClosureTyper<'tcx> {
fn param_env<'a>(&'a self) -> &'a ty::ParameterEnvironment<'a, 'tcx>; fn param_env<'a>(&'a self) -> &'a ty::ParameterEnvironment<'a, 'tcx>;
fn unboxed_closure_kind(&self, fn closure_kind(&self, def_id: ast::DefId) -> ty::ClosureKind;
def_id: ast::DefId)
-> ty::UnboxedClosureKind;
fn unboxed_closure_type(&self, fn closure_type(&self,
def_id: ast::DefId, def_id: ast::DefId,
substs: &subst::Substs<'tcx>) substs: &subst::Substs<'tcx>)
-> ty::ClosureTy<'tcx>; -> ty::ClosureTy<'tcx>;
// Returns `None` if the upvar types cannot yet be definitively determined. // Returns `None` if the upvar types cannot yet be definitively determined.
fn unboxed_closure_upvars(&self, fn closure_upvars(&self,
def_id: ast::DefId, def_id: ast::DefId,
substs: &Substs<'tcx>) substs: &Substs<'tcx>)
-> Option<Vec<UnboxedClosureUpvar<'tcx>>>; -> Option<Vec<ClosureUpvar<'tcx>>>;
} }
impl<'tcx> CommonTypes<'tcx> { impl<'tcx> CommonTypes<'tcx> {
@ -2407,7 +2405,7 @@ pub fn mk_ctxt<'tcx>(s: Session,
extern_const_variants: RefCell::new(DefIdMap()), extern_const_variants: RefCell::new(DefIdMap()),
method_map: RefCell::new(FnvHashMap()), method_map: RefCell::new(FnvHashMap()),
dependency_formats: RefCell::new(FnvHashMap()), dependency_formats: RefCell::new(FnvHashMap()),
unboxed_closures: RefCell::new(DefIdMap()), closures: RefCell::new(DefIdMap()),
node_lint_levels: RefCell::new(FnvHashMap()), node_lint_levels: RefCell::new(FnvHashMap()),
transmute_restrictions: RefCell::new(Vec::new()), transmute_restrictions: RefCell::new(Vec::new()),
stability: RefCell::new(stability), stability: RefCell::new(stability),
@ -2454,19 +2452,16 @@ impl<'tcx> ctxt<'tcx> {
region region
} }
pub fn unboxed_closure_kind(&self, pub fn closure_kind(&self, def_id: ast::DefId) -> ty::ClosureKind {
def_id: ast::DefId) self.closures.borrow()[def_id].kind
-> ty::UnboxedClosureKind
{
self.unboxed_closures.borrow()[def_id].kind
} }
pub fn unboxed_closure_type(&self, pub fn closure_type(&self,
def_id: ast::DefId, def_id: ast::DefId,
substs: &subst::Substs<'tcx>) substs: &subst::Substs<'tcx>)
-> ty::ClosureTy<'tcx> -> ty::ClosureTy<'tcx>
{ {
self.unboxed_closures.borrow()[def_id].closure_type.subst(self, substs) self.closures.borrow()[def_id].closure_type.subst(self, substs)
} }
} }
@ -2574,7 +2569,7 @@ impl FlagComputation {
} }
} }
&ty_unboxed_closure(_, region, substs) => { &ty_closure(_, region, substs) => {
self.add_region(*region); self.add_region(*region);
self.add_substs(substs); self.add_substs(substs);
} }
@ -2843,10 +2838,10 @@ pub fn mk_struct<'tcx>(cx: &ctxt<'tcx>, struct_id: ast::DefId,
mk_t(cx, ty_struct(struct_id, substs)) mk_t(cx, ty_struct(struct_id, substs))
} }
pub fn mk_unboxed_closure<'tcx>(cx: &ctxt<'tcx>, closure_id: ast::DefId, pub fn mk_closure<'tcx>(cx: &ctxt<'tcx>, closure_id: ast::DefId,
region: &'tcx Region, substs: &'tcx Substs<'tcx>) region: &'tcx Region, substs: &'tcx Substs<'tcx>)
-> Ty<'tcx> { -> Ty<'tcx> {
mk_t(cx, ty_unboxed_closure(closure_id, region, substs)) mk_t(cx, ty_closure(closure_id, region, substs))
} }
pub fn mk_var<'tcx>(cx: &ctxt<'tcx>, v: TyVid) -> Ty<'tcx> { pub fn mk_var<'tcx>(cx: &ctxt<'tcx>, v: TyVid) -> Ty<'tcx> {
@ -3057,7 +3052,7 @@ pub fn type_is_vec(ty: Ty) -> bool {
pub fn type_is_structural(ty: Ty) -> bool { pub fn type_is_structural(ty: Ty) -> bool {
match ty.sty { match ty.sty {
ty_struct(..) | ty_tup(_) | ty_enum(..) | ty_struct(..) | ty_tup(_) | ty_enum(..) |
ty_vec(_, Some(_)) | ty_unboxed_closure(..) => true, ty_vec(_, Some(_)) | ty_closure(..) => true,
_ => type_is_slice(ty) | type_is_trait(ty) _ => type_is_slice(ty) | type_is_trait(ty)
} }
} }
@ -3422,11 +3417,11 @@ pub fn type_contents<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> TypeContents {
apply_lang_items(cx, did, res) apply_lang_items(cx, did, res)
} }
ty_unboxed_closure(did, r, substs) => { ty_closure(did, r, substs) => {
// FIXME(#14449): `borrowed_contents` below assumes `&mut` // FIXME(#14449): `borrowed_contents` below assumes `&mut`
// unboxed closure. // unboxed closure.
let param_env = ty::empty_parameter_environment(cx); let param_env = ty::empty_parameter_environment(cx);
let upvars = unboxed_closure_upvars(&param_env, did, substs).unwrap(); let upvars = closure_upvars(&param_env, did, substs).unwrap();
TypeContents::union(upvars.as_slice(), TypeContents::union(upvars.as_slice(),
|f| tc_ty(cx, f.ty, cache)) |f| tc_ty(cx, f.ty, cache))
| borrowed_contents(*r, MutMutable) | borrowed_contents(*r, MutMutable)
@ -3690,7 +3685,7 @@ pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
ty_err | ty_err |
ty_infer(_) | ty_infer(_) |
ty_unboxed_closure(..) => { ty_closure(..) => {
// this check is run on type definitions, so we don't expect to see // this check is run on type definitions, so we don't expect to see
// inference by-products or unboxed closure types // inference by-products or unboxed closure types
cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}", cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}",
@ -3784,7 +3779,7 @@ pub fn is_type_representable<'tcx>(cx: &ctxt<'tcx>, sp: Span, ty: Ty<'tcx>)
find_nonrepresentable(cx, sp, seen, iter) find_nonrepresentable(cx, sp, seen, iter)
} }
ty_unboxed_closure(..) => { ty_closure(..) => {
// this check is run on type definitions, so we don't expect to see // this check is run on type definitions, so we don't expect to see
// unboxed closure types // unboxed closure types
cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}", cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}",
@ -4698,7 +4693,7 @@ pub fn ty_sort_string<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> String {
ty_struct(id, _) => { ty_struct(id, _) => {
format!("struct `{}`", item_path_str(cx, id)) format!("struct `{}`", item_path_str(cx, id))
} }
ty_unboxed_closure(..) => "closure".to_string(), ty_closure(..) => "closure".to_string(),
ty_tup(_) => "tuple".to_string(), ty_tup(_) => "tuple".to_string(),
ty_infer(TyVar(_)) => "inferred type".to_string(), ty_infer(TyVar(_)) => "inferred type".to_string(),
ty_infer(IntVar(_)) => "integral variable".to_string(), ty_infer(IntVar(_)) => "integral variable".to_string(),
@ -5118,7 +5113,7 @@ pub fn ty_to_def_id(ty: Ty) -> Option<ast::DefId> {
Some(tt.principal_def_id()), Some(tt.principal_def_id()),
ty_struct(id, _) | ty_struct(id, _) |
ty_enum(id, _) | ty_enum(id, _) |
ty_unboxed_closure(id, _, _) => ty_closure(id, _, _) =>
Some(id), Some(id),
_ => _ =>
None None
@ -5626,17 +5621,17 @@ pub fn tup_fields<'tcx>(v: &[Ty<'tcx>]) -> Vec<field<'tcx>> {
} }
#[derive(Copy, Clone)] #[derive(Copy, Clone)]
pub struct UnboxedClosureUpvar<'tcx> { pub struct ClosureUpvar<'tcx> {
pub def: def::Def, pub def: def::Def,
pub span: Span, pub span: Span,
pub ty: Ty<'tcx>, pub ty: Ty<'tcx>,
} }
// Returns a list of `UnboxedClosureUpvar`s for each upvar. // Returns a list of `ClosureUpvar`s for each upvar.
pub fn unboxed_closure_upvars<'tcx>(typer: &mc::Typer<'tcx>, pub fn closure_upvars<'tcx>(typer: &mc::Typer<'tcx>,
closure_id: ast::DefId, closure_id: ast::DefId,
substs: &Substs<'tcx>) substs: &Substs<'tcx>)
-> Option<Vec<UnboxedClosureUpvar<'tcx>>> -> Option<Vec<ClosureUpvar<'tcx>>>
{ {
// Presently an unboxed closure type cannot "escape" out of a // Presently an unboxed closure type cannot "escape" out of a
// function, so we will only encounter ones that originated in the // function, so we will only encounter ones that originated in the
@ -5660,7 +5655,7 @@ pub fn unboxed_closure_upvars<'tcx>(typer: &mc::Typer<'tcx>,
match capture_mode { match capture_mode {
ast::CaptureByValue => { ast::CaptureByValue => {
Some(UnboxedClosureUpvar { def: freevar.def, Some(ClosureUpvar { def: freevar.def,
span: freevar.span, span: freevar.span,
ty: freevar_ty }) ty: freevar_ty })
} }
@ -5688,7 +5683,7 @@ pub fn unboxed_closure_upvars<'tcx>(typer: &mc::Typer<'tcx>,
freevar_ty freevar_ty
} }
}; };
Some(UnboxedClosureUpvar { Some(ClosureUpvar {
def: freevar.def, def: freevar.def,
span: freevar.span, span: freevar.span,
ty: freevar_ref_ty, ty: freevar_ref_ty,
@ -6240,7 +6235,7 @@ pub fn hash_crate_independent<'tcx>(tcx: &ctxt<'tcx>, ty: Ty<'tcx>, svh: &Svh) -
ty_open(_) => byte!(22), ty_open(_) => byte!(22),
ty_infer(_) => unreachable!(), ty_infer(_) => unreachable!(),
ty_err => byte!(23), ty_err => byte!(23),
ty_unboxed_closure(d, r, _) => { ty_closure(d, r, _) => {
byte!(24); byte!(24);
did(state, d); did(state, d);
region(state, *r); region(state, *r);
@ -6476,32 +6471,29 @@ impl<'a,'tcx> mc::Typer<'tcx> for ParameterEnvironment<'a,'tcx> {
} }
} }
impl<'a,'tcx> UnboxedClosureTyper<'tcx> for ty::ParameterEnvironment<'a,'tcx> { impl<'a,'tcx> ClosureTyper<'tcx> for ty::ParameterEnvironment<'a,'tcx> {
fn param_env<'b>(&'b self) -> &'b ty::ParameterEnvironment<'b,'tcx> { fn param_env<'b>(&'b self) -> &'b ty::ParameterEnvironment<'b,'tcx> {
self self
} }
fn unboxed_closure_kind(&self, fn closure_kind(&self, def_id: ast::DefId) -> ty::ClosureKind {
def_id: ast::DefId) self.tcx.closure_kind(def_id)
-> ty::UnboxedClosureKind
{
self.tcx.unboxed_closure_kind(def_id)
} }
fn unboxed_closure_type(&self, fn closure_type(&self,
def_id: ast::DefId, def_id: ast::DefId,
substs: &subst::Substs<'tcx>) substs: &subst::Substs<'tcx>)
-> ty::ClosureTy<'tcx> -> ty::ClosureTy<'tcx>
{ {
self.tcx.unboxed_closure_type(def_id, substs) self.tcx.closure_type(def_id, substs)
} }
fn unboxed_closure_upvars(&self, fn closure_upvars(&self,
def_id: ast::DefId, def_id: ast::DefId,
substs: &Substs<'tcx>) substs: &Substs<'tcx>)
-> Option<Vec<UnboxedClosureUpvar<'tcx>>> -> Option<Vec<ClosureUpvar<'tcx>>>
{ {
unboxed_closure_upvars(self, def_id, substs) closure_upvars(self, def_id, substs)
} }
} }
@ -6533,7 +6525,7 @@ pub fn accumulate_lifetimes_in_type(accumulator: &mut Vec<ty::Region>,
ty_struct(_, substs) => { ty_struct(_, substs) => {
accum_substs(accumulator, substs); accum_substs(accumulator, substs);
} }
ty_unboxed_closure(_, region, substs) => { ty_closure(_, region, substs) => {
accumulator.push(*region); accumulator.push(*region);
accum_substs(accumulator, substs); accum_substs(accumulator, substs);
} }
@ -6826,8 +6818,8 @@ impl<'tcx> Repr<'tcx> for vtable_origin<'tcx> {
format!("vtable_param({:?}, {})", x, y) format!("vtable_param({:?}, {})", x, y)
} }
vtable_unboxed_closure(def_id) => { vtable_closure(def_id) => {
format!("vtable_unboxed_closure({:?})", def_id) format!("vtable_closure({:?})", def_id)
} }
vtable_error => { vtable_error => {
@ -7064,7 +7056,7 @@ impl<'tcx> HasProjectionTypes for ClosureTy<'tcx> {
} }
} }
impl<'tcx> HasProjectionTypes for UnboxedClosureUpvar<'tcx> { impl<'tcx> HasProjectionTypes for ClosureUpvar<'tcx> {
fn has_projection_types(&self) -> bool { fn has_projection_types(&self) -> bool {
self.ty.has_projection_types() self.ty.has_projection_types()
} }
@ -7285,9 +7277,9 @@ impl<'tcx> Repr<'tcx> for ClosureTy<'tcx> {
} }
} }
impl<'tcx> Repr<'tcx> for UnboxedClosureUpvar<'tcx> { impl<'tcx> Repr<'tcx> for ClosureUpvar<'tcx> {
fn repr(&self, tcx: &ctxt<'tcx>) -> String { fn repr(&self, tcx: &ctxt<'tcx>) -> String {
format!("UnboxedClosureUpvar({},{})", format!("ClosureUpvar({},{})",
self.def.repr(tcx), self.def.repr(tcx),
self.ty.repr(tcx)) self.ty.repr(tcx))
} }

View file

@ -304,8 +304,8 @@ impl<'tcx> TypeFoldable<'tcx> for ty::MethodOrigin<'tcx> {
ty::MethodStatic(def_id) => { ty::MethodStatic(def_id) => {
ty::MethodStatic(def_id) ty::MethodStatic(def_id)
} }
ty::MethodStaticUnboxedClosure(def_id) => { ty::MethodStaticClosure(def_id) => {
ty::MethodStaticUnboxedClosure(def_id) ty::MethodStaticClosure(def_id)
} }
ty::MethodTypeParam(ref param) => { ty::MethodTypeParam(ref param) => {
ty::MethodTypeParam(ty::MethodParam { ty::MethodTypeParam(ty::MethodParam {
@ -337,8 +337,8 @@ impl<'tcx> TypeFoldable<'tcx> for ty::vtable_origin<'tcx> {
ty::vtable_param(n, b) => { ty::vtable_param(n, b) => {
ty::vtable_param(n, b) ty::vtable_param(n, b)
} }
ty::vtable_unboxed_closure(def_id) => { ty::vtable_closure(def_id) => {
ty::vtable_unboxed_closure(def_id) ty::vtable_closure(def_id)
} }
ty::vtable_error => { ty::vtable_error => {
ty::vtable_error ty::vtable_error
@ -499,8 +499,8 @@ impl<'tcx, N: TypeFoldable<'tcx>> TypeFoldable<'tcx> for traits::Vtable<'tcx, N>
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Vtable<'tcx, N> { fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> traits::Vtable<'tcx, N> {
match *self { match *self {
traits::VtableImpl(ref v) => traits::VtableImpl(v.fold_with(folder)), traits::VtableImpl(ref v) => traits::VtableImpl(v.fold_with(folder)),
traits::VtableUnboxedClosure(d, ref s) => { traits::VtableClosure(d, ref s) => {
traits::VtableUnboxedClosure(d, s.fold_with(folder)) traits::VtableClosure(d, s.fold_with(folder))
} }
traits::VtableFnPointer(ref d) => { traits::VtableFnPointer(ref d) => {
traits::VtableFnPointer(d.fold_with(folder)) traits::VtableFnPointer(d.fold_with(folder))
@ -545,9 +545,9 @@ impl<'tcx,T,U> TypeFoldable<'tcx> for ty::OutlivesPredicate<T,U>
} }
} }
impl<'tcx> TypeFoldable<'tcx> for ty::UnboxedClosureUpvar<'tcx> { impl<'tcx> TypeFoldable<'tcx> for ty::ClosureUpvar<'tcx> {
fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::UnboxedClosureUpvar<'tcx> { fn fold_with<F:TypeFolder<'tcx>>(&self, folder: &mut F) -> ty::ClosureUpvar<'tcx> {
ty::UnboxedClosureUpvar { ty::ClosureUpvar {
def: self.def, def: self.def,
span: self.span, span: self.span,
ty: self.ty.fold_with(folder), ty: self.ty.fold_with(folder),
@ -624,10 +624,10 @@ pub fn super_fold_ty<'tcx, T: TypeFolder<'tcx>>(this: &mut T,
let substs = substs.fold_with(this); let substs = substs.fold_with(this);
ty::ty_struct(did, this.tcx().mk_substs(substs)) ty::ty_struct(did, this.tcx().mk_substs(substs))
} }
ty::ty_unboxed_closure(did, ref region, ref substs) => { ty::ty_closure(did, ref region, ref substs) => {
let r = region.fold_with(this); let r = region.fold_with(this);
let s = substs.fold_with(this); let s = substs.fold_with(this);
ty::ty_unboxed_closure(did, this.tcx().mk_region(r), this.tcx().mk_substs(s)) ty::ty_closure(did, this.tcx().mk_region(r), this.tcx().mk_substs(s))
} }
ty::ty_projection(ref data) => { ty::ty_projection(ref data) => {
ty::ty_projection(data.fold_with(this)) ty::ty_projection(data.fold_with(this))

View file

@ -42,7 +42,7 @@ impl<'tcx> TypeWalker<'tcx> {
} }
ty::ty_enum(_, ref substs) | ty::ty_enum(_, ref substs) |
ty::ty_struct(_, ref substs) | ty::ty_struct(_, ref substs) |
ty::ty_unboxed_closure(_, _, ref substs) => { ty::ty_closure(_, _, ref substs) => {
self.push_reversed(substs.types.as_slice()); self.push_reversed(substs.types.as_slice());
} }
ty::ty_tup(ref ts) => { ty::ty_tup(ref ts) => {

View file

@ -20,7 +20,7 @@ use middle::ty::{mt, Ty, ParamTy};
use middle::ty::{ty_bool, ty_char, ty_struct, ty_enum}; use middle::ty::{ty_bool, ty_char, ty_struct, ty_enum};
use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn}; use middle::ty::{ty_err, ty_str, ty_vec, ty_float, ty_bare_fn};
use middle::ty::{ty_param, ty_ptr, ty_rptr, ty_tup, ty_open}; use middle::ty::{ty_param, ty_ptr, ty_rptr, ty_tup, ty_open};
use middle::ty::{ty_unboxed_closure}; use middle::ty::{ty_closure};
use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_infer}; use middle::ty::{ty_uniq, ty_trait, ty_int, ty_uint, ty_infer};
use middle::ty; use middle::ty;
use middle::ty_fold::TypeFoldable; use middle::ty_fold::TypeFoldable;
@ -414,9 +414,8 @@ pub fn ty_to_string<'tcx>(cx: &ctxt<'tcx>, typ: &ty::TyS<'tcx>) -> String {
data.item_name.user_string(cx)) data.item_name.user_string(cx))
} }
ty_str => "str".to_string(), ty_str => "str".to_string(),
ty_unboxed_closure(ref did, _, substs) => { ty_closure(ref did, _, substs) => {
let unboxed_closures = cx.unboxed_closures.borrow(); cx.closures.borrow().get(did).map(|cl| {
unboxed_closures.get(did).map(|cl| {
closure_to_string(cx, &cl.closure_type.subst(cx, substs)) closure_to_string(cx, &cl.closure_type.subst(cx, substs))
}).unwrap_or_else(|| { }).unwrap_or_else(|| {
if did.krate == ast::LOCAL_CRATE { if did.krate == ast::LOCAL_CRATE {
@ -1021,8 +1020,8 @@ impl<'tcx> Repr<'tcx> for ty::MethodOrigin<'tcx> {
&ty::MethodStatic(def_id) => { &ty::MethodStatic(def_id) => {
format!("MethodStatic({})", def_id.repr(tcx)) format!("MethodStatic({})", def_id.repr(tcx))
} }
&ty::MethodStaticUnboxedClosure(def_id) => { &ty::MethodStaticClosure(def_id) => {
format!("MethodStaticUnboxedClosure({})", def_id.repr(tcx)) format!("MethodStaticClosure({})", def_id.repr(tcx))
} }
&ty::MethodTypeParam(ref p) => { &ty::MethodTypeParam(ref p) => {
p.repr(tcx) p.repr(tcx)

View file

@ -806,7 +806,7 @@ impl<'a, 'tcx> CheckLoanCtxt<'a, 'tcx> {
mc::cat_upvar(mc::Upvar { kind, .. }) => kind, mc::cat_upvar(mc::Upvar { kind, .. }) => kind,
_ => unreachable!() _ => unreachable!()
}; };
if kind == ty::FnUnboxedClosureKind { if kind == ty::FnClosureKind {
self.bccx.span_err( self.bccx.span_err(
assignment_span, assignment_span,
&format!("cannot assign to {}", &format!("cannot assign to {}",

View file

@ -845,7 +845,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> {
mc::cat_upvar(mc::Upvar { kind, .. }) => kind, mc::cat_upvar(mc::Upvar { kind, .. }) => kind,
_ => unreachable!() _ => unreachable!()
}; };
if kind == ty::FnUnboxedClosureKind { if kind == ty::FnClosureKind {
self.tcx.sess.span_help( self.tcx.sess.span_help(
self.tcx.map.span(upvar_id.closure_expr_id), self.tcx.map.span(upvar_id.closure_expr_id),
"consider changing this closure to take \ "consider changing this closure to take \

View file

@ -40,7 +40,7 @@ use rustc::middle::privacy::{ExportedItems, PublicItems, LastPrivateMap};
use rustc::middle::privacy::{ExternalExports}; use rustc::middle::privacy::{ExternalExports};
use rustc::middle::ty::{MethodTypeParam, MethodStatic}; use rustc::middle::ty::{MethodTypeParam, MethodStatic};
use rustc::middle::ty::{MethodCall, MethodMap, MethodOrigin, MethodParam}; use rustc::middle::ty::{MethodCall, MethodMap, MethodOrigin, MethodParam};
use rustc::middle::ty::{MethodStaticUnboxedClosure, MethodObject}; use rustc::middle::ty::{MethodStaticClosure, MethodObject};
use rustc::middle::ty::{MethodTraitObject}; use rustc::middle::ty::{MethodTraitObject};
use rustc::middle::ty::{self, Ty}; use rustc::middle::ty::{self, Ty};
use rustc::util::nodemap::{NodeMap, NodeSet}; use rustc::util::nodemap::{NodeMap, NodeSet};
@ -816,7 +816,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> {
MethodStatic(method_id) => { MethodStatic(method_id) => {
self.check_static_method(span, method_id, ident) self.check_static_method(span, method_id, ident)
} }
MethodStaticUnboxedClosure(_) => {} MethodStaticClosure(_) => {}
// Trait methods are always all public. The only controlling factor // Trait methods are always all public. The only controlling factor
// is whether the trait itself is accessible or not. // is whether the trait itself is accessible or not.
MethodTypeParam(MethodParam { ref trait_ref, .. }) | MethodTypeParam(MethodParam { ref trait_ref, .. }) |

View file

@ -920,7 +920,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> {
let method_callee = &(*method_map)[ty::MethodCall::expr(ex.id)]; let method_callee = &(*method_map)[ty::MethodCall::expr(ex.id)];
let (def_id, decl_id) = match method_callee.origin { let (def_id, decl_id) = match method_callee.origin {
ty::MethodStatic(def_id) | ty::MethodStatic(def_id) |
ty::MethodStaticUnboxedClosure(def_id) => { ty::MethodStaticClosure(def_id) => {
// method invoked on an object with a concrete type (not a static method) // method invoked on an object with a concrete type (not a static method)
let decl_id = let decl_id =
match ty::trait_item_of_item(&self.analysis.ty_cx, match ty::trait_item_of_item(&self.analysis.ty_cx,

View file

@ -51,7 +51,7 @@ use std::rc::Rc;
use llvm::{ValueRef, True, IntEQ, IntNE}; use llvm::{ValueRef, True, IntEQ, IntNE};
use back::abi::FAT_PTR_ADDR; use back::abi::FAT_PTR_ADDR;
use middle::subst; use middle::subst;
use middle::ty::{self, Ty, UnboxedClosureTyper}; use middle::ty::{self, Ty, ClosureTyper};
use middle::ty::Disr; use middle::ty::Disr;
use syntax::ast; use syntax::ast;
use syntax::attr; use syntax::attr;
@ -169,9 +169,9 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
Univariant(mk_struct(cx, &ftys[], packed, t), dtor) Univariant(mk_struct(cx, &ftys[], packed, t), dtor)
} }
ty::ty_unboxed_closure(def_id, _, substs) => { ty::ty_closure(def_id, _, substs) => {
let typer = NormalizingUnboxedClosureTyper::new(cx.tcx()); let typer = NormalizingClosureTyper::new(cx.tcx());
let upvars = typer.unboxed_closure_upvars(def_id, substs).unwrap(); let upvars = typer.closure_upvars(def_id, substs).unwrap();
let upvar_types = upvars.iter().map(|u| u.ty).collect::<Vec<_>>(); let upvar_types = upvars.iter().map(|u| u.ty).collect::<Vec<_>>();
Univariant(mk_struct(cx, &upvar_types[], false, t), false) Univariant(mk_struct(cx, &upvar_types[], false, t), false)
} }

View file

@ -43,7 +43,7 @@ use middle::lang_items::{LangItem, ExchangeMallocFnLangItem, StartFnLangItem};
use middle::subst; use middle::subst;
use middle::weak_lang_items; use middle::weak_lang_items;
use middle::subst::{Subst, Substs}; use middle::subst::{Subst, Substs};
use middle::ty::{self, Ty, UnboxedClosureTyper}; use middle::ty::{self, Ty, ClosureTyper};
use session::config::{self, NoDebugInfo}; use session::config::{self, NoDebugInfo};
use session::Session; use session::Session;
use trans::_match; use trans::_match;
@ -255,27 +255,25 @@ fn get_extern_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<'tcx>,
f f
} }
pub fn self_type_for_unboxed_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, pub fn self_type_for_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
closure_id: ast::DefId, closure_id: ast::DefId,
fn_ty: Ty<'tcx>) fn_ty: Ty<'tcx>)
-> Ty<'tcx> -> Ty<'tcx>
{ {
let unboxed_closure_kind = ccx.tcx().unboxed_closure_kind(closure_id); let closure_kind = ccx.tcx().closure_kind(closure_id);
match unboxed_closure_kind { match closure_kind {
ty::FnUnboxedClosureKind => { ty::FnClosureKind => {
ty::mk_imm_rptr(ccx.tcx(), ccx.tcx().mk_region(ty::ReStatic), fn_ty) ty::mk_imm_rptr(ccx.tcx(), ccx.tcx().mk_region(ty::ReStatic), fn_ty)
} }
ty::FnMutUnboxedClosureKind => { ty::FnMutClosureKind => {
ty::mk_mut_rptr(ccx.tcx(), ccx.tcx().mk_region(ty::ReStatic), fn_ty) ty::mk_mut_rptr(ccx.tcx(), ccx.tcx().mk_region(ty::ReStatic), fn_ty)
} }
ty::FnOnceUnboxedClosureKind => fn_ty ty::FnOnceClosureKind => fn_ty
} }
} }
pub fn kind_for_unboxed_closure(ccx: &CrateContext, closure_id: ast::DefId) pub fn kind_for_closure(ccx: &CrateContext, closure_id: ast::DefId) -> ty::ClosureKind {
-> ty::UnboxedClosureKind { ccx.tcx().closures.borrow()[closure_id].kind
let unboxed_closures = ccx.tcx().unboxed_closures.borrow();
(*unboxed_closures)[closure_id].kind
} }
pub fn decl_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, pub fn decl_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
@ -295,10 +293,10 @@ pub fn decl_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
ty::ty_bare_fn(_, ref f) => { ty::ty_bare_fn(_, ref f) => {
(&f.sig, f.abi, None) (&f.sig, f.abi, None)
} }
ty::ty_unboxed_closure(closure_did, _, substs) => { ty::ty_closure(closure_did, _, substs) => {
let typer = common::NormalizingUnboxedClosureTyper::new(ccx.tcx()); let typer = common::NormalizingClosureTyper::new(ccx.tcx());
function_type = typer.unboxed_closure_type(closure_did, substs); function_type = typer.closure_type(closure_did, substs);
let self_type = self_type_for_unboxed_closure(ccx, closure_did, fn_ty); let self_type = self_type_for_closure(ccx, closure_did, fn_ty);
let llenvironment_type = type_of_explicit_arg(ccx, self_type); let llenvironment_type = type_of_explicit_arg(ccx, self_type);
debug!("decl_rust_fn: function_type={} self_type={}", debug!("decl_rust_fn: function_type={} self_type={}",
function_type.repr(ccx.tcx()), function_type.repr(ccx.tcx()),
@ -715,10 +713,10 @@ pub fn iter_structural_ty<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
} }
}) })
} }
ty::ty_unboxed_closure(def_id, _, substs) => { ty::ty_closure(def_id, _, substs) => {
let repr = adt::represent_type(cx.ccx(), t); let repr = adt::represent_type(cx.ccx(), t);
let typer = common::NormalizingUnboxedClosureTyper::new(cx.tcx()); let typer = common::NormalizingClosureTyper::new(cx.tcx());
let upvars = typer.unboxed_closure_upvars(def_id, substs).unwrap(); let upvars = typer.closure_upvars(def_id, substs).unwrap();
for (i, upvar) in upvars.iter().enumerate() { for (i, upvar) in upvars.iter().enumerate() {
let llupvar = adt::trans_field_ptr(cx, &*repr, data_ptr, 0, i); let llupvar = adt::trans_field_ptr(cx, &*repr, data_ptr, 0, i);
cx = f(cx, llupvar, upvar.ty); cx = f(cx, llupvar, upvar.ty);
@ -1626,14 +1624,13 @@ fn copy_args_to_allocas<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
bcx bcx
} }
fn copy_unboxed_closure_args_to_allocas<'blk, 'tcx>( fn copy_closure_args_to_allocas<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
mut bcx: Block<'blk, 'tcx>,
arg_scope: cleanup::CustomScopeIndex, arg_scope: cleanup::CustomScopeIndex,
args: &[ast::Arg], args: &[ast::Arg],
arg_datums: Vec<RvalueDatum<'tcx>>, arg_datums: Vec<RvalueDatum<'tcx>>,
monomorphized_arg_types: &[Ty<'tcx>]) monomorphized_arg_types: &[Ty<'tcx>])
-> Block<'blk, 'tcx> { -> Block<'blk, 'tcx> {
let _icx = push_ctxt("copy_unboxed_closure_args_to_allocas"); let _icx = push_ctxt("copy_closure_args_to_allocas");
let arg_scope_id = cleanup::CustomScope(arg_scope); let arg_scope_id = cleanup::CustomScope(arg_scope);
assert_eq!(arg_datums.len(), 1); assert_eq!(arg_datums.len(), 1);
@ -1822,7 +1819,7 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
} }
// Tuple up closure argument types for the "rust-call" ABI. // Tuple up closure argument types for the "rust-call" ABI.
closure::UnboxedClosure(..) => { closure::Closure(..) => {
vec![ty::mk_tup(ccx.tcx(), monomorphized_arg_types)] vec![ty::mk_tup(ccx.tcx(), monomorphized_arg_types)]
} }
}; };
@ -1850,8 +1847,8 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
&decl.inputs[], &decl.inputs[],
arg_datums) arg_datums)
} }
closure::UnboxedClosure(..) => { closure::Closure(..) => {
copy_unboxed_closure_args_to_allocas( copy_closure_args_to_allocas(
bcx, bcx,
arg_scope, arg_scope,
&decl.inputs[], &decl.inputs[],
@ -2430,9 +2427,9 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
let function_type; let function_type;
let (fn_sig, abi, has_env) = match fn_ty.sty { let (fn_sig, abi, has_env) = match fn_ty.sty {
ty::ty_bare_fn(_, ref f) => (&f.sig, f.abi, false), ty::ty_bare_fn(_, ref f) => (&f.sig, f.abi, false),
ty::ty_unboxed_closure(closure_did, _, substs) => { ty::ty_closure(closure_did, _, substs) => {
let typer = common::NormalizingUnboxedClosureTyper::new(ccx.tcx()); let typer = common::NormalizingClosureTyper::new(ccx.tcx());
function_type = typer.unboxed_closure_type(closure_did, substs); function_type = typer.closure_type(closure_did, substs);
(&function_type.sig, RustCall, true) (&function_type.sig, RustCall, true)
} }
_ => ccx.sess().bug("expected closure or function.") _ => ccx.sess().bug("expected closure or function.")
@ -2449,7 +2446,7 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
// These have an odd calling convention, so we need to manually // These have an odd calling convention, so we need to manually
// unpack the input ty's // unpack the input ty's
let input_tys = match fn_ty.sty { let input_tys = match fn_ty.sty {
ty::ty_unboxed_closure(_, _, _) => { ty::ty_closure(_, _, _) => {
assert!(abi == RustCall); assert!(abi == RustCall);
match fn_sig.inputs[0].sty { match fn_sig.inputs[0].sty {

View file

@ -458,9 +458,7 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>(
}; };
// If this is an unboxed closure, redirect to it. // If this is an unboxed closure, redirect to it.
match closure::get_or_create_declaration_if_unboxed_closure(ccx, match closure::get_or_create_declaration_if_closure(ccx, def_id, &substs) {
def_id,
&substs) {
None => {} None => {}
Some(llfn) => return llfn, Some(llfn) => return llfn,
} }

View file

@ -23,7 +23,7 @@ use trans::debuginfo;
use trans::expr; use trans::expr;
use trans::monomorphize::{self, MonoId}; use trans::monomorphize::{self, MonoId};
use trans::type_of::*; use trans::type_of::*;
use middle::ty::{self, UnboxedClosureTyper}; use middle::ty::{self, ClosureTyper};
use middle::subst::{Substs}; use middle::subst::{Substs};
use session::config::FullDebugInfo; use session::config::FullDebugInfo;
@ -31,24 +31,23 @@ use syntax::ast;
use syntax::ast_util; use syntax::ast_util;
fn load_unboxed_closure_environment<'blk, 'tcx>( fn load_closure_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
bcx: Block<'blk, 'tcx>,
arg_scope_id: ScopeId, arg_scope_id: ScopeId,
freevar_mode: ast::CaptureClause, freevar_mode: ast::CaptureClause,
freevars: &[ty::Freevar]) freevars: &[ty::Freevar])
-> Block<'blk, 'tcx> { -> Block<'blk, 'tcx> {
let _icx = push_ctxt("closure::load_unboxed_closure_environment"); let _icx = push_ctxt("closure::load_closure_environment");
// Special case for small by-value selfs. // Special case for small by-value selfs.
let closure_id = ast_util::local_def(bcx.fcx.id); let closure_id = ast_util::local_def(bcx.fcx.id);
let self_type = self_type_for_unboxed_closure(bcx.ccx(), closure_id, let self_type = self_type_for_closure(bcx.ccx(), closure_id,
node_id_type(bcx, closure_id.node)); node_id_type(bcx, closure_id.node));
let kind = kind_for_unboxed_closure(bcx.ccx(), closure_id); let kind = kind_for_closure(bcx.ccx(), closure_id);
let llenv = if kind == ty::FnOnceUnboxedClosureKind && let llenv = if kind == ty::FnOnceClosureKind &&
!arg_is_indirect(bcx.ccx(), self_type) { !arg_is_indirect(bcx.ccx(), self_type) {
let datum = rvalue_scratch_datum(bcx, let datum = rvalue_scratch_datum(bcx,
self_type, self_type,
"unboxed_closure_env"); "closure_env");
store_ty(bcx, bcx.fcx.llenv.unwrap(), datum.val, self_type); store_ty(bcx, bcx.fcx.llenv.unwrap(), datum.val, self_type);
datum.val datum.val
} else { } else {
@ -77,7 +76,7 @@ fn load_unboxed_closure_environment<'blk, 'tcx>(
let def_id = freevar.def.def_id(); let def_id = freevar.def.def_id();
bcx.fcx.llupvars.borrow_mut().insert(def_id.node, upvar_ptr); bcx.fcx.llupvars.borrow_mut().insert(def_id.node, upvar_ptr);
if kind == ty::FnOnceUnboxedClosureKind && freevar_mode == ast::CaptureByValue { if kind == ty::FnOnceClosureKind && freevar_mode == ast::CaptureByValue {
bcx.fcx.schedule_drop_mem(arg_scope_id, bcx.fcx.schedule_drop_mem(arg_scope_id,
upvar_ptr, upvar_ptr,
node_id_type(bcx, def_id.node)) node_id_type(bcx, def_id.node))
@ -100,8 +99,8 @@ fn load_unboxed_closure_environment<'blk, 'tcx>(
#[derive(PartialEq)] #[derive(PartialEq)]
pub enum ClosureKind<'tcx> { pub enum ClosureKind<'tcx> {
NotClosure, NotClosure,
// See load_unboxed_closure_environment. // See load_closure_environment.
UnboxedClosure(ast::CaptureClause) Closure(ast::CaptureClause)
} }
pub struct ClosureEnv<'a, 'tcx> { pub struct ClosureEnv<'a, 'tcx> {
@ -127,8 +126,8 @@ impl<'a, 'tcx> ClosureEnv<'a, 'tcx> {
match self.kind { match self.kind {
NotClosure => bcx, NotClosure => bcx,
UnboxedClosure(freevar_mode) => { Closure(freevar_mode) => {
load_unboxed_closure_environment(bcx, arg_scope, freevar_mode, self.freevars) load_closure_environment(bcx, arg_scope, freevar_mode, self.freevars)
} }
} }
} }
@ -136,12 +135,12 @@ impl<'a, 'tcx> ClosureEnv<'a, 'tcx> {
/// Returns the LLVM function declaration for an unboxed closure, creating it /// Returns the LLVM function declaration for an unboxed closure, creating it
/// if necessary. If the ID does not correspond to a closure ID, returns None. /// if necessary. If the ID does not correspond to a closure ID, returns None.
pub fn get_or_create_declaration_if_unboxed_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, // Not an unboxed closure.
pub fn get_or_create_declaration_if_closure<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
closure_id: ast::DefId, closure_id: ast::DefId,
substs: &Substs<'tcx>) substs: &Substs<'tcx>)
-> Option<Datum<'tcx, Rvalue>> { -> Option<Datum<'tcx, Rvalue>> {
if !ccx.tcx().unboxed_closures.borrow().contains_key(&closure_id) { if !ccx.tcx().closures.borrow().contains_key(&closure_id) {
// Not an unboxed closure.
return None return None
} }
@ -152,7 +151,7 @@ pub fn get_or_create_declaration_if_unboxed_closure<'a, 'tcx>(ccx: &CrateContext
// duplicate declarations // duplicate declarations
let function_type = erase_regions(ccx.tcx(), &function_type); let function_type = erase_regions(ccx.tcx(), &function_type);
let params = match function_type.sty { let params = match function_type.sty {
ty::ty_unboxed_closure(_, _, ref substs) => substs.types.clone(), ty::ty_closure(_, _, ref substs) => substs.types.clone(),
_ => unreachable!() _ => unreachable!()
}; };
let mono_id = MonoId { let mono_id = MonoId {
@ -160,9 +159,9 @@ pub fn get_or_create_declaration_if_unboxed_closure<'a, 'tcx>(ccx: &CrateContext
params: params params: params
}; };
match ccx.unboxed_closure_vals().borrow().get(&mono_id) { match ccx.closure_vals().borrow().get(&mono_id) {
Some(&llfn) => { Some(&llfn) => {
debug!("get_or_create_declaration_if_unboxed_closure(): found \ debug!("get_or_create_declaration_if_closure(): found \
closure"); closure");
return Some(Datum::new(llfn, function_type, Rvalue::new(ByValue))) return Some(Datum::new(llfn, function_type, Rvalue::new(ByValue)))
} }
@ -170,7 +169,7 @@ pub fn get_or_create_declaration_if_unboxed_closure<'a, 'tcx>(ccx: &CrateContext
} }
let symbol = ccx.tcx().map.with_path(closure_id.node, |path| { let symbol = ccx.tcx().map.with_path(closure_id.node, |path| {
mangle_internal_name_by_path_and_seq(path, "unboxed_closure") mangle_internal_name_by_path_and_seq(path, "closure")
}); });
let llfn = decl_internal_rust_fn(ccx, function_type, &symbol[]); let llfn = decl_internal_rust_fn(ccx, function_type, &symbol[]);
@ -178,29 +177,28 @@ pub fn get_or_create_declaration_if_unboxed_closure<'a, 'tcx>(ccx: &CrateContext
// set an inline hint for all closures // set an inline hint for all closures
set_inline_hint(llfn); set_inline_hint(llfn);
debug!("get_or_create_declaration_if_unboxed_closure(): inserting new \ debug!("get_or_create_declaration_if_closure(): inserting new \
closure {:?} (type {})", closure {:?} (type {})",
mono_id, mono_id,
ccx.tn().type_to_string(val_ty(llfn))); ccx.tn().type_to_string(val_ty(llfn)));
ccx.unboxed_closure_vals().borrow_mut().insert(mono_id, llfn); ccx.closure_vals().borrow_mut().insert(mono_id, llfn);
Some(Datum::new(llfn, function_type, Rvalue::new(ByValue))) Some(Datum::new(llfn, function_type, Rvalue::new(ByValue)))
} }
pub fn trans_unboxed_closure<'blk, 'tcx>( pub fn trans_closure_expr<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
mut bcx: Block<'blk, 'tcx>,
decl: &ast::FnDecl, decl: &ast::FnDecl,
body: &ast::Block, body: &ast::Block,
id: ast::NodeId, id: ast::NodeId,
dest: expr::Dest) dest: expr::Dest)
-> Block<'blk, 'tcx> -> Block<'blk, 'tcx>
{ {
let _icx = push_ctxt("closure::trans_unboxed_closure"); let _icx = push_ctxt("closure::trans_closure");
debug!("trans_unboxed_closure()"); debug!("trans_closure()");
let closure_id = ast_util::local_def(id); let closure_id = ast_util::local_def(id);
let llfn = get_or_create_declaration_if_unboxed_closure( let llfn = get_or_create_declaration_if_closure(
bcx.ccx(), bcx.ccx(),
closure_id, closure_id,
bcx.fcx.param_substs).unwrap(); bcx.fcx.param_substs).unwrap();
@ -208,10 +206,10 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
// Get the type of this closure. Use the current `param_substs` as // Get the type of this closure. Use the current `param_substs` as
// the closure substitutions. This makes sense because the closure // the closure substitutions. This makes sense because the closure
// takes the same set of type arguments as the enclosing fn, and // takes the same set of type arguments as the enclosing fn, and
// this function (`trans_unboxed_closure`) is invoked at the point // this function (`trans_closure`) is invoked at the point
// of the closure expression. // of the closure expression.
let typer = NormalizingUnboxedClosureTyper::new(bcx.tcx()); let typer = NormalizingClosureTyper::new(bcx.tcx());
let function_type = typer.unboxed_closure_type(closure_id, bcx.fcx.param_substs); let function_type = typer.closure_type(closure_id, bcx.fcx.param_substs);
let freevars: Vec<ty::Freevar> = let freevars: Vec<ty::Freevar> =
ty::with_freevars(bcx.tcx(), id, |fv| fv.iter().map(|&fv| fv).collect()); ty::with_freevars(bcx.tcx(), id, |fv| fv.iter().map(|&fv| fv).collect());
@ -229,7 +227,7 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
sig.output, sig.output,
function_type.abi, function_type.abi,
ClosureEnv::new(&freevars[], ClosureEnv::new(&freevars[],
UnboxedClosure(freevar_mode))); Closure(freevar_mode)));
// Don't hoist this to the top of the function. It's perfectly legitimate // Don't hoist this to the top of the function. It's perfectly legitimate
// to have a zero-size unboxed closure (in which case dest will be // to have a zero-size unboxed closure (in which case dest will be
@ -237,7 +235,7 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
let dest_addr = match dest { let dest_addr = match dest {
expr::SaveIn(p) => p, expr::SaveIn(p) => p,
expr::Ignore => { expr::Ignore => {
debug!("trans_unboxed_closure() ignoring result"); debug!("trans_closure() ignoring result");
return bcx return bcx
} }
}; };

View file

@ -248,7 +248,7 @@ pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -
} }
match ty.sty { match ty.sty {
ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) | ty::ty_vec(_, Some(_)) | ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) | ty::ty_vec(_, Some(_)) |
ty::ty_unboxed_closure(..) => { ty::ty_closure(..) => {
let llty = sizing_type_of(ccx, ty); let llty = sizing_type_of(ccx, ty);
llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type()) llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type())
} }
@ -693,35 +693,32 @@ impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> {
} }
} }
impl<'blk, 'tcx> ty::UnboxedClosureTyper<'tcx> for BlockS<'blk, 'tcx> { impl<'blk, 'tcx> ty::ClosureTyper<'tcx> for BlockS<'blk, 'tcx> {
fn param_env<'a>(&'a self) -> &'a ty::ParameterEnvironment<'a, 'tcx> { fn param_env<'a>(&'a self) -> &'a ty::ParameterEnvironment<'a, 'tcx> {
&self.fcx.param_env &self.fcx.param_env
} }
fn unboxed_closure_kind(&self, fn closure_kind(&self, def_id: ast::DefId) -> ty::ClosureKind {
def_id: ast::DefId) let typer = NormalizingClosureTyper::new(self.tcx());
-> ty::UnboxedClosureKind typer.closure_kind(def_id)
{
let typer = NormalizingUnboxedClosureTyper::new(self.tcx());
typer.unboxed_closure_kind(def_id)
} }
fn unboxed_closure_type(&self, fn closure_type(&self,
def_id: ast::DefId, def_id: ast::DefId,
substs: &subst::Substs<'tcx>) substs: &subst::Substs<'tcx>)
-> ty::ClosureTy<'tcx> -> ty::ClosureTy<'tcx>
{ {
let typer = NormalizingUnboxedClosureTyper::new(self.tcx()); let typer = NormalizingClosureTyper::new(self.tcx());
typer.unboxed_closure_type(def_id, substs) typer.closure_type(def_id, substs)
} }
fn unboxed_closure_upvars(&self, fn closure_upvars(&self,
def_id: ast::DefId, def_id: ast::DefId,
substs: &Substs<'tcx>) substs: &Substs<'tcx>)
-> Option<Vec<ty::UnboxedClosureUpvar<'tcx>>> -> Option<Vec<ty::ClosureUpvar<'tcx>>>
{ {
let typer = NormalizingUnboxedClosureTyper::new(self.tcx()); let typer = NormalizingClosureTyper::new(self.tcx());
typer.unboxed_closure_upvars(def_id, substs) typer.closure_upvars(def_id, substs)
} }
} }
@ -1011,7 +1008,7 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
// Do the initial selection for the obligation. This yields the // Do the initial selection for the obligation. This yields the
// shallow result we are looking for -- that is, what specific impl. // shallow result we are looking for -- that is, what specific impl.
let typer = NormalizingUnboxedClosureTyper::new(tcx); let typer = NormalizingClosureTyper::new(tcx);
let mut selcx = traits::SelectionContext::new(&infcx, &typer); let mut selcx = traits::SelectionContext::new(&infcx, &typer);
let obligation = traits::Obligation::new(traits::ObligationCause::dummy(), let obligation = traits::Obligation::new(traits::ObligationCause::dummy(),
trait_ref.to_poly_trait_predicate()); trait_ref.to_poly_trait_predicate());
@ -1056,49 +1053,46 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
vtable vtable
} }
pub struct NormalizingUnboxedClosureTyper<'a,'tcx:'a> { pub struct NormalizingClosureTyper<'a,'tcx:'a> {
param_env: ty::ParameterEnvironment<'a, 'tcx> param_env: ty::ParameterEnvironment<'a, 'tcx>
} }
impl<'a,'tcx> NormalizingUnboxedClosureTyper<'a,'tcx> { impl<'a,'tcx> NormalizingClosureTyper<'a,'tcx> {
pub fn new(tcx: &'a ty::ctxt<'tcx>) -> NormalizingUnboxedClosureTyper<'a,'tcx> { pub fn new(tcx: &'a ty::ctxt<'tcx>) -> NormalizingClosureTyper<'a,'tcx> {
// Parameter environment is used to give details about type parameters, // Parameter environment is used to give details about type parameters,
// but since we are in trans, everything is fully monomorphized. // but since we are in trans, everything is fully monomorphized.
NormalizingUnboxedClosureTyper { param_env: ty::empty_parameter_environment(tcx) } NormalizingClosureTyper { param_env: ty::empty_parameter_environment(tcx) }
} }
} }
impl<'a,'tcx> ty::UnboxedClosureTyper<'tcx> for NormalizingUnboxedClosureTyper<'a,'tcx> { impl<'a,'tcx> ty::ClosureTyper<'tcx> for NormalizingClosureTyper<'a,'tcx> {
fn param_env<'b>(&'b self) -> &'b ty::ParameterEnvironment<'b,'tcx> { fn param_env<'b>(&'b self) -> &'b ty::ParameterEnvironment<'b,'tcx> {
&self.param_env &self.param_env
} }
fn unboxed_closure_kind(&self, fn closure_kind(&self, def_id: ast::DefId) -> ty::ClosureKind {
def_id: ast::DefId) self.param_env.tcx.closure_kind(def_id)
-> ty::UnboxedClosureKind
{
self.param_env.tcx.unboxed_closure_kind(def_id)
} }
fn unboxed_closure_type(&self, fn closure_type(&self,
def_id: ast::DefId, def_id: ast::DefId,
substs: &subst::Substs<'tcx>) substs: &subst::Substs<'tcx>)
-> ty::ClosureTy<'tcx> -> ty::ClosureTy<'tcx>
{ {
// the substitutions in `substs` are already monomorphized, // the substitutions in `substs` are already monomorphized,
// but we still must normalize associated types // but we still must normalize associated types
let closure_ty = self.param_env.tcx.unboxed_closure_type(def_id, substs); let closure_ty = self.param_env.tcx.closure_type(def_id, substs);
monomorphize::normalize_associated_type(self.param_env.tcx, &closure_ty) monomorphize::normalize_associated_type(self.param_env.tcx, &closure_ty)
} }
fn unboxed_closure_upvars(&self, fn closure_upvars(&self,
def_id: ast::DefId, def_id: ast::DefId,
substs: &Substs<'tcx>) substs: &Substs<'tcx>)
-> Option<Vec<ty::UnboxedClosureUpvar<'tcx>>> -> Option<Vec<ty::ClosureUpvar<'tcx>>>
{ {
// the substitutions in `substs` are already monomorphized, // the substitutions in `substs` are already monomorphized,
// but we still must normalize associated types // but we still must normalize associated types
let result = ty::unboxed_closure_upvars(&self.param_env, def_id, substs); let result = ty::closure_upvars(&self.param_env, def_id, substs);
monomorphize::normalize_associated_type(self.param_env.tcx, &result) monomorphize::normalize_associated_type(self.param_env.tcx, &result)
} }
} }
@ -1116,7 +1110,7 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(span: Span,
// In principle, we only need to do this so long as `result` // In principle, we only need to do this so long as `result`
// contains unbound type parameters. It could be a slight // contains unbound type parameters. It could be a slight
// optimization to stop iterating early. // optimization to stop iterating early.
let typer = NormalizingUnboxedClosureTyper::new(infcx.tcx); let typer = NormalizingClosureTyper::new(infcx.tcx);
match fulfill_cx.select_all_or_error(infcx, &typer) { match fulfill_cx.select_all_or_error(infcx, &typer) {
Ok(()) => { } Ok(()) => { }
Err(errors) => { Err(errors) => {

View file

@ -138,7 +138,7 @@ pub struct LocalCrateContext<'tcx> {
builder: BuilderRef_res, builder: BuilderRef_res,
/// Holds the LLVM values for closure IDs. /// Holds the LLVM values for closure IDs.
unboxed_closure_vals: RefCell<FnvHashMap<MonoId<'tcx>, ValueRef>>, closure_vals: RefCell<FnvHashMap<MonoId<'tcx>, ValueRef>>,
dbg_cx: Option<debuginfo::CrateDebugContext<'tcx>>, dbg_cx: Option<debuginfo::CrateDebugContext<'tcx>>,
@ -414,7 +414,7 @@ impl<'tcx> LocalCrateContext<'tcx> {
int_type: Type::from_ref(ptr::null_mut()), int_type: Type::from_ref(ptr::null_mut()),
opaque_vec_type: Type::from_ref(ptr::null_mut()), opaque_vec_type: Type::from_ref(ptr::null_mut()),
builder: BuilderRef_res(llvm::LLVMCreateBuilderInContext(llcx)), builder: BuilderRef_res(llvm::LLVMCreateBuilderInContext(llcx)),
unboxed_closure_vals: RefCell::new(FnvHashMap()), closure_vals: RefCell::new(FnvHashMap()),
dbg_cx: dbg_cx, dbg_cx: dbg_cx,
eh_personality: RefCell::new(None), eh_personality: RefCell::new(None),
intrinsics: RefCell::new(FnvHashMap()), intrinsics: RefCell::new(FnvHashMap()),
@ -684,8 +684,8 @@ impl<'b, 'tcx> CrateContext<'b, 'tcx> {
self.local.opaque_vec_type self.local.opaque_vec_type
} }
pub fn unboxed_closure_vals<'a>(&'a self) -> &'a RefCell<FnvHashMap<MonoId<'tcx>,ValueRef>> { pub fn closure_vals<'a>(&'a self) -> &'a RefCell<FnvHashMap<MonoId<'tcx>, ValueRef>> {
&self.local.unboxed_closure_vals &self.local.closure_vals
} }
pub fn dbg_cx<'a>(&'a self) -> &'a Option<debuginfo::CrateDebugContext<'tcx>> { pub fn dbg_cx<'a>(&'a self) -> &'a Option<debuginfo::CrateDebugContext<'tcx>> {

View file

@ -197,11 +197,11 @@ use metadata::csearch;
use middle::subst::{self, Substs}; use middle::subst::{self, Substs};
use trans::{self, adt, machine, type_of}; use trans::{self, adt, machine, type_of};
use trans::common::{self, NodeIdAndSpan, CrateContext, FunctionContext, Block, use trans::common::{self, NodeIdAndSpan, CrateContext, FunctionContext, Block,
C_bytes, C_i32, C_i64, NormalizingUnboxedClosureTyper}; C_bytes, C_i32, C_i64, NormalizingClosureTyper};
use trans::_match::{BindingInfo, TrByCopy, TrByMove, TrByRef}; use trans::_match::{BindingInfo, TrByCopy, TrByMove, TrByRef};
use trans::monomorphize; use trans::monomorphize;
use trans::type_::Type; use trans::type_::Type;
use middle::ty::{self, Ty, UnboxedClosureTyper}; use middle::ty::{self, Ty, ClosureTyper};
use middle::pat_util; use middle::pat_util;
use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo}; use session::config::{self, FullDebugInfo, LimitedDebugInfo, NoDebugInfo};
use util::nodemap::{DefIdMap, NodeMap, FnvHashMap, FnvHashSet}; use util::nodemap::{DefIdMap, NodeMap, FnvHashMap, FnvHashSet};
@ -472,9 +472,9 @@ impl<'tcx> TypeMap<'tcx> {
} }
} }
}, },
ty::ty_unboxed_closure(def_id, _, substs) => { ty::ty_closure(def_id, _, substs) => {
let typer = NormalizingUnboxedClosureTyper::new(cx.tcx()); let typer = NormalizingClosureTyper::new(cx.tcx());
let closure_ty = typer.unboxed_closure_type(def_id, substs); let closure_ty = typer.closure_type(def_id, substs);
self.get_unique_type_id_of_closure_type(cx, self.get_unique_type_id_of_closure_type(cx,
closure_ty, closure_ty,
&mut unique_type_id); &mut unique_type_id);
@ -3035,9 +3035,9 @@ fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
ty::ty_bare_fn(_, ref barefnty) => { ty::ty_bare_fn(_, ref barefnty) => {
subroutine_type_metadata(cx, unique_type_id, &barefnty.sig, usage_site_span) subroutine_type_metadata(cx, unique_type_id, &barefnty.sig, usage_site_span)
} }
ty::ty_unboxed_closure(def_id, _, substs) => { ty::ty_closure(def_id, _, substs) => {
let typer = NormalizingUnboxedClosureTyper::new(cx.tcx()); let typer = NormalizingClosureTyper::new(cx.tcx());
let sig = typer.unboxed_closure_type(def_id, substs).sig; let sig = typer.closure_type(def_id, substs).sig;
subroutine_type_metadata(cx, unique_type_id, &sig, usage_site_span) subroutine_type_metadata(cx, unique_type_id, &sig, usage_site_span)
} }
ty::ty_struct(def_id, substs) => { ty::ty_struct(def_id, substs) => {
@ -3888,7 +3888,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
} }
} }
}, },
ty::ty_unboxed_closure(..) => { ty::ty_closure(..) => {
output.push_str("closure"); output.push_str("closure");
} }
ty::ty_err | ty::ty_err |

View file

@ -1102,7 +1102,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
// closure or an older, legacy style closure. Store this // closure or an older, legacy style closure. Store this
// into a variable to ensure the the RefCell-lock is // into a variable to ensure the the RefCell-lock is
// released before we recurse. // released before we recurse.
closure::trans_unboxed_closure(bcx, &**decl, &**body, expr.id, dest) closure::trans_closure_expr(bcx, &**decl, &**body, expr.id, dest)
} }
ast::ExprCall(ref f, ref args) => { ast::ExprCall(ref f, ref args) => {
if bcx.tcx().is_method_call(expr.id) { if bcx.tcx().is_method_call(expr.id) {

View file

@ -438,7 +438,7 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: Ty<'tcx>)
} }
} }
} }
ty::ty_unboxed_closure(..) => { ty::ty_closure(..) => {
iter_structural_ty(bcx, iter_structural_ty(bcx,
v0, v0,
t, t,

View file

@ -120,7 +120,7 @@ pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
match origin { match origin {
ty::MethodStatic(did) | ty::MethodStatic(did) |
ty::MethodStaticUnboxedClosure(did) => { ty::MethodStaticClosure(did) => {
Callee { Callee {
bcx: bcx, bcx: bcx,
data: Fn(callee::trans_fn_ref(bcx.ccx(), data: Fn(callee::trans_fn_ref(bcx.ccx(),
@ -365,7 +365,7 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
Callee { bcx: bcx, data: Fn(llfn) } Callee { bcx: bcx, data: Fn(llfn) }
} }
traits::VtableUnboxedClosure(closure_def_id, substs) => { traits::VtableClosure(closure_def_id, substs) => {
// The substitutions should have no type parameters remaining // The substitutions should have no type parameters remaining
// after passing through fulfill_obligation // after passing through fulfill_obligation
let llfn = trans_fn_ref_with_substs(bcx.ccx(), let llfn = trans_fn_ref_with_substs(bcx.ccx(),
@ -727,7 +727,7 @@ pub fn get_vtable<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
nested: _ }) => { nested: _ }) => {
emit_vtable_methods(bcx, id, substs).into_iter() emit_vtable_methods(bcx, id, substs).into_iter()
} }
traits::VtableUnboxedClosure(closure_def_id, substs) => { traits::VtableClosure(closure_def_id, substs) => {
let llfn = trans_fn_ref_with_substs( let llfn = trans_fn_ref_with_substs(
bcx.ccx(), bcx.ccx(),
closure_def_id, closure_def_id,

View file

@ -322,7 +322,7 @@ pub fn normalize_associated_type<'tcx,T>(tcx: &ty::ctxt<'tcx>, value: &T) -> T
// FIXME(#20304) -- cache // FIXME(#20304) -- cache
let infcx = infer::new_infer_ctxt(tcx); let infcx = infer::new_infer_ctxt(tcx);
let typer = NormalizingUnboxedClosureTyper::new(tcx); let typer = NormalizingClosureTyper::new(tcx);
let mut selcx = traits::SelectionContext::new(&infcx, &typer); let mut selcx = traits::SelectionContext::new(&infcx, &typer);
let cause = traits::ObligationCause::dummy(); let cause = traits::ObligationCause::dummy();
let traits::Normalized { value: result, obligations } = let traits::Normalized { value: result, obligations } =

View file

@ -211,7 +211,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
Type::nil(cx) Type::nil(cx)
} }
ty::ty_tup(..) | ty::ty_enum(..) | ty::ty_unboxed_closure(..) => { ty::ty_tup(..) | ty::ty_enum(..) | ty::ty_closure(..) => {
let repr = adt::represent_type(cx, t); let repr = adt::represent_type(cx, t);
adt::sizing_type_of(cx, &*repr, false) adt::sizing_type_of(cx, &*repr, false)
} }
@ -330,7 +330,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
let name = llvm_type_name(cx, an_enum, did, tps); let name = llvm_type_name(cx, an_enum, did, tps);
adt::incomplete_type_of(cx, &*repr, &name[]) adt::incomplete_type_of(cx, &*repr, &name[])
} }
ty::ty_unboxed_closure(did, _, ref substs) => { ty::ty_closure(did, _, ref substs) => {
// Only create the named struct, but don't fill it in. We // Only create the named struct, but don't fill it in. We
// fill it in *after* placing it into the type cache. // fill it in *after* placing it into the type cache.
let repr = adt::represent_type(cx, t); let repr = adt::represent_type(cx, t);
@ -338,7 +338,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
// inherited from their environment, so we use entire // inherited from their environment, so we use entire
// contents of the VecPerParamSpace to to construct the llvm // contents of the VecPerParamSpace to to construct the llvm
// name // name
let name = llvm_type_name(cx, an_unboxed_closure, did, substs.types.as_slice()); let name = llvm_type_name(cx, a_closure, did, substs.types.as_slice());
adt::incomplete_type_of(cx, &*repr, &name[]) adt::incomplete_type_of(cx, &*repr, &name[])
} }
@ -432,7 +432,7 @@ pub fn type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Type {
// If this was an enum or struct, fill in the type now. // If this was an enum or struct, fill in the type now.
match t.sty { match t.sty {
ty::ty_enum(..) | ty::ty_struct(..) | ty::ty_unboxed_closure(..) ty::ty_enum(..) | ty::ty_struct(..) | ty::ty_closure(..)
if !ty::type_is_simd(cx.tcx(), t) => { if !ty::type_is_simd(cx.tcx(), t) => {
let repr = adt::represent_type(cx, t); let repr = adt::represent_type(cx, t);
adt::finish_type_of(cx, &*repr, &mut llty); adt::finish_type_of(cx, &*repr, &mut llty);
@ -454,7 +454,7 @@ pub fn align_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>)
pub enum named_ty { pub enum named_ty {
a_struct, a_struct,
an_enum, an_enum,
an_unboxed_closure, a_closure,
} }
pub fn llvm_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, pub fn llvm_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
@ -465,7 +465,7 @@ pub fn llvm_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
let name = match what { let name = match what {
a_struct => "struct", a_struct => "struct",
an_enum => "enum", an_enum => "enum",
an_unboxed_closure => return "closure".to_string(), a_closure => return "closure".to_string(),
}; };
let base = ty::item_path_str(cx.tcx(), did); let base = ty::item_path_str(cx.tcx(), did);

View file

@ -18,7 +18,7 @@ use syntax::codemap::Span;
use util::ppaux::Repr; use util::ppaux::Repr;
pub fn normalize_associated_types_in<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>, pub fn normalize_associated_types_in<'a,'tcx,T>(infcx: &InferCtxt<'a,'tcx>,
typer: &(ty::UnboxedClosureTyper<'tcx>+'a), typer: &(ty::ClosureTyper<'tcx>+'a),
fulfillment_cx: &mut FulfillmentContext<'tcx>, fulfillment_cx: &mut FulfillmentContext<'tcx>,
span: Span, span: Span,
body_id: ast::NodeId, body_id: ast::NodeId,

View file

@ -25,7 +25,7 @@ use util::ppaux::Repr;
pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
expr: &ast::Expr, expr: &ast::Expr,
_capture: ast::CaptureClause, _capture: ast::CaptureClause,
opt_kind: Option<ast::UnboxedClosureKind>, opt_kind: Option<ast::ClosureKind>,
decl: &ast::FnDecl, decl: &ast::FnDecl,
body: &ast::Block, body: &ast::Block,
expected: Expectation<'tcx>) { expected: Expectation<'tcx>) {
@ -34,7 +34,7 @@ pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
expected.repr(fcx.tcx())); expected.repr(fcx.tcx()));
let expected_sig_and_kind = expected.to_option(fcx).and_then(|ty| { let expected_sig_and_kind = expected.to_option(fcx).and_then(|ty| {
deduce_unboxed_closure_expectations_from_expected_type(fcx, ty) deduce_closure_expectations_from_expected_type(fcx, ty)
}); });
match opt_kind { match opt_kind {
@ -46,42 +46,42 @@ pub fn check_expr_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
match expected_sig_and_kind { match expected_sig_and_kind {
None => { // don't have information about the kind, request explicit annotation None => { // don't have information about the kind, request explicit annotation
// NB We still need to typeck the body, so assume `FnMut` kind just for that // NB We still need to typeck the body, so assume `FnMut` kind just for that
let kind = ty::FnMutUnboxedClosureKind; let kind = ty::FnMutClosureKind;
check_unboxed_closure(fcx, expr, kind, decl, body, None); check_closure(fcx, expr, kind, decl, body, None);
span_err!(fcx.ccx.tcx.sess, expr.span, E0187, span_err!(fcx.ccx.tcx.sess, expr.span, E0187,
"can't infer the \"kind\" of the closure; explicitly annotate it; e.g. \ "can't infer the \"kind\" of the closure; explicitly annotate it; e.g. \
`|&:| {{}}`"); `|&:| {{}}`");
}, },
Some((sig, kind)) => { Some((sig, kind)) => {
check_unboxed_closure(fcx, expr, kind, decl, body, Some(sig)); check_closure(fcx, expr, kind, decl, body, Some(sig));
} }
} }
} }
Some(kind) => { Some(kind) => {
let kind = match kind { let kind = match kind {
ast::FnUnboxedClosureKind => ty::FnUnboxedClosureKind, ast::FnClosureKind => ty::FnClosureKind,
ast::FnMutUnboxedClosureKind => ty::FnMutUnboxedClosureKind, ast::FnMutClosureKind => ty::FnMutClosureKind,
ast::FnOnceUnboxedClosureKind => ty::FnOnceUnboxedClosureKind, ast::FnOnceClosureKind => ty::FnOnceClosureKind,
}; };
let expected_sig = expected_sig_and_kind.map(|t| t.0); let expected_sig = expected_sig_and_kind.map(|t| t.0);
check_unboxed_closure(fcx, expr, kind, decl, body, expected_sig); check_closure(fcx, expr, kind, decl, body, expected_sig);
} }
} }
} }
fn check_unboxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>, fn check_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
expr: &ast::Expr, expr: &ast::Expr,
kind: ty::UnboxedClosureKind, kind: ty::ClosureKind,
decl: &ast::FnDecl, decl: &ast::FnDecl,
body: &ast::Block, body: &ast::Block,
expected_sig: Option<ty::FnSig<'tcx>>) { expected_sig: Option<ty::FnSig<'tcx>>) {
let expr_def_id = ast_util::local_def(expr.id); let expr_def_id = ast_util::local_def(expr.id);
debug!("check_unboxed_closure kind={:?} expected_sig={}", debug!("check_closure kind={:?} expected_sig={}",
kind, kind,
expected_sig.repr(fcx.tcx())); expected_sig.repr(fcx.tcx()));
@ -100,7 +100,7 @@ fn check_unboxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
Ok(regions) => regions[0], Ok(regions) => regions[0],
}; };
let closure_type = ty::mk_unboxed_closure(fcx.ccx.tcx, let closure_type = ty::mk_closure(fcx.ccx.tcx,
expr_def_id, expr_def_id,
fcx.ccx.tcx.mk_region(region), fcx.ccx.tcx.mk_region(region),
fcx.ccx.tcx.mk_substs( fcx.ccx.tcx.mk_substs(
@ -121,39 +121,36 @@ fn check_unboxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
fcx.inh); fcx.inh);
// Tuple up the arguments and insert the resulting function type into // Tuple up the arguments and insert the resulting function type into
// the `unboxed_closures` table. // the `closures` table.
fn_ty.sig.0.inputs = vec![ty::mk_tup(fcx.tcx(), fn_ty.sig.0.inputs)]; fn_ty.sig.0.inputs = vec![ty::mk_tup(fcx.tcx(), fn_ty.sig.0.inputs)];
debug!("unboxed_closure for {} --> sig={} kind={:?}", debug!("closure for {} --> sig={} kind={:?}",
expr_def_id.repr(fcx.tcx()), expr_def_id.repr(fcx.tcx()),
fn_ty.sig.repr(fcx.tcx()), fn_ty.sig.repr(fcx.tcx()),
kind); kind);
let unboxed_closure = ty::UnboxedClosure { let closure = ty::Closure {
closure_type: fn_ty, closure_type: fn_ty,
kind: kind, kind: kind,
}; };
fcx.inh fcx.inh.closures.borrow_mut().insert(expr_def_id, closure);
.unboxed_closures
.borrow_mut()
.insert(expr_def_id, unboxed_closure);
} }
fn deduce_unboxed_closure_expectations_from_expected_type<'a,'tcx>( fn deduce_closure_expectations_from_expected_type<'a,'tcx>(
fcx: &FnCtxt<'a,'tcx>, fcx: &FnCtxt<'a,'tcx>,
expected_ty: Ty<'tcx>) expected_ty: Ty<'tcx>)
-> Option<(ty::FnSig<'tcx>,ty::UnboxedClosureKind)> -> Option<(ty::FnSig<'tcx>,ty::ClosureKind)>
{ {
match expected_ty.sty { match expected_ty.sty {
ty::ty_trait(ref object_type) => { ty::ty_trait(ref object_type) => {
let trait_ref = let trait_ref =
object_type.principal_trait_ref_with_self_ty(fcx.tcx(), object_type.principal_trait_ref_with_self_ty(fcx.tcx(),
fcx.tcx().types.err); fcx.tcx().types.err);
deduce_unboxed_closure_expectations_from_trait_ref(fcx, &trait_ref) deduce_closure_expectations_from_trait_ref(fcx, &trait_ref)
} }
ty::ty_infer(ty::TyVar(vid)) => { ty::ty_infer(ty::TyVar(vid)) => {
deduce_unboxed_closure_expectations_from_obligations(fcx, vid) deduce_closure_expectations_from_obligations(fcx, vid)
} }
_ => { _ => {
None None
@ -161,14 +158,14 @@ fn deduce_unboxed_closure_expectations_from_expected_type<'a,'tcx>(
} }
} }
fn deduce_unboxed_closure_expectations_from_trait_ref<'a,'tcx>( fn deduce_closure_expectations_from_trait_ref<'a,'tcx>(
fcx: &FnCtxt<'a,'tcx>, fcx: &FnCtxt<'a,'tcx>,
trait_ref: &ty::PolyTraitRef<'tcx>) trait_ref: &ty::PolyTraitRef<'tcx>)
-> Option<(ty::FnSig<'tcx>, ty::UnboxedClosureKind)> -> Option<(ty::FnSig<'tcx>, ty::ClosureKind)>
{ {
let tcx = fcx.tcx(); let tcx = fcx.tcx();
debug!("deduce_unboxed_closure_expectations_from_object_type({})", debug!("deduce_closure_expectations_from_object_type({})",
trait_ref.repr(tcx)); trait_ref.repr(tcx));
let kind = match tcx.lang_items.fn_trait_kind(trait_ref.def_id()) { let kind = match tcx.lang_items.fn_trait_kind(trait_ref.def_id()) {
@ -202,10 +199,10 @@ fn deduce_unboxed_closure_expectations_from_trait_ref<'a,'tcx>(
return Some((fn_sig, kind)); return Some((fn_sig, kind));
} }
fn deduce_unboxed_closure_expectations_from_obligations<'a,'tcx>( fn deduce_closure_expectations_from_obligations<'a,'tcx>(
fcx: &FnCtxt<'a,'tcx>, fcx: &FnCtxt<'a,'tcx>,
expected_vid: ty::TyVid) expected_vid: ty::TyVid)
-> Option<(ty::FnSig<'tcx>, ty::UnboxedClosureKind)> -> Option<(ty::FnSig<'tcx>, ty::ClosureKind)>
{ {
// Here `expected_ty` is known to be a type inference variable. // Here `expected_ty` is known to be a type inference variable.
for obligation in fcx.inh.fulfillment_cx.borrow().pending_obligations().iter() { for obligation in fcx.inh.fulfillment_cx.borrow().pending_obligations().iter() {
@ -218,7 +215,7 @@ fn deduce_unboxed_closure_expectations_from_obligations<'a,'tcx>(
_ => { continue; } _ => { continue; }
} }
match deduce_unboxed_closure_expectations_from_trait_ref(fcx, &trait_ref) { match deduce_closure_expectations_from_trait_ref(fcx, &trait_ref) {
Some(e) => { return Some(e); } Some(e) => { return Some(e); }
None => { } None => { }
} }

View file

@ -62,7 +62,7 @@ enum CandidateKind<'tcx> {
ObjectCandidate(/* Trait */ ast::DefId, /* method_num */ uint, /* real_index */ uint), ObjectCandidate(/* Trait */ ast::DefId, /* method_num */ uint, /* real_index */ uint),
ExtensionImplCandidate(/* Impl */ ast::DefId, Rc<ty::TraitRef<'tcx>>, ExtensionImplCandidate(/* Impl */ ast::DefId, Rc<ty::TraitRef<'tcx>>,
subst::Substs<'tcx>, MethodIndex), subst::Substs<'tcx>, MethodIndex),
UnboxedClosureCandidate(/* Trait */ ast::DefId, MethodIndex), ClosureCandidate(/* Trait */ ast::DefId, MethodIndex),
WhereClauseCandidate(ty::PolyTraitRef<'tcx>, MethodIndex), WhereClauseCandidate(ty::PolyTraitRef<'tcx>, MethodIndex),
ProjectionCandidate(ast::DefId, MethodIndex), ProjectionCandidate(ast::DefId, MethodIndex),
} }
@ -249,7 +249,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
} }
ty::ty_enum(did, _) | ty::ty_enum(did, _) |
ty::ty_struct(did, _) | ty::ty_struct(did, _) |
ty::ty_unboxed_closure(did, _, _) => { ty::ty_closure(did, _, _) => {
self.assemble_inherent_impl_candidates_for_type(did); self.assemble_inherent_impl_candidates_for_type(did);
} }
ty::ty_param(p) => { ty::ty_param(p) => {
@ -494,7 +494,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
method.clone(), method.clone(),
matching_index); matching_index);
self.assemble_unboxed_closure_candidates(trait_def_id, self.assemble_closure_candidates(trait_def_id,
method.clone(), method.clone(),
matching_index); matching_index);
@ -571,7 +571,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
simplified_steps.contains(&impl_simplified_type) simplified_steps.contains(&impl_simplified_type)
} }
fn assemble_unboxed_closure_candidates(&mut self, fn assemble_closure_candidates(&mut self,
trait_def_id: ast::DefId, trait_def_id: ast::DefId,
method_ty: Rc<ty::Method<'tcx>>, method_ty: Rc<ty::Method<'tcx>>,
method_index: uint) method_index: uint)
@ -579,11 +579,11 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
// Check if this is one of the Fn,FnMut,FnOnce traits. // Check if this is one of the Fn,FnMut,FnOnce traits.
let tcx = self.tcx(); let tcx = self.tcx();
let kind = if Some(trait_def_id) == tcx.lang_items.fn_trait() { let kind = if Some(trait_def_id) == tcx.lang_items.fn_trait() {
ty::FnUnboxedClosureKind ty::FnClosureKind
} else if Some(trait_def_id) == tcx.lang_items.fn_mut_trait() { } else if Some(trait_def_id) == tcx.lang_items.fn_mut_trait() {
ty::FnMutUnboxedClosureKind ty::FnMutClosureKind
} else if Some(trait_def_id) == tcx.lang_items.fn_once_trait() { } else if Some(trait_def_id) == tcx.lang_items.fn_once_trait() {
ty::FnOnceUnboxedClosureKind ty::FnOnceClosureKind
} else { } else {
return; return;
}; };
@ -593,12 +593,12 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
let steps = self.steps.clone(); let steps = self.steps.clone();
for step in steps.iter() { for step in steps.iter() {
let (closure_def_id, _, _) = match step.self_ty.sty { let (closure_def_id, _, _) = match step.self_ty.sty {
ty::ty_unboxed_closure(a, b, ref c) => (a, b, c), ty::ty_closure(a, b, ref c) => (a, b, c),
_ => continue, _ => continue,
}; };
let unboxed_closures = self.fcx.inh.unboxed_closures.borrow(); let closures = self.fcx.inh.closures.borrow();
let closure_data = match unboxed_closures.get(&closure_def_id) { let closure_data = match closures.get(&closure_def_id) {
Some(data) => data, Some(data) => data,
None => { None => {
self.tcx().sess.span_bug( self.tcx().sess.span_bug(
@ -626,7 +626,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
self.inherent_candidates.push(Candidate { self.inherent_candidates.push(Candidate {
xform_self_ty: xform_self_ty, xform_self_ty: xform_self_ty,
method_ty: method_ty.clone(), method_ty: method_ty.clone(),
kind: UnboxedClosureCandidate(trait_def_id, method_index) kind: ClosureCandidate(trait_def_id, method_index)
}); });
} }
} }
@ -950,7 +950,7 @@ impl<'a,'tcx> ProbeContext<'a,'tcx> {
ProjectionCandidate(..) | ProjectionCandidate(..) |
ObjectCandidate(..) | ObjectCandidate(..) |
UnboxedClosureCandidate(..) | ClosureCandidate(..) |
WhereClauseCandidate(..) => { WhereClauseCandidate(..) => {
// These have no additional conditions to check. // These have no additional conditions to check.
true true
@ -1173,7 +1173,7 @@ impl<'tcx> Candidate<'tcx> {
ExtensionImplCandidate(def_id, _, _, index) => { ExtensionImplCandidate(def_id, _, _, index) => {
ExtensionImplPick(def_id, index) ExtensionImplPick(def_id, index)
} }
UnboxedClosureCandidate(trait_def_id, index) => { ClosureCandidate(trait_def_id, index) => {
TraitPick(trait_def_id, index) TraitPick(trait_def_id, index)
} }
WhereClauseCandidate(ref trait_ref, index) => { WhereClauseCandidate(ref trait_ref, index) => {
@ -1198,7 +1198,7 @@ impl<'tcx> Candidate<'tcx> {
InherentImplCandidate(def_id, _) => ImplSource(def_id), InherentImplCandidate(def_id, _) => ImplSource(def_id),
ObjectCandidate(def_id, _, _) => TraitSource(def_id), ObjectCandidate(def_id, _, _) => TraitSource(def_id),
ExtensionImplCandidate(def_id, _, _, _) => ImplSource(def_id), ExtensionImplCandidate(def_id, _, _, _) => ImplSource(def_id),
UnboxedClosureCandidate(trait_def_id, _) => TraitSource(trait_def_id), ClosureCandidate(trait_def_id, _) => TraitSource(trait_def_id),
WhereClauseCandidate(ref trait_ref, _) => TraitSource(trait_ref.def_id()), WhereClauseCandidate(ref trait_ref, _) => TraitSource(trait_ref.def_id()),
ProjectionCandidate(trait_def_id, _) => TraitSource(trait_def_id), ProjectionCandidate(trait_def_id, _) => TraitSource(trait_def_id),
} }
@ -1210,7 +1210,7 @@ impl<'tcx> Candidate<'tcx> {
ObjectCandidate(..) => { ObjectCandidate(..) => {
None None
} }
UnboxedClosureCandidate(trait_def_id, method_num) => { ClosureCandidate(trait_def_id, method_num) => {
Some((trait_def_id, method_num)) Some((trait_def_id, method_num))
} }
ExtensionImplCandidate(_, ref trait_ref, _, method_num) => { ExtensionImplCandidate(_, ref trait_ref, _, method_num) => {
@ -1244,8 +1244,8 @@ impl<'tcx> Repr<'tcx> for CandidateKind<'tcx> {
ExtensionImplCandidate(ref a, ref b, ref c, ref d) => ExtensionImplCandidate(ref a, ref b, ref c, ref d) =>
format!("ExtensionImplCandidate({},{},{},{})", a.repr(tcx), b.repr(tcx), format!("ExtensionImplCandidate({},{},{},{})", a.repr(tcx), b.repr(tcx),
c.repr(tcx), d), c.repr(tcx), d),
UnboxedClosureCandidate(ref a, ref b) => ClosureCandidate(ref a, ref b) =>
format!("UnboxedClosureCandidate({},{})", a.repr(tcx), b), format!("ClosureCandidate({},{})", a.repr(tcx), b),
WhereClauseCandidate(ref a, ref b) => WhereClauseCandidate(ref a, ref b) =>
format!("WhereClauseCandidate({},{})", a.repr(tcx), b), format!("WhereClauseCandidate({},{})", a.repr(tcx), b),
ProjectionCandidate(ref a, ref b) => ProjectionCandidate(ref a, ref b) =>

View file

@ -160,7 +160,7 @@ pub struct Inherited<'a, 'tcx: 'a> {
adjustments: RefCell<NodeMap<ty::AutoAdjustment<'tcx>>>, adjustments: RefCell<NodeMap<ty::AutoAdjustment<'tcx>>>,
method_map: MethodMap<'tcx>, method_map: MethodMap<'tcx>,
upvar_borrow_map: RefCell<ty::UpvarBorrowMap>, upvar_borrow_map: RefCell<ty::UpvarBorrowMap>,
unboxed_closures: RefCell<DefIdMap<ty::UnboxedClosure<'tcx>>>, closures: RefCell<DefIdMap<ty::Closure<'tcx>>>,
object_cast_map: ObjectCastMap<'tcx>, object_cast_map: ObjectCastMap<'tcx>,
// A mapping from each fn's id to its signature, with all bound // A mapping from each fn's id to its signature, with all bound
@ -338,32 +338,29 @@ impl<'a, 'tcx> mc::Typer<'tcx> for FnCtxt<'a, 'tcx> {
} }
} }
impl<'a, 'tcx> ty::UnboxedClosureTyper<'tcx> for FnCtxt<'a, 'tcx> { impl<'a, 'tcx> ty::ClosureTyper<'tcx> for FnCtxt<'a, 'tcx> {
fn param_env<'b>(&'b self) -> &'b ty::ParameterEnvironment<'b,'tcx> { fn param_env<'b>(&'b self) -> &'b ty::ParameterEnvironment<'b,'tcx> {
&self.inh.param_env &self.inh.param_env
} }
fn unboxed_closure_kind(&self, fn closure_kind(&self, def_id: ast::DefId) -> ty::ClosureKind {
def_id: ast::DefId) self.inh.closures.borrow()[def_id].kind
-> ty::UnboxedClosureKind
{
self.inh.unboxed_closures.borrow()[def_id].kind
} }
fn unboxed_closure_type(&self, fn closure_type(&self,
def_id: ast::DefId, def_id: ast::DefId,
substs: &subst::Substs<'tcx>) substs: &subst::Substs<'tcx>)
-> ty::ClosureTy<'tcx> -> ty::ClosureTy<'tcx>
{ {
self.inh.unboxed_closures.borrow()[def_id].closure_type.subst(self.tcx(), substs) self.inh.closures.borrow()[def_id].closure_type.subst(self.tcx(), substs)
} }
fn unboxed_closure_upvars(&self, fn closure_upvars(&self,
def_id: ast::DefId, def_id: ast::DefId,
substs: &Substs<'tcx>) substs: &Substs<'tcx>)
-> Option<Vec<ty::UnboxedClosureUpvar<'tcx>>> -> Option<Vec<ty::ClosureUpvar<'tcx>>>
{ {
ty::unboxed_closure_upvars(self, def_id, substs) ty::closure_upvars(self, def_id, substs)
} }
} }
@ -381,14 +378,14 @@ impl<'a, 'tcx> Inherited<'a, 'tcx> {
method_map: RefCell::new(FnvHashMap()), method_map: RefCell::new(FnvHashMap()),
object_cast_map: RefCell::new(NodeMap()), object_cast_map: RefCell::new(NodeMap()),
upvar_borrow_map: RefCell::new(FnvHashMap()), upvar_borrow_map: RefCell::new(FnvHashMap()),
unboxed_closures: RefCell::new(DefIdMap()), closures: RefCell::new(DefIdMap()),
fn_sig_map: RefCell::new(NodeMap()), fn_sig_map: RefCell::new(NodeMap()),
fulfillment_cx: RefCell::new(traits::FulfillmentContext::new()), fulfillment_cx: RefCell::new(traits::FulfillmentContext::new()),
} }
} }
fn normalize_associated_types_in<T>(&self, fn normalize_associated_types_in<T>(&self,
typer: &ty::UnboxedClosureTyper<'tcx>, typer: &ty::ClosureTyper<'tcx>,
span: Span, span: Span,
body_id: ast::NodeId, body_id: ast::NodeId,
value: &T) value: &T)

View file

@ -748,7 +748,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
let function_type = rcx.resolve_node_type(expr.id); let function_type = rcx.resolve_node_type(expr.id);
match function_type.sty { match function_type.sty {
ty::ty_unboxed_closure(_, region, _) => { ty::ty_closure(_, region, _) => {
if tcx.capture_modes.borrow()[expr.id].clone() == ast::CaptureByRef { if tcx.capture_modes.borrow()[expr.id].clone() == ast::CaptureByRef {
ty::with_freevars(tcx, expr.id, |freevars| { ty::with_freevars(tcx, expr.id, |freevars| {
if !freevars.is_empty() { if !freevars.is_empty() {
@ -768,7 +768,7 @@ fn check_expr_fn_block(rcx: &mut Rcx,
rcx.set_repeating_scope(repeating_scope); rcx.set_repeating_scope(repeating_scope);
match function_type.sty { match function_type.sty {
ty::ty_unboxed_closure(_, region, _) => { ty::ty_closure(_, region, _) => {
ty::with_freevars(tcx, expr.id, |freevars| { ty::with_freevars(tcx, expr.id, |freevars| {
let bounds = ty::region_existential_bound(*region); let bounds = ty::region_existential_bound(*region);
ensure_free_variable_types_outlive_closure_bound(rcx, &bounds, expr, freevars); ensure_free_variable_types_outlive_closure_bound(rcx, &bounds, expr, freevars);

View file

@ -68,7 +68,7 @@ impl<'a, 'tcx> Wf<'a, 'tcx> {
// No borrowed content reachable here. // No borrowed content reachable here.
} }
ty::ty_unboxed_closure(_, region, _) => { ty::ty_closure(_, region, _) => {
// An "unboxed closure type" is basically // An "unboxed closure type" is basically
// modeled here as equivalent to a struct like // modeled here as equivalent to a struct like
// //

View file

@ -39,7 +39,7 @@ pub fn resolve_type_vars_in_expr(fcx: &FnCtxt, e: &ast::Expr) {
let mut wbcx = WritebackCx::new(fcx); let mut wbcx = WritebackCx::new(fcx);
wbcx.visit_expr(e); wbcx.visit_expr(e);
wbcx.visit_upvar_borrow_map(); wbcx.visit_upvar_borrow_map();
wbcx.visit_unboxed_closures(); wbcx.visit_closures();
wbcx.visit_object_cast_map(); wbcx.visit_object_cast_map();
} }
@ -60,7 +60,7 @@ pub fn resolve_type_vars_in_fn(fcx: &FnCtxt,
} }
} }
wbcx.visit_upvar_borrow_map(); wbcx.visit_upvar_borrow_map();
wbcx.visit_unboxed_closures(); wbcx.visit_closures();
wbcx.visit_object_cast_map(); wbcx.visit_object_cast_map();
} }
@ -195,27 +195,19 @@ impl<'cx, 'tcx> WritebackCx<'cx, 'tcx> {
} }
} }
fn visit_unboxed_closures(&self) { fn visit_closures(&self) {
if self.fcx.writeback_errors.get() { if self.fcx.writeback_errors.get() {
return return
} }
for (def_id, unboxed_closure) in self.fcx for (def_id, closure) in self.fcx.inh.closures.borrow().iter() {
.inh let closure_ty = self.resolve(&closure.closure_type,
.unboxed_closures ResolvingClosure(*def_id));
.borrow() let closure = ty::Closure {
.iter() {
let closure_ty = self.resolve(&unboxed_closure.closure_type,
ResolvingUnboxedClosure(*def_id));
let unboxed_closure = ty::UnboxedClosure {
closure_type: closure_ty, closure_type: closure_ty,
kind: unboxed_closure.kind, kind: closure.kind,
}; };
self.fcx self.fcx.tcx().closures.borrow_mut().insert(*def_id, closure);
.tcx()
.unboxed_closures
.borrow_mut()
.insert(*def_id, unboxed_closure);
} }
} }
@ -331,7 +323,7 @@ enum ResolveReason {
ResolvingLocal(Span), ResolvingLocal(Span),
ResolvingPattern(Span), ResolvingPattern(Span),
ResolvingUpvar(ty::UpvarId), ResolvingUpvar(ty::UpvarId),
ResolvingUnboxedClosure(ast::DefId), ResolvingClosure(ast::DefId),
} }
impl ResolveReason { impl ResolveReason {
@ -343,7 +335,7 @@ impl ResolveReason {
ResolvingUpvar(upvar_id) => { ResolvingUpvar(upvar_id) => {
ty::expr_span(tcx, upvar_id.closure_expr_id) ty::expr_span(tcx, upvar_id.closure_expr_id)
} }
ResolvingUnboxedClosure(did) => { ResolvingClosure(did) => {
if did.krate == ast::LOCAL_CRATE { if did.krate == ast::LOCAL_CRATE {
ty::expr_span(tcx, did.node) ty::expr_span(tcx, did.node)
} else { } else {
@ -414,7 +406,7 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
infer::fixup_err_to_string(e)); infer::fixup_err_to_string(e));
} }
ResolvingUnboxedClosure(_) => { ResolvingClosure(_) => {
let span = self.reason.span(self.tcx); let span = self.reason.span(self.tcx);
span_err!(self.tcx.sess, span, E0196, span_err!(self.tcx.sess, span, E0196,
"cannot determine a type for this \ "cannot determine a type for this \

View file

@ -26,7 +26,7 @@ use middle::ty::{Ty, ty_bool, ty_char, ty_enum, ty_err};
use middle::ty::{ty_param, TypeScheme, ty_ptr}; use middle::ty::{ty_param, TypeScheme, ty_ptr};
use middle::ty::{ty_rptr, ty_struct, ty_trait, ty_tup}; use middle::ty::{ty_rptr, ty_struct, ty_trait, ty_tup};
use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_open}; use middle::ty::{ty_str, ty_vec, ty_float, ty_infer, ty_int, ty_open};
use middle::ty::{ty_uint, ty_unboxed_closure, ty_uniq, ty_bare_fn}; use middle::ty::{ty_uint, ty_closure, ty_uniq, ty_bare_fn};
use middle::ty::{ty_projection}; use middle::ty::{ty_projection};
use middle::ty; use middle::ty;
use CrateCtxt; use CrateCtxt;
@ -80,7 +80,7 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
None None
} }
ty_infer(..) | ty_unboxed_closure(..) => { ty_infer(..) | ty_closure(..) => {
// `ty` comes from a user declaration so we should only expect types // `ty` comes from a user declaration so we should only expect types
// that the user can type // that the user can type
inference_context.tcx.sess.span_bug( inference_context.tcx.sess.span_bug(
@ -410,7 +410,7 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> {
match self_type.ty.sty { match self_type.ty.sty {
ty::ty_enum(type_def_id, _) | ty::ty_enum(type_def_id, _) |
ty::ty_struct(type_def_id, _) | ty::ty_struct(type_def_id, _) |
ty::ty_unboxed_closure(type_def_id, _, _) => { ty::ty_closure(type_def_id, _, _) => {
tcx.destructor_for_type tcx.destructor_for_type
.borrow_mut() .borrow_mut()
.insert(type_def_id, method_def_id.def_id()); .insert(type_def_id, method_def_id.def_id());

View file

@ -740,7 +740,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> {
/* leaf type -- noop */ /* leaf type -- noop */
} }
ty::ty_unboxed_closure(..) => { ty::ty_closure(..) => {
self.tcx().sess.bug("Unexpected unboxed closure type in variance computation"); self.tcx().sess.bug("Unexpected unboxed closure type in variance computation");
} }

View file

@ -1601,7 +1601,7 @@ impl<'tcx> Clean<Type> for ty::Ty<'tcx> {
ty::ty_param(ref p) => Generic(token::get_name(p.name).to_string()), ty::ty_param(ref p) => Generic(token::get_name(p.name).to_string()),
ty::ty_unboxed_closure(..) => Tuple(vec![]), // FIXME(pcwalton) ty::ty_closure(..) => Tuple(vec![]), // FIXME(pcwalton)
ty::ty_infer(..) => panic!("ty_infer"), ty::ty_infer(..) => panic!("ty_infer"),
ty::ty_open(..) => panic!("ty_open"), ty::ty_open(..) => panic!("ty_open"),

View file

@ -49,7 +49,7 @@ pub use self::TraitItem::*;
pub use self::Ty_::*; pub use self::Ty_::*;
pub use self::TyParamBound::*; pub use self::TyParamBound::*;
pub use self::UintTy::*; pub use self::UintTy::*;
pub use self::UnboxedClosureKind::*; pub use self::ClosureKind::*;
pub use self::UnOp::*; pub use self::UnOp::*;
pub use self::UnsafeSource::*; pub use self::UnsafeSource::*;
pub use self::VariantKind::*; pub use self::VariantKind::*;
@ -734,7 +734,7 @@ pub enum Expr_ {
// FIXME #6993: change to Option<Name> ... or not, if these are hygienic. // FIXME #6993: change to Option<Name> ... or not, if these are hygienic.
ExprLoop(P<Block>, Option<Ident>), ExprLoop(P<Block>, Option<Ident>),
ExprMatch(P<Expr>, Vec<Arm>, MatchSource), ExprMatch(P<Expr>, Vec<Arm>, MatchSource),
ExprClosure(CaptureClause, Option<UnboxedClosureKind>, P<FnDecl>, P<Block>), ExprClosure(CaptureClause, Option<ClosureKind>, P<FnDecl>, P<Block>),
ExprBlock(P<Block>), ExprBlock(P<Block>),
ExprAssign(P<Expr>, P<Expr>), ExprAssign(P<Expr>, P<Expr>),
@ -1710,10 +1710,10 @@ impl ForeignItem_ {
} }
#[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)] #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show, Copy)]
pub enum UnboxedClosureKind { pub enum ClosureKind {
FnUnboxedClosureKind, FnClosureKind,
FnMutUnboxedClosureKind, FnMutClosureKind,
FnOnceUnboxedClosureKind, FnOnceClosureKind,
} }
/// The data we save and restore about an inlined item or method. This is not /// The data we save and restore about an inlined item or method. This is not

View file

@ -28,8 +28,8 @@ use ast::{ExprLit, ExprLoop, ExprMac, ExprRange};
use ast::{ExprMethodCall, ExprParen, ExprPath, ExprQPath}; use ast::{ExprMethodCall, ExprParen, ExprPath, ExprQPath};
use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary}; use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary};
use ast::{ExprVec, ExprWhile, ExprWhileLet, ExprForLoop, Field, FnDecl}; use ast::{ExprVec, ExprWhile, ExprWhileLet, ExprForLoop, Field, FnDecl};
use ast::{FnUnboxedClosureKind, FnMutUnboxedClosureKind}; use ast::{FnClosureKind, FnMutClosureKind};
use ast::{FnOnceUnboxedClosureKind}; use ast::{FnOnceClosureKind};
use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, ForeignMod, FunctionRetTy}; use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, ForeignMod, FunctionRetTy};
use ast::{Ident, Inherited, ImplItem, Item, Item_, ItemStatic}; use ast::{Ident, Inherited, ImplItem, Item, Item_, ItemStatic};
use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl, ItemConst}; use ast::{ItemEnum, ItemFn, ItemForeignMod, ItemImpl, ItemConst};
@ -57,7 +57,7 @@ use ast::{TyFixedLengthVec, TyBareFn};
use ast::{TyTypeof, TyInfer, TypeMethod}; use ast::{TyTypeof, TyInfer, TypeMethod};
use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr, TyQPath}; use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr, TyQPath};
use ast::{TyRptr, TyTup, TyU32, TyVec, UnUniq}; use ast::{TyRptr, TyTup, TyU32, TyVec, UnUniq};
use ast::{TypeImplItem, TypeTraitItem, Typedef, UnboxedClosureKind}; use ast::{TypeImplItem, TypeTraitItem, Typedef, ClosureKind};
use ast::{UnnamedField, UnsafeBlock}; use ast::{UnnamedField, UnsafeBlock};
use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple};
use ast::{Visibility, WhereClause}; use ast::{Visibility, WhereClause};
@ -1134,26 +1134,25 @@ impl<'a> Parser<'a> {
} }
/// Parses an optional unboxed closure kind (`&:`, `&mut:`, or `:`). /// Parses an optional unboxed closure kind (`&:`, `&mut:`, or `:`).
pub fn parse_optional_unboxed_closure_kind(&mut self) pub fn parse_optional_closure_kind(&mut self) -> Option<ClosureKind> {
-> Option<UnboxedClosureKind> {
if self.check(&token::BinOp(token::And)) && if self.check(&token::BinOp(token::And)) &&
self.look_ahead(1, |t| t.is_keyword(keywords::Mut)) && self.look_ahead(1, |t| t.is_keyword(keywords::Mut)) &&
self.look_ahead(2, |t| *t == token::Colon) { self.look_ahead(2, |t| *t == token::Colon) {
self.bump(); self.bump();
self.bump(); self.bump();
self.bump(); self.bump();
return Some(FnMutUnboxedClosureKind) return Some(FnMutClosureKind)
} }
if self.token == token::BinOp(token::And) && if self.token == token::BinOp(token::And) &&
self.look_ahead(1, |t| *t == token::Colon) { self.look_ahead(1, |t| *t == token::Colon) {
self.bump(); self.bump();
self.bump(); self.bump();
return Some(FnUnboxedClosureKind) return Some(FnClosureKind)
} }
if self.eat(&token::Colon) { if self.eat(&token::Colon) {
return Some(FnOnceUnboxedClosureKind) return Some(FnOnceClosureKind)
} }
return None return None
@ -3023,8 +3022,7 @@ impl<'a> Parser<'a> {
-> P<Expr> -> P<Expr>
{ {
let lo = self.span.lo; let lo = self.span.lo;
let (decl, optional_unboxed_closure_kind) = let (decl, optional_closure_kind) = self.parse_fn_block_decl();
self.parse_fn_block_decl();
let body = self.parse_expr(); let body = self.parse_expr();
let fakeblock = P(ast::Block { let fakeblock = P(ast::Block {
id: ast::DUMMY_NODE_ID, id: ast::DUMMY_NODE_ID,
@ -3037,7 +3035,7 @@ impl<'a> Parser<'a> {
self.mk_expr( self.mk_expr(
lo, lo,
fakeblock.span.hi, fakeblock.span.hi,
ExprClosure(capture_clause, optional_unboxed_closure_kind, decl, fakeblock)) ExprClosure(capture_clause, optional_closure_kind, decl, fakeblock))
} }
pub fn parse_else_expr(&mut self) -> P<Expr> { pub fn parse_else_expr(&mut self) -> P<Expr> {
@ -4506,22 +4504,21 @@ impl<'a> Parser<'a> {
} }
// parse the |arg, arg| header on a lambda // parse the |arg, arg| header on a lambda
fn parse_fn_block_decl(&mut self) fn parse_fn_block_decl(&mut self) -> (P<FnDecl>, Option<ClosureKind>) {
-> (P<FnDecl>, Option<UnboxedClosureKind>) { let (optional_closure_kind, inputs_captures) = {
let (optional_unboxed_closure_kind, inputs_captures) = {
if self.eat(&token::OrOr) { if self.eat(&token::OrOr) {
(None, Vec::new()) (None, Vec::new())
} else { } else {
self.expect(&token::BinOp(token::Or)); self.expect(&token::BinOp(token::Or));
let optional_unboxed_closure_kind = let optional_closure_kind =
self.parse_optional_unboxed_closure_kind(); self.parse_optional_closure_kind();
let args = self.parse_seq_to_before_end( let args = self.parse_seq_to_before_end(
&token::BinOp(token::Or), &token::BinOp(token::Or),
seq_sep_trailing_allowed(token::Comma), seq_sep_trailing_allowed(token::Comma),
|p| p.parse_fn_block_arg() |p| p.parse_fn_block_arg()
); );
self.bump(); self.bump();
(optional_unboxed_closure_kind, args) (optional_closure_kind, args)
} }
}; };
let output = self.parse_ret_ty(); let output = self.parse_ret_ty();
@ -4530,7 +4527,7 @@ impl<'a> Parser<'a> {
inputs: inputs_captures, inputs: inputs_captures,
output: output, output: output,
variadic: false variadic: false
}), optional_unboxed_closure_kind) }), optional_closure_kind)
} }
/// Parses the `(arg, arg) -> return_type` header on a procedure. /// Parses the `(arg, arg) -> return_type` header on a procedure.

View file

@ -11,11 +11,11 @@
pub use self::AnnNode::*; pub use self::AnnNode::*;
use abi; use abi;
use ast::{self, FnUnboxedClosureKind, FnMutUnboxedClosureKind}; use ast::{self, FnClosureKind, FnMutClosureKind};
use ast::{FnOnceUnboxedClosureKind}; use ast::{FnOnceClosureKind};
use ast::{MethodImplItem, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::{MethodImplItem, RegionTyParamBound, TraitTyParamBound, TraitBoundModifier};
use ast::{RequiredMethod, ProvidedMethod, TypeImplItem, TypeTraitItem}; use ast::{RequiredMethod, ProvidedMethod, TypeImplItem, TypeTraitItem};
use ast::{UnboxedClosureKind}; use ast::{ClosureKind};
use ast_util; use ast_util;
use owned_slice::OwnedSlice; use owned_slice::OwnedSlice;
use attr::{AttrMetaMethods, AttributeMethods}; use attr::{AttrMetaMethods, AttributeMethods};
@ -2357,14 +2357,14 @@ impl<'a> State<'a> {
pub fn print_fn_block_args( pub fn print_fn_block_args(
&mut self, &mut self,
decl: &ast::FnDecl, decl: &ast::FnDecl,
unboxed_closure_kind: Option<UnboxedClosureKind>) closure_kind: Option<ClosureKind>)
-> IoResult<()> { -> IoResult<()> {
try!(word(&mut self.s, "|")); try!(word(&mut self.s, "|"));
match unboxed_closure_kind { match closure_kind {
None => {} None => {}
Some(FnUnboxedClosureKind) => try!(self.word_space("&:")), Some(FnClosureKind) => try!(self.word_space("&:")),
Some(FnMutUnboxedClosureKind) => try!(self.word_space("&mut:")), Some(FnMutClosureKind) => try!(self.word_space("&mut:")),
Some(FnOnceUnboxedClosureKind) => try!(self.word_space(":")), Some(FnOnceClosureKind) => try!(self.word_space(":")),
} }
try!(self.print_fn_args(decl, None)); try!(self.print_fn_args(decl, None));
try!(word(&mut self.s, "|")); try!(word(&mut self.s, "|"));

View file

@ -12,7 +12,7 @@
// //
// error: internal compiler error: get_unique_type_id_of_type() - // error: internal compiler error: get_unique_type_id_of_type() -
// unexpected type: closure, // unexpected type: closure,
// ty_unboxed_closure(syntax::ast::DefId{krate: 0u32, node: 66u32}, // ty_closure(syntax::ast::DefId{krate: 0u32, node: 66u32},
// ReScope(63u32)) // ReScope(63u32))
// //
// This is a regression test for issue #17021. // This is a regression test for issue #17021.