From 714a5b7f5e960c885030fac4b357ec1304f539f9 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 4 Jan 2015 09:51:37 -0500 Subject: remove TyClosure --- src/libsyntax/parse/parser.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index cc67079e538..9bc91a95841 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -55,7 +55,7 @@ use ast::{SelfExplicit, SelfRegion, SelfStatic, SelfValue}; use ast::{Delimited, SequenceRepetition, TokenTree, TraitItem, TraitRef}; use ast::{TtDelimited, TtSequence, TtToken}; use ast::{TupleVariantKind, Ty, Ty_, TypeBinding}; -use ast::{TypeField, TyFixedLengthVec, TyClosure, TyBareFn}; +use ast::{TypeField, TyFixedLengthVec, TyBareFn}; use ast::{TyTypeof, TyInfer, TypeMethod}; use ast::{TyParam, TyParamBound, TyParen, TyPath, TyPolyTraitRef, TyPtr, TyQPath}; use ast::{TyRptr, TyTup, TyU32, TyVec, UnUniq}; @@ -1252,13 +1252,7 @@ impl<'a> Parser<'a> { variadic: false }); - TyClosure(P(ClosureTy { - unsafety: unsafety, - onceness: Many, - bounds: bounds, - decl: decl, - lifetimes: lifetime_defs, - })) + panic!("stub"); } pub fn parse_unsafety(&mut self) -> Unsafety { -- cgit 1.4.1-3-g733a5 From 58b0d7479fb478d9c8293e78adaa86a8971442d5 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Thu, 1 Jan 2015 17:21:25 -0500 Subject: syntax: make the closure type `f: |uint| -> bool` syntax obsolete --- src/libsyntax/parse/obsolete.rs | 5 +++++ src/libsyntax/parse/parser.rs | 29 +++++++++++++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/obsolete.rs b/src/libsyntax/parse/obsolete.rs index e1e456f880e..75b2c17b81b 100644 --- a/src/libsyntax/parse/obsolete.rs +++ b/src/libsyntax/parse/obsolete.rs @@ -34,6 +34,7 @@ pub enum ObsoleteSyntax { ObsoleteExternCrateRenaming, ObsoleteProcType, ObsoleteProcExpr, + ObsoleteClosureType, } pub trait ParserObsoleteMethods { @@ -94,6 +95,10 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> { ObsoleteExternCrateRenaming => ( "`extern crate foo = bar` syntax", "write `extern crate bar as foo` instead" + ), + ObsoleteClosureType => ( + "`|uint| -> bool` closure type syntax", + "use unboxed closures instead, no type annotation needed" ) }; diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 9bc91a95841..678a3c574f5 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -1227,32 +1227,29 @@ impl<'a> Parser<'a> { */ - let unsafety = self.parse_unsafety(); + let ty_closure_span = self.last_span; - let lifetime_defs = self.parse_legacy_lifetime_defs(lifetime_defs); + // To be helpful, parse the closure type as ever + let _ = self.parse_unsafety(); - let inputs = if self.eat(&token::OrOr) { - Vec::new() - } else { + let _ = self.parse_legacy_lifetime_defs(lifetime_defs); + + if !self.eat(&token::OrOr) { self.expect_or(); - let inputs = self.parse_seq_to_before_or( + let _ = self.parse_seq_to_before_or( &token::Comma, |p| p.parse_arg_general(false)); self.expect_or(); - inputs - }; + } - let bounds = self.parse_colon_then_ty_param_bounds(BoundParsingMode::Bare); + let _ = self.parse_colon_then_ty_param_bounds(BoundParsingMode::Bare); - let output = self.parse_ret_ty(); - let decl = P(FnDecl { - inputs: inputs, - output: output, - variadic: false - }); + let _ = self.parse_ret_ty(); - panic!("stub"); + self.obsolete(ty_closure_span, ObsoleteClosureType); + + TyInfer } pub fn parse_unsafety(&mut self) -> Unsafety { -- cgit 1.4.1-3-g733a5 From 799332fa3f968544831ed66e4e32bf331beddbc0 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sun, 4 Jan 2015 10:42:11 -0500 Subject: syntax: remove dead code --- src/libsyntax/parse/parser.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/libsyntax/parse') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 678a3c574f5..28c7293fc26 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -14,7 +14,7 @@ pub use self::PathParsingMode::*; use self::ItemOrViewItem::*; use abi; -use ast::{AssociatedType, BareFnTy, ClosureTy}; +use ast::{AssociatedType, BareFnTy}; use ast::{RegionTyParamBound, TraitTyParamBound, TraitBoundModifier}; use ast::{ProvidedMethod, Public, Unsafety}; use ast::{Mod, BiAdd, Arg, Arm, Attribute, BindByRef, BindByValue}; @@ -30,7 +30,6 @@ use ast::{ExprLit, ExprLoop, ExprMac, ExprRange}; use ast::{ExprMethodCall, ExprParen, ExprPath}; use ast::{ExprRepeat, ExprRet, ExprStruct, ExprTup, ExprUnary}; use ast::{ExprVec, ExprWhile, ExprWhileLet, ExprForLoop, Field, FnDecl}; -use ast::{Many}; use ast::{FnUnboxedClosureKind, FnMutUnboxedClosureKind}; use ast::{FnOnceUnboxedClosureKind}; use ast::{ForeignItem, ForeignItemStatic, ForeignItemFn, ForeignMod, FunctionRetTy}; -- cgit 1.4.1-3-g733a5