syntax: make the closure type f: |uint| -> bool syntax obsolete

This commit is contained in:
Jorge Aparicio 2015-01-01 17:21:25 -05:00
parent 865aabb662
commit 58b0d7479f
2 changed files with 18 additions and 16 deletions

View File

@ -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"
)
};

View File

@ -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 {