From ba3eebd41db384c2a46535e8db8c7b2337d55f0b Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Sun, 23 Sep 2012 04:39:27 -0700 Subject: Make it illegal to use modes in a fn signature with providing an explicit variable name. (Step one to changing the defaults) First step to #3535 --- src/libsyntax/parse/parser.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'src/libsyntax/parse/parser.rs') diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index a6ad5b35484..f2e7245a1d4 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -19,7 +19,8 @@ use obsolete::{ ObsoleteReporter, ObsoleteSyntax, ObsoleteLowerCaseKindBounds, ObsoleteLet, ObsoleteFieldTerminator, ObsoleteStructCtor, - ObsoleteWith, ObsoleteClassMethod, ObsoleteClassTraits + ObsoleteWith, ObsoleteClassMethod, ObsoleteClassTraits, + ObsoleteModeInFnType }; use ast::{_mod, add, alt_check, alt_exhaustive, arg, arm, attribute, bind_by_ref, bind_by_implicit_ref, bind_by_value, bind_by_move, @@ -618,6 +619,15 @@ impl parser { } else { special_idents::invalid } }; + match m { + expl(_) => { + if i == special_idents::invalid { + self.obsolete(copy self.span, ObsoleteModeInFnType); + } + } + _ => {} + } + let t = self.parse_ty(false); {mode: m, ty: t, ident: i, id: self.get_id()} @@ -1585,7 +1595,7 @@ impl parser { } fn parse_sugary_call_expr(keyword: ~str, - ctor: fn(+@expr) -> expr_) -> @expr { + ctor: fn(+v: @expr) -> expr_) -> @expr { let lo = self.last_span; // Parse the callee `foo` in // for foo || { @@ -2400,7 +2410,7 @@ impl parser { fn(parser) -> arg_or_capture_item) -> (self_ty, fn_decl, capture_clause) { - fn maybe_parse_self_ty(cnstr: fn(+mutability) -> ast::self_ty_, + fn maybe_parse_self_ty(cnstr: fn(+v: mutability) -> ast::self_ty_, p: parser) -> ast::self_ty_ { // We need to make sure it isn't a mode or a type if p.token_is_keyword(~"self", p.look_ahead(1)) || -- cgit 1.4.1-3-g733a5