]> git.lizzy.rs Git - rust.git/commitdiff
Remove parsing of obsolete pre-1.0 syntaxes
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Fri, 26 Aug 2016 16:23:42 +0000 (19:23 +0300)
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>
Tue, 13 Sep 2016 20:33:50 +0000 (23:33 +0300)
src/libsyntax/parse/obsolete.rs
src/libsyntax/parse/parser.rs
src/test/parse-fail/obsolete-closure-kind.rs [deleted file]

index a1d7ddcdf4bdf5fbe19a2af879c034ad65bdf051..a46a788ca0808ef01aa409eba76ad10ee177e6ab 100644 (file)
@@ -19,8 +19,7 @@
 /// The specific types of unsupported syntax
 #[derive(Copy, Clone, PartialEq, Eq, Hash)]
 pub enum ObsoleteSyntax {
-    ClosureKind,
-    ExternCrateString,
+    // Nothing here at the moment
 }
 
 pub trait ParserObsoleteMethods {
@@ -36,18 +35,10 @@ fn report(&mut self,
 
 impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
     /// Reports an obsolete syntax non-fatal error.
+    #[allow(unused_variables)]
     fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
         let (kind_str, desc, error) = match kind {
-            ObsoleteSyntax::ClosureKind => (
-                "`:`, `&mut:`, or `&:`",
-                "rely on inference instead",
-                true,
-            ),
-            ObsoleteSyntax::ExternCrateString => (
-                "\"crate-name\"",
-                "use an identifier not in quotes instead",
-                false, // warning for now
-            ),
+            // Nothing here at the moment
         };
 
         self.report(sp, kind, kind_str, desc, error);
index 6a0e40edded59ab09bc935239209db5c1a64872f..d0936fd981b508390f488664a1d2937e9c703517 100644 (file)
@@ -47,7 +47,7 @@
 use parse::classify;
 use parse::common::SeqSep;
 use parse::lexer::{Reader, TokenAndSpan};
-use parse::obsolete::{ParserObsoleteMethods, ObsoleteSyntax};
+use parse::obsolete::ObsoleteSyntax;
 use parse::token::{self, intern, MatchNt, SubstNt, SpecialVarNt, InternedString};
 use parse::token::{keywords, SpecialMacroVar};
 use parse::{new_sub_parser_from_file, ParseSess};
@@ -1165,36 +1165,6 @@ pub fn parse_ty_bare_fn(&mut self, lifetime_defs: Vec<ast::LifetimeDef>)
         })))
     }
 
-    /// Parses an obsolete closure kind (`&:`, `&mut:`, or `:`).
-    pub fn parse_obsolete_closure_kind(&mut self) -> PResult<'a, ()> {
-         let lo = self.span.lo;
-        if
-            self.check(&token::BinOp(token::And)) &&
-            self.look_ahead(1, |t| t.is_keyword(keywords::Mut)) &&
-            self.look_ahead(2, |t| *t == token::Colon)
-        {
-            self.bump();
-            self.bump();
-            self.bump();
-        } else if
-            self.token == token::BinOp(token::And) &&
-            self.look_ahead(1, |t| *t == token::Colon)
-        {
-            self.bump();
-            self.bump();
-        } else if
-            self.eat(&token::Colon)
-        {
-            /* nothing */
-        } else {
-            return Ok(());
-        }
-
-        let span = mk_sp(lo, self.span.hi);
-        self.obsolete(span, ObsoleteSyntax::ClosureKind);
-        Ok(())
-    }
-
     pub fn parse_unsafety(&mut self) -> PResult<'a, Unsafety> {
         if self.eat_keyword(keywords::Unsafe) {
             return Ok(Unsafety::Unsafe);
@@ -4728,7 +4698,6 @@ fn parse_fn_block_decl(&mut self) -> PResult<'a, P<FnDecl>> {
                 Vec::new()
             } else {
                 self.expect(&token::BinOp(token::Or))?;
-                self.parse_obsolete_closure_kind()?;
                 let args = self.parse_seq_to_before_end(
                     &token::BinOp(token::Or),
                     SeqSep::trailing_allowed(token::Comma),
diff --git a/src/test/parse-fail/obsolete-closure-kind.rs b/src/test/parse-fail/obsolete-closure-kind.rs
deleted file mode 100644 (file)
index 89134e8..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test that we generate obsolete syntax errors around usages of closure kinds: `|:|`, `|&:|` and
-// `|&mut:|`.
-
-fn main() {
-    let a = |:| {};  //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
-    let a = |&:| {};  //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
-    let a = |&mut:| {};  //~ ERROR obsolete syntax: `:`, `&mut:`, or `&:`
-}