diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 34f0cb7c19823f26e87e0f4ef453ff24e0deb39b..0420506d00175428353aec8c5fc9dde3e20d3eda 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -40,7 +40,7 @@ use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt}; use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyProc, TyQPath}; use syntax::ast::{TyRptr, TyStr, TyU, TyU8, TyU16, TyU32, TyU64, TyUint}; -use syntax::ast::{TypeImplItem, UnboxedFnTyParamBound, UnnamedField}; +use syntax::ast::{TypeImplItem, UnnamedField}; use syntax::ast::{Variant, ViewItem, ViewItemExternCrate}; use syntax::ast::{ViewItemUse, ViewPathGlob, ViewPathList, ViewPathSimple}; use syntax::ast::{Visibility}; @@ -4523,41 +4523,6 @@ fn resolve_type_parameter_bound(&mut self, TraitTyParamBound(ref tref) => { self.resolve_trait_reference(id, tref, reference_type) } - UnboxedFnTyParamBound(ref unboxed_function) => { - match self.resolve_path(unboxed_function.ref_id, - &unboxed_function.path, - TypeNS, - true) { - None => { - let path_str = self.path_names_to_string( - &unboxed_function.path); - self.resolve_error(unboxed_function.path.span, - format!("unresolved trait `{}`", - path_str).as_slice()) - } - Some(def) => { - match def { - (DefTrait(_), _) => { - self.record_def(unboxed_function.ref_id, def); - } - _ => { - let msg = - format!("`{}` is not a trait", - self.path_names_to_string( - &unboxed_function.path)); - self.resolve_error(unboxed_function.path.span, - msg.as_slice()); - } - } - } - } - - for argument in unboxed_function.decl.inputs.iter() { - self.resolve_type(&*argument.ty); - } - - self.resolve_type(&*unboxed_function.decl.output); - } RegionTyParamBound(..) => {} } } diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index eda4c241f86cf4211a0f40f9fb44c91c7869e5c7..8246970c24ad7695ad37943603cbbdb42ed2930a 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -204,9 +204,6 @@ fn visit_ty_param_bounds(&mut self, ast::TraitTyParamBound(ref trait_ref) => { self.visit_trait_ref(trait_ref); } - ast::UnboxedFnTyParamBound(ref fn_decl) => { - self.visit_unboxed_fn_ty_param_bound(&**fn_decl); - } ast::RegionTyParamBound(ref lifetime) => { self.visit_lifetime_ref(lifetime); } @@ -226,18 +223,6 @@ fn visit_trait_ref(&mut self, trait_ref: &ast::TraitRef) { }) } - fn visit_unboxed_fn_ty_param_bound(&mut self, - bound: &ast::UnboxedFnBound) { - self.with(|scope, f| { - f(LateScope(bound.ref_id, &bound.lifetimes, scope)) - }, |v| { - for argument in bound.decl.inputs.iter() { - v.visit_ty(&*argument.ty); - } - v.visit_ty(&*bound.decl.output); - }) - } - /// Visits self by adding a scope and handling recursive walk over the contents with `walk`. fn visit_fn_decl(&mut self, n: ast::NodeId, diff --git a/src/librustc/middle/save/mod.rs b/src/librustc/middle/save/mod.rs index 90a21d479037894013dc9f893ea902116847397d..b64a160ab1f28c915aab829310be1bf3fa21d981 100644 --- a/src/librustc/middle/save/mod.rs +++ b/src/librustc/middle/save/mod.rs @@ -705,7 +705,7 @@ fn process_trait(&mut self, ast::TraitTyParamBound(ref trait_ref) => { trait_ref } - ast::UnboxedFnTyParamBound(..) | ast::RegionTyParamBound(..) => { + ast::RegionTyParamBound(..) => { continue; } }; diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index f2cc3bfd29b9f5a2ec93bf990b5f25196bcc254d..05d315e5fec32cbdfa64681b7e56526f16d43184 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -620,15 +620,6 @@ enum PointerTy { Uniq } -impl PointerTy { - fn default_region(&self) -> ty::Region { - match *self { - Uniq => ty::ReStatic, - RPtr(r) => r, - } - } -} - pub fn trait_ref_for_unboxed_function<'tcx, AC: AstConv<'tcx>, RS:RegionScope>( this: &AC, @@ -687,31 +678,6 @@ fn mk_pointer<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( let ty = ast_ty_to_ty(this, rscope, &**ty); return constr(ty::mk_vec(tcx, ty, None)); } - ast::TyUnboxedFn(ref unboxed_function) => { - let ty::TraitRef { - def_id, - substs - } = trait_ref_for_unboxed_function(this, - rscope, - unboxed_function.kind, - &*unboxed_function.decl, - None); - let r = ptr_ty.default_region(); - let tr = ty::mk_trait(this.tcx(), - def_id, - substs, - ty::region_existential_bound(r)); - match ptr_ty { - Uniq => { - return ty::mk_uniq(this.tcx(), tr); - } - RPtr(r) => { - return ty::mk_rptr(this.tcx(), - r, - ty::mt {mutbl: a_seq_mutbl, ty: tr}); - } - } - } ast::TyPath(ref path, ref opt_bounds, id) => { // Note that the "bounds must be empty if path is not a trait" // restriction is enforced in the below case for ty_path, which @@ -941,11 +907,6 @@ pub fn ast_ty_to_ty<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( ty::mk_closure(tcx, fn_decl) } - ast::TyUnboxedFn(..) => { - tcx.sess.span_err(ast_ty.span, - "cannot use unboxed functions here"); - ty::mk_err() - } ast::TyPath(ref path, ref bounds, id) => { let a_def = match tcx.def_map.borrow().find(&id) { None => { @@ -1425,8 +1386,7 @@ pub fn conv_existential_bounds<'tcx, AC: AstConv<'tcx>, RS:RegionScope>( let PartitionedBounds { builtin_bounds, trait_bounds, - region_bounds, - unboxed_fn_ty_bounds } = + region_bounds } = partition_bounds(this.tcx(), span, ast_bound_refs.as_slice()); if !trait_bounds.is_empty() { @@ -1437,13 +1397,6 @@ pub fn conv_existential_bounds<'tcx, AC: AstConv<'tcx>, RS:RegionScope>( as closure or object bounds").as_slice()); } - if !unboxed_fn_ty_bounds.is_empty() { - this.tcx().sess.span_err( - span, - format!("only the builtin traits can be used \ - as closure or object bounds").as_slice()); - } - // The "main trait refs", rather annoyingly, have no type // specified for the `Self` parameter of the trait. The reason for // this is that they are, after all, *existential* types, and @@ -1572,7 +1525,6 @@ fn compute_region_bound<'tcx, AC: AstConv<'tcx>, RS:RegionScope>( pub struct PartitionedBounds<'a> { pub builtin_bounds: ty::BuiltinBounds, pub trait_bounds: Vec<&'a ast::TraitRef>, - pub unboxed_fn_ty_bounds: Vec<&'a ast::UnboxedFnBound>, pub region_bounds: Vec<&'a ast::Lifetime>, } @@ -1590,7 +1542,6 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt, let mut builtin_bounds = ty::empty_builtin_bounds(); let mut region_bounds = Vec::new(); let mut trait_bounds = Vec::new(); - let mut unboxed_fn_ty_bounds = Vec::new(); let mut trait_def_ids = HashMap::new(); for &ast_bound in ast_bounds.iter() { match *ast_bound { @@ -1635,9 +1586,6 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt, ast::RegionTyParamBound(ref l) => { region_bounds.push(l); } - ast::UnboxedFnTyParamBound(ref unboxed_function) => { - unboxed_fn_ty_bounds.push(&**unboxed_function); - } } } @@ -1645,7 +1593,6 @@ pub fn partition_bounds<'a>(tcx: &ty::ctxt, builtin_bounds: builtin_bounds, trait_bounds: trait_bounds, region_bounds: region_bounds, - unboxed_fn_ty_bounds: unboxed_fn_ty_bounds } } diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 7a26cc51114540b538152f7114992014aa1e08f0..38de50f68318f9dce0f06451d9f8663cd96f1420 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -638,7 +638,7 @@ pub fn ensure_no_ty_param_bounds(ccx: &CrateCtxt, let mut bounds = bounds.chain(ty_param.unbound.iter()); for bound in bounds { match *bound { - ast::TraitTyParamBound(..) | ast::UnboxedFnTyParamBound(..) => { + ast::TraitTyParamBound(..) => { // According to accepted RFC #XXX, we should // eventually accept these, but it will not be // part of this PR. Still, convert to warning to @@ -1356,20 +1356,6 @@ pub fn instantiate_trait_ref<'tcx,AC>(this: &AC, } } -pub fn instantiate_unboxed_fn_ty<'tcx,AC>(this: &AC, - unboxed_function: &ast::UnboxedFnTy, - param_ty: ty::ParamTy) - -> Rc - where AC: AstConv<'tcx> { - let rscope = ExplicitRscope; - let param_ty = param_ty.to_ty(this.tcx()); - Rc::new(astconv::trait_ref_for_unboxed_function(this, - &rscope, - unboxed_function.kind, - &*unboxed_function.decl, - Some(param_ty))) -} - fn get_trait_def(ccx: &CrateCtxt, trait_id: ast::DefId) -> Rc { if trait_id.krate != ast::LOCAL_CRATE { return ty::lookup_trait_def(ccx.tcx, trait_id) @@ -1879,7 +1865,6 @@ fn create_type_parameters_for_associated_types<'tcx,AC>( // In the above example, `ast_trait_ref` is `Iterator`. let ast_trait_ref = match *bound { ast::TraitTyParamBound(ref r) => r, - ast::UnboxedFnTyParamBound(..) => { continue; } ast::RegionTyParamBound(..) => { continue; } }; @@ -2057,45 +2042,8 @@ fn conv_param_bounds<'tcx,AC>(this: &AC, merge_param_bounds(this.tcx(), param_ty, ast_bounds, where_clause); let astconv::PartitionedBounds { builtin_bounds, trait_bounds, - region_bounds, - unboxed_fn_ty_bounds } = + region_bounds } = astconv::partition_bounds(this.tcx(), span, all_bounds.as_slice()); - - let unboxed_fn_ty_bounds = unboxed_fn_ty_bounds.into_iter().map(|b| { - let trait_id = (*this.tcx().def_map.borrow())[b.ref_id].def_id(); - let mut kind = None; - for &(lang_item, this_kind) in [ - (this.tcx().lang_items.fn_trait(), ast::FnUnboxedClosureKind), - (this.tcx().lang_items.fn_mut_trait(), - ast::FnMutUnboxedClosureKind), - (this.tcx().lang_items.fn_once_trait(), - ast::FnOnceUnboxedClosureKind) - ].iter() { - if Some(trait_id) == lang_item { - kind = Some(this_kind); - break - } - } - - let kind = match kind { - Some(kind) => kind, - None => { - this.tcx().sess.span_err(b.path.span, - "unboxed function trait must be one \ - of `Fn`, `FnMut`, or `FnOnce`"); - ast::FnMutUnboxedClosureKind - } - }; - - let rscope = ExplicitRscope; - let param_ty = param_ty.to_ty(this.tcx()); - Rc::new(astconv::trait_ref_for_unboxed_function(this, - &rscope, - kind, - &*b.decl, - Some(param_ty))) - }); - let trait_bounds: Vec> = trait_bounds.into_iter() .map(|b| { @@ -2104,7 +2052,6 @@ fn conv_param_bounds<'tcx,AC>(this: &AC, param_ty.to_ty(this.tcx()), Some(param_ty.to_ty(this.tcx()))) }) - .chain(unboxed_fn_ty_bounds) .collect(); let region_bounds: Vec = region_bounds.into_iter() diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 64efae486b7e9733fc6a67f02759ad9e941b7240..4882059e91b62fea08550b4489faa7082da3303b 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -1102,9 +1102,6 @@ fn rebuild_ty_param_bounds(&self, // be passing down a map. ast::RegionTyParamBound(lt) } - &ast::UnboxedFnTyParamBound(ref unboxed_function_type) => { - ast::UnboxedFnTyParamBound((*unboxed_function_type).clone()) - } &ast::TraitTyParamBound(ref tr) => { let last_seg = tr.path.segments.last().unwrap(); let mut insert = Vec::new(); diff --git a/src/librustdoc/clean/inline.rs b/src/librustdoc/clean/inline.rs index d87d8776d4a6cecb27236f3b858b09789d0013ee..a3bf0160471ec0af5335ddcc2d240b397af3e2f5 100644 --- a/src/librustdoc/clean/inline.rs +++ b/src/librustdoc/clean/inline.rs @@ -323,7 +323,6 @@ fn build_impl(cx: &DocContext, tcx: &ty::ctxt, trait_: associated_trait.clean(cx).map(|bound| { match bound { clean::TraitBound(ty) => ty, - clean::UnboxedFnBound(..) | clean::RegionBound(..) => unreachable!(), } }), diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index cfd183b4c453b4a1c2354e752d200e3fbb29ba57..d3bfe42dcb2195c78a2fb4e08ad46f2206e7e9d0 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -476,7 +476,6 @@ fn clean(&self, cx: &DocContext) -> TyParam { #[deriving(Clone, Encodable, Decodable, PartialEq)] pub enum TyParamBound { RegionBound(Lifetime), - UnboxedFnBound(UnboxedFnType), TraitBound(Type) } @@ -484,7 +483,6 @@ impl Clean for ast::TyParamBound { fn clean(&self, cx: &DocContext) -> TyParamBound { match *self { ast::RegionTyParamBound(lt) => RegionBound(lt.clean(cx)), - ast::UnboxedFnTyParamBound(ref ty) => { UnboxedFnBound(ty.clean(cx)) }, ast::TraitTyParamBound(ref t) => TraitBound(t.clean(cx)), } } @@ -599,21 +597,6 @@ fn clean(&self, cx: &DocContext) -> Option> { } } -#[deriving(Clone, Encodable, Decodable, PartialEq)] -pub struct UnboxedFnType { - pub path: Path, - pub decl: FnDecl -} - -impl Clean for ast::UnboxedFnBound { - fn clean(&self, cx: &DocContext) -> UnboxedFnType { - UnboxedFnType { - path: self.path.clean(cx), - decl: self.decl.clean(cx) - } - } -} - #[deriving(Clone, Encodable, Decodable, PartialEq)] pub struct Lifetime(String); diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index f9177c8d61578797a79a5af5f234f287edcb591c..ea6cbbb6b833862829c202a09c9730d5883d1984 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -143,9 +143,6 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { clean::RegionBound(ref lt) => { write!(f, "{}", *lt) } - clean::UnboxedFnBound(ref ty) => { - write!(f, "{}{}", ty.path, ty.decl) - } clean::TraitBound(ref ty) => { write!(f, "{}", *ty) } @@ -404,8 +401,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { let mut ret = String::new(); for bound in decl.bounds.iter() { match *bound { - clean::RegionBound(..) | - clean::UnboxedFnBound(..) => {} + clean::RegionBound(..) => {} clean::TraitBound(ref t) => { if ret.len() == 0 { ret.push_str(": "); diff --git a/src/libsyntax/ast.rs b/src/libsyntax/ast.rs index a2089a3e2a35c2d0fd0227e14e77c00f27eec3e8..6a354fa20e1b40bbb88b48d0ea5ee6cac1f11fcb 100644 --- a/src/libsyntax/ast.rs +++ b/src/libsyntax/ast.rs @@ -308,20 +308,11 @@ pub struct DefId { #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum TyParamBound { TraitTyParamBound(TraitRef), - UnboxedFnTyParamBound(P), RegionTyParamBound(Lifetime) } pub type TyParamBounds = OwnedSlice; -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] -pub struct UnboxedFnBound { - pub path: Path, - pub decl: P, - pub lifetimes: Vec, - pub ref_id: NodeId, -} - #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub struct TyParam { pub ident: Ident, @@ -1089,12 +1080,6 @@ pub struct BareFnTy { pub decl: P } -#[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] -pub struct UnboxedFnTy { - pub kind: UnboxedClosureKind, - pub decl: P, -} - #[deriving(Clone, PartialEq, Eq, Encodable, Decodable, Hash, Show)] pub enum Ty_ { TyNil, @@ -1107,7 +1092,6 @@ pub enum Ty_ { TyClosure(P), TyProc(P), TyBareFn(P), - TyUnboxedFn(P), TyTup(Vec> ), TyPath(Path, Option, NodeId), // for #7264; see above /// A "qualified path", e.g. ` as SomeTrait>::SomeType` diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index f049b964ff33d415d77acf27528c60ebd219de52..3adb062864e1e128ffe207dac5be3702ba254c72 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -848,9 +848,6 @@ fn visit_ty(&mut self, ty: &'ast Ty) { TyBareFn(ref fd) => { self.visit_fn_decl(&*fd.decl); } - TyUnboxedFn(ref fd) => { - self.visit_fn_decl(&*fd.decl); - } _ => {} } visit::walk_ty(self, ty); diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 7701f495f726fcb72543f66d2761eb5901fc0607..80b158a54d36cf90dd8d20fc473044134e3c89fd 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -313,11 +313,6 @@ fn visit_ty(&mut self, t: &ast::Ty) { experimental and likely to be removed"); }, - ast::TyUnboxedFn(..) => { - self.gate_feature("unboxed_closure_sugar", - t.span, - "unboxed closure trait sugar is experimental"); - } _ => {} } diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 79e2c656e41f4a8796a63a03275df25a366c2eb8..cd4a3d10c48825749105d304305b494adcbc94d5 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -424,12 +424,6 @@ pub fn noop_fold_ty(t: P, fld: &mut T) -> P { decl: fld.fold_fn_decl(decl) })) } - TyUnboxedFn(f) => { - TyUnboxedFn(f.map(|UnboxedFnTy {decl, kind}| UnboxedFnTy { - decl: fld.fold_fn_decl(decl), - kind: kind, - })) - } TyTup(tys) => TyTup(tys.move_map(|ty| fld.fold_ty(ty))), TyParen(ty) => TyParen(fld.fold_ty(ty)), TyPath(path, bounds, id) => { @@ -715,23 +709,6 @@ pub fn noop_fold_ty_param_bound(tpb: TyParamBound, fld: &mut T) match tpb { TraitTyParamBound(ty) => TraitTyParamBound(fld.fold_trait_ref(ty)), RegionTyParamBound(lifetime) => RegionTyParamBound(fld.fold_lifetime(lifetime)), - UnboxedFnTyParamBound(bound) => { - match *bound { - UnboxedFnBound { - ref path, - ref decl, - ref lifetimes, - ref_id - } => { - UnboxedFnTyParamBound(P(UnboxedFnBound { - path: fld.fold_path(path.clone()), - decl: fld.fold_fn_decl(decl.clone()), - lifetimes: fld.fold_lifetime_defs(lifetimes.clone()), - ref_id: fld.new_id(ref_id), - })) - } - } - } } } diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 1c65a47350ea827cb20dd6b15321f848a12628a5..18dd7074d28b32e8389d4ae3bddc9735b9d28b60 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -53,9 +53,8 @@ use ast::{TypeField, TyFixedLengthVec, TyClosure, TyProc, TyBareFn}; use ast::{TyTypeof, TyInfer, TypeMethod}; use ast::{TyNil, TyParam, TyParamBound, TyParen, TyPath, TyPtr, TyQPath}; -use ast::{TyRptr, TyTup, TyU32, TyUnboxedFn, TyUniq, TyVec, UnUniq}; +use ast::{TyRptr, TyTup, TyU32, TyUniq, TyVec, UnUniq}; use ast::{TypeImplItem, TypeTraitItem, Typedef, UnboxedClosureKind}; -use ast::{UnboxedFnBound, UnboxedFnTy, UnboxedFnTyParamBound}; use ast::{UnnamedField, UnsafeBlock}; use ast::{UnsafeFn, ViewItem, ViewItem_, ViewItemExternCrate, ViewItemUse}; use ast::{ViewPath, ViewPathGlob, ViewPathList, ViewPathSimple}; @@ -1127,19 +1126,16 @@ pub fn parse_ty_closure(&mut self) -> Ty_ { Vec::new() }; - let (optional_unboxed_closure_kind, inputs) = if self.eat(&token::OrOr) { - (None, Vec::new()) + let inputs = if self.eat(&token::OrOr) { + Vec::new() } else { self.expect_or(); - let optional_unboxed_closure_kind = - self.parse_optional_unboxed_closure_kind(); - let inputs = self.parse_seq_to_before_or( &token::Comma, |p| p.parse_arg_general(false)); self.expect_or(); - (optional_unboxed_closure_kind, inputs) + inputs }; let bounds = self.parse_colon_then_ty_param_bounds(); @@ -1152,23 +1148,13 @@ pub fn parse_ty_closure(&mut self) -> Ty_ { variadic: false }); - match optional_unboxed_closure_kind { - Some(unboxed_closure_kind) => { - TyUnboxedFn(P(UnboxedFnTy { - kind: unboxed_closure_kind, - decl: decl, - })) - } - None => { - TyClosure(P(ClosureTy { - fn_style: fn_style, - onceness: onceness, - bounds: bounds, - decl: decl, - lifetimes: lifetime_defs, - })) - } - } + TyClosure(P(ClosureTy { + fn_style: fn_style, + onceness: onceness, + bounds: bounds, + decl: decl, + lifetimes: lifetime_defs, + })) } pub fn parse_unsafety(&mut self) -> FnStyle { @@ -3935,31 +3921,11 @@ fn parse_ty_param_bounds(&mut self) token::ModSep | token::Ident(..) => { let path = self.parse_path(LifetimeAndTypesWithoutColons).path; - if self.token == token::OpenDelim(token::Paren) { - self.bump(); - let inputs = self.parse_seq_to_end( - &token::CloseDelim(token::Paren), - seq_sep_trailing_allowed(token::Comma), - |p| p.parse_arg_general(false)); - let (return_style, output) = self.parse_ret_ty(); - result.push(UnboxedFnTyParamBound(P(UnboxedFnBound { - path: path, - decl: P(FnDecl { - inputs: inputs, - output: output, - cf: return_style, - variadic: false, - }), - lifetimes: lifetime_defs, - ref_id: ast::DUMMY_NODE_ID, - }))); - } else { - result.push(TraitTyParamBound(ast::TraitRef { - path: path, - ref_id: ast::DUMMY_NODE_ID, - lifetimes: lifetime_defs, - })) - } + result.push(TraitTyParamBound(ast::TraitRef { + path: path, + ref_id: ast::DUMMY_NODE_ID, + lifetimes: lifetime_defs, + })) } _ => break, } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index d83ea5f76b1fc0f48246aec351bdebb2b736daa5..2448eacbb39986a32e5290cb729d739d9c3574b9 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -13,7 +13,7 @@ use ast::{FnOnceUnboxedClosureKind}; use ast::{MethodImplItem, RegionTyParamBound, TraitTyParamBound}; use ast::{RequiredMethod, ProvidedMethod, TypeImplItem, TypeTraitItem}; -use ast::{UnboxedClosureKind, UnboxedFnTyParamBound}; +use ast::{UnboxedClosureKind}; use ast; use ast_util; use owned_slice::OwnedSlice; @@ -699,7 +699,6 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> IoResult<()> { None, &OwnedSlice::empty(), Some(&generics), - None, None)); } ast::TyClosure(ref f) => { @@ -719,7 +718,6 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> IoResult<()> { None, &f.bounds, Some(&generics), - None, None)); } ast::TyProc(ref f) => { @@ -739,21 +737,8 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> IoResult<()> { None, &f.bounds, Some(&generics), - None, None)); } - ast::TyUnboxedFn(ref f) => { - try!(self.print_ty_fn(None, - None, - ast::NormalFn, - ast::Many, - &*f.decl, - None, - &OwnedSlice::empty(), - None, - None, - Some(f.kind))); - } ast::TyPath(ref path, ref bounds, _) => { try!(self.print_bounded_path(path, bounds)); } @@ -1212,8 +1197,7 @@ pub fn print_ty_method(&mut self, m: &ast::TypeMethod) -> IoResult<()> { Some(m.ident), &OwnedSlice::empty(), Some(&m.generics), - Some(&m.explicit_self.node), - None)); + Some(&m.explicit_self.node))); word(&mut self.s, ";") } @@ -2407,15 +2391,6 @@ pub fn print_bounds(&mut self, RegionTyParamBound(ref lt) => { self.print_lifetime(lt) } - UnboxedFnTyParamBound(ref unboxed_function_type) => { - try!(self.print_path(&unboxed_function_type.path, - false)); - try!(self.popen()); - try!(self.print_fn_args(&*unboxed_function_type.decl, - None)); - try!(self.pclose()); - self.print_fn_output(&*unboxed_function_type.decl) - } }) } Ok(()) @@ -2675,9 +2650,7 @@ pub fn print_ty_fn(&mut self, id: Option, bounds: &OwnedSlice, generics: Option<&ast::Generics>, - opt_explicit_self: Option<&ast::ExplicitSelf_>, - opt_unboxed_closure_kind: - Option) + opt_explicit_self: Option<&ast::ExplicitSelf_>) -> IoResult<()> { try!(self.ibox(indent_unit)); @@ -2694,9 +2667,7 @@ pub fn print_ty_fn(&mut self, try!(self.print_fn_style(fn_style)); try!(self.print_opt_abi_and_extern_if_nondefault(opt_abi)); try!(self.print_onceness(onceness)); - if opt_unboxed_closure_kind.is_none() { - try!(word(&mut self.s, "fn")); - } + try!(word(&mut self.s, "fn")); } match id { @@ -2710,30 +2681,15 @@ pub fn print_ty_fn(&mut self, match generics { Some(g) => try!(self.print_generics(g)), _ => () } try!(zerobreak(&mut self.s)); - if opt_unboxed_closure_kind.is_some() || opt_sigil == Some('&') { + if opt_sigil == Some('&') { try!(word(&mut self.s, "|")); } else { try!(self.popen()); } - match opt_unboxed_closure_kind { - Some(ast::FnUnboxedClosureKind) => { - try!(word(&mut self.s, "&")); - try!(self.word_space(":")); - } - Some(ast::FnMutUnboxedClosureKind) => { - try!(word(&mut self.s, "&mut")); - try!(self.word_space(":")); - } - Some(ast::FnOnceUnboxedClosureKind) => { - try!(self.word_space(":")); - } - None => {} - } - try!(self.print_fn_args(decl, opt_explicit_self)); - if opt_unboxed_closure_kind.is_some() || opt_sigil == Some('&') { + if opt_sigil == Some('&') { try!(word(&mut self.s, "|")); } else { if decl.variadic { diff --git a/src/libsyntax/visit.rs b/src/libsyntax/visit.rs index b4141af07336a3d912ec6f5e39136200858c2835..9751abacbd3ff863bc42cae0f235763e72777e15 100644 --- a/src/libsyntax/visit.rs +++ b/src/libsyntax/visit.rs @@ -365,12 +365,6 @@ pub fn walk_ty<'v, V: Visitor<'v>>(visitor: &mut V, typ: &'v Ty) { visitor.visit_ty(&*function_declaration.decl.output); walk_lifetime_decls(visitor, &function_declaration.lifetimes); } - TyUnboxedFn(ref function_declaration) => { - for argument in function_declaration.decl.inputs.iter() { - visitor.visit_ty(&*argument.ty) - } - visitor.visit_ty(&*function_declaration.decl.output); - } TyPath(ref path, ref opt_bounds, id) => { visitor.visit_path(path, id); match *opt_bounds { @@ -505,13 +499,6 @@ pub fn walk_ty_param_bounds<'v, V: Visitor<'v>>(visitor: &mut V, TraitTyParamBound(ref typ) => { walk_trait_ref_helper(visitor, typ) } - UnboxedFnTyParamBound(ref function_declaration) => { - for argument in function_declaration.decl.inputs.iter() { - visitor.visit_ty(&*argument.ty) - } - visitor.visit_ty(&*function_declaration.decl.output); - walk_lifetime_decls(visitor, &function_declaration.lifetimes); - } RegionTyParamBound(ref lifetime) => { visitor.visit_lifetime_ref(lifetime); } diff --git a/src/test/run-pass/unboxed-closures-manual-impl.rs b/src/test/run-pass/unboxed-closures-manual-impl.rs index b0947f46a86ae9b6ef6842b0c03792aa352b0a3f..8f6cfe0499703ff7c7116c016bff80af6f060744 100644 --- a/src/test/run-pass/unboxed-closures-manual-impl.rs +++ b/src/test/run-pass/unboxed-closures-manual-impl.rs @@ -25,7 +25,7 @@ fn call_itint>(mut f: F, x: int) -> int { f.call_mut((x,)) + 3 } -fn call_box(f: &mut |&mut: int|->int, x: int) -> int { +fn call_box(f: &mut FnMut(int) -> int, x: int) -> int { f.call_mut((x,)) + 3 }