Remove parsing of obsolete pre-1.0 syntaxes
This commit is contained in:
parent
03161e9b12
commit
b57f1099b5
3 changed files with 4 additions and 62 deletions
|
@ -19,8 +19,7 @@ use parse::parser;
|
||||||
/// The specific types of unsupported syntax
|
/// The specific types of unsupported syntax
|
||||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||||
pub enum ObsoleteSyntax {
|
pub enum ObsoleteSyntax {
|
||||||
ClosureKind,
|
// Nothing here at the moment
|
||||||
ExternCrateString,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ParserObsoleteMethods {
|
pub trait ParserObsoleteMethods {
|
||||||
|
@ -36,18 +35,10 @@ pub trait ParserObsoleteMethods {
|
||||||
|
|
||||||
impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
|
impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
|
||||||
/// Reports an obsolete syntax non-fatal error.
|
/// Reports an obsolete syntax non-fatal error.
|
||||||
|
#[allow(unused_variables)]
|
||||||
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
|
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
|
||||||
let (kind_str, desc, error) = match kind {
|
let (kind_str, desc, error) = match kind {
|
||||||
ObsoleteSyntax::ClosureKind => (
|
// Nothing here at the moment
|
||||||
"`:`, `&mut:`, or `&:`",
|
|
||||||
"rely on inference instead",
|
|
||||||
true,
|
|
||||||
),
|
|
||||||
ObsoleteSyntax::ExternCrateString => (
|
|
||||||
"\"crate-name\"",
|
|
||||||
"use an identifier not in quotes instead",
|
|
||||||
false, // warning for now
|
|
||||||
),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
self.report(sp, kind, kind_str, desc, error);
|
self.report(sp, kind, kind_str, desc, error);
|
||||||
|
|
|
@ -47,7 +47,7 @@ use parse;
|
||||||
use parse::classify;
|
use parse::classify;
|
||||||
use parse::common::SeqSep;
|
use parse::common::SeqSep;
|
||||||
use parse::lexer::{Reader, TokenAndSpan};
|
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::{self, intern, MatchNt, SubstNt, SpecialVarNt, InternedString};
|
||||||
use parse::token::{keywords, SpecialMacroVar};
|
use parse::token::{keywords, SpecialMacroVar};
|
||||||
use parse::{new_sub_parser_from_file, ParseSess};
|
use parse::{new_sub_parser_from_file, ParseSess};
|
||||||
|
@ -1165,36 +1165,6 @@ impl<'a> Parser<'a> {
|
||||||
})))
|
})))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// 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> {
|
pub fn parse_unsafety(&mut self) -> PResult<'a, Unsafety> {
|
||||||
if self.eat_keyword(keywords::Unsafe) {
|
if self.eat_keyword(keywords::Unsafe) {
|
||||||
return Ok(Unsafety::Unsafe);
|
return Ok(Unsafety::Unsafe);
|
||||||
|
@ -4728,7 +4698,6 @@ impl<'a> Parser<'a> {
|
||||||
Vec::new()
|
Vec::new()
|
||||||
} else {
|
} else {
|
||||||
self.expect(&token::BinOp(token::Or))?;
|
self.expect(&token::BinOp(token::Or))?;
|
||||||
self.parse_obsolete_closure_kind()?;
|
|
||||||
let args = self.parse_seq_to_before_end(
|
let args = self.parse_seq_to_before_end(
|
||||||
&token::BinOp(token::Or),
|
&token::BinOp(token::Or),
|
||||||
SeqSep::trailing_allowed(token::Comma),
|
SeqSep::trailing_allowed(token::Comma),
|
||||||
|
|
|
@ -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 `&:`
|
|
||||||
}
|
|
Loading…
Add table
Add a link
Reference in a new issue