Remove the prefix in ObsoleteSyntax variants
This commit is contained in:
parent
f11f3e7bae
commit
595a082587
2 changed files with 34 additions and 34 deletions
|
@ -13,8 +13,6 @@
|
||||||
//!
|
//!
|
||||||
//! Obsolete syntax that becomes too hard to parse can be removed.
|
//! Obsolete syntax that becomes too hard to parse can be removed.
|
||||||
|
|
||||||
pub use self::ObsoleteSyntax::*;
|
|
||||||
|
|
||||||
use ast::{Expr, ExprTup};
|
use ast::{Expr, ExprTup};
|
||||||
use codemap::Span;
|
use codemap::Span;
|
||||||
use parse::parser;
|
use parse::parser;
|
||||||
|
@ -24,16 +22,16 @@ use ptr::P;
|
||||||
/// The specific types of unsupported syntax
|
/// The specific types of unsupported syntax
|
||||||
#[derive(Copy, PartialEq, Eq, Hash)]
|
#[derive(Copy, PartialEq, Eq, Hash)]
|
||||||
pub enum ObsoleteSyntax {
|
pub enum ObsoleteSyntax {
|
||||||
ObsoleteOwnedType,
|
OwnedType,
|
||||||
ObsoleteOwnedExpr,
|
OwnedExpr,
|
||||||
ObsoleteOwnedPattern,
|
OwnedPattern,
|
||||||
ObsoleteOwnedVector,
|
OwnedVector,
|
||||||
ObsoleteOwnedSelf,
|
OwnedSelf,
|
||||||
ObsoleteImportRenaming,
|
ImportRenaming,
|
||||||
ObsoleteSubsliceMatch,
|
SubsliceMatch,
|
||||||
ObsoleteExternCrateRenaming,
|
ExternCrateRenaming,
|
||||||
ObsoleteProcType,
|
ProcType,
|
||||||
ObsoleteProcExpr,
|
ProcExpr,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait ParserObsoleteMethods {
|
pub trait ParserObsoleteMethods {
|
||||||
|
@ -55,43 +53,43 @@ impl<'a> ParserObsoleteMethods for parser::Parser<'a> {
|
||||||
/// Reports an obsolete syntax non-fatal error.
|
/// Reports an obsolete syntax non-fatal error.
|
||||||
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
|
fn obsolete(&mut self, sp: Span, kind: ObsoleteSyntax) {
|
||||||
let (kind_str, desc) = match kind {
|
let (kind_str, desc) = match kind {
|
||||||
ObsoleteProcType => (
|
ObsoleteSyntax::ProcType => (
|
||||||
"the `proc` type",
|
"the `proc` type",
|
||||||
"use unboxed closures instead",
|
"use unboxed closures instead",
|
||||||
),
|
),
|
||||||
ObsoleteProcExpr => (
|
ObsoleteSyntax::ProcExpr => (
|
||||||
"`proc` expression",
|
"`proc` expression",
|
||||||
"use a `move ||` expression instead",
|
"use a `move ||` expression instead",
|
||||||
),
|
),
|
||||||
ObsoleteOwnedType => (
|
ObsoleteSyntax::OwnedType => (
|
||||||
"`~` notation for owned pointers",
|
"`~` notation for owned pointers",
|
||||||
"use `Box<T>` in `std::owned` instead"
|
"use `Box<T>` in `std::owned` instead"
|
||||||
),
|
),
|
||||||
ObsoleteOwnedExpr => (
|
ObsoleteSyntax::OwnedExpr => (
|
||||||
"`~` notation for owned pointer allocation",
|
"`~` notation for owned pointer allocation",
|
||||||
"use the `box` operator instead of `~`"
|
"use the `box` operator instead of `~`"
|
||||||
),
|
),
|
||||||
ObsoleteOwnedPattern => (
|
ObsoleteSyntax::OwnedPattern => (
|
||||||
"`~` notation for owned pointer patterns",
|
"`~` notation for owned pointer patterns",
|
||||||
"use the `box` operator instead of `~`"
|
"use the `box` operator instead of `~`"
|
||||||
),
|
),
|
||||||
ObsoleteOwnedVector => (
|
ObsoleteSyntax::OwnedVector => (
|
||||||
"`~[T]` is no longer a type",
|
"`~[T]` is no longer a type",
|
||||||
"use the `Vec` type instead"
|
"use the `Vec` type instead"
|
||||||
),
|
),
|
||||||
ObsoleteOwnedSelf => (
|
ObsoleteSyntax::OwnedSelf => (
|
||||||
"`~self` is no longer supported",
|
"`~self` is no longer supported",
|
||||||
"write `self: Box<Self>` instead"
|
"write `self: Box<Self>` instead"
|
||||||
),
|
),
|
||||||
ObsoleteImportRenaming => (
|
ObsoleteSyntax::ImportRenaming => (
|
||||||
"`use foo = bar` syntax",
|
"`use foo = bar` syntax",
|
||||||
"write `use bar as foo` instead"
|
"write `use bar as foo` instead"
|
||||||
),
|
),
|
||||||
ObsoleteSubsliceMatch => (
|
ObsoleteSyntax::SubsliceMatch => (
|
||||||
"subslice match syntax",
|
"subslice match syntax",
|
||||||
"instead of `..xs`, write `xs..` in a pattern"
|
"instead of `..xs`, write `xs..` in a pattern"
|
||||||
),
|
),
|
||||||
ObsoleteExternCrateRenaming => (
|
ObsoleteSyntax::ExternCrateRenaming => (
|
||||||
"`extern crate foo = bar` syntax",
|
"`extern crate foo = bar` syntax",
|
||||||
"write `extern crate bar as foo` instead"
|
"write `extern crate bar as foo` instead"
|
||||||
)
|
)
|
||||||
|
|
|
@ -1156,7 +1156,7 @@ impl<'a> Parser<'a> {
|
||||||
let _ = self.parse_colon_then_ty_param_bounds(BoundParsingMode::Bare);
|
let _ = self.parse_colon_then_ty_param_bounds(BoundParsingMode::Bare);
|
||||||
let _ = self.parse_ret_ty();
|
let _ = self.parse_ret_ty();
|
||||||
|
|
||||||
self.obsolete(proc_span, ObsoleteProcType);
|
self.obsolete(proc_span, ObsoleteSyntax::ProcType);
|
||||||
|
|
||||||
TyInfer
|
TyInfer
|
||||||
}
|
}
|
||||||
|
@ -1521,8 +1521,10 @@ impl<'a> Parser<'a> {
|
||||||
self.bump();
|
self.bump();
|
||||||
let last_span = self.last_span;
|
let last_span = self.last_span;
|
||||||
match self.token {
|
match self.token {
|
||||||
token::OpenDelim(token::Bracket) => self.obsolete(last_span, ObsoleteOwnedVector),
|
token::OpenDelim(token::Bracket) => {
|
||||||
_ => self.obsolete(last_span, ObsoleteOwnedType)
|
self.obsolete(last_span, ObsoleteSyntax::OwnedVector)
|
||||||
|
}
|
||||||
|
_ => self.obsolete(last_span, ObsoleteSyntax::OwnedType)
|
||||||
}
|
}
|
||||||
TyTup(vec![self.parse_ty()])
|
TyTup(vec![self.parse_ty()])
|
||||||
} else if self.check(&token::BinOp(token::Star)) {
|
} else if self.check(&token::BinOp(token::Star)) {
|
||||||
|
@ -2285,7 +2287,7 @@ impl<'a> Parser<'a> {
|
||||||
let span = self.last_span;
|
let span = self.last_span;
|
||||||
let _ = self.parse_proc_decl();
|
let _ = self.parse_proc_decl();
|
||||||
let _ = self.parse_expr();
|
let _ = self.parse_expr();
|
||||||
return self.obsolete_expr(span, ObsoleteProcExpr);
|
return self.obsolete_expr(span, ObsoleteSyntax::ProcExpr);
|
||||||
}
|
}
|
||||||
if self.eat_keyword(keywords::If) {
|
if self.eat_keyword(keywords::If) {
|
||||||
return self.parse_if_expr();
|
return self.parse_if_expr();
|
||||||
|
@ -2860,9 +2862,9 @@ impl<'a> Parser<'a> {
|
||||||
let last_span = self.last_span;
|
let last_span = self.last_span;
|
||||||
match self.token {
|
match self.token {
|
||||||
token::OpenDelim(token::Bracket) => {
|
token::OpenDelim(token::Bracket) => {
|
||||||
self.obsolete(last_span, ObsoleteOwnedVector)
|
self.obsolete(last_span, ObsoleteSyntax::OwnedVector)
|
||||||
},
|
},
|
||||||
_ => self.obsolete(last_span, ObsoleteOwnedExpr)
|
_ => self.obsolete(last_span, ObsoleteSyntax::OwnedExpr)
|
||||||
}
|
}
|
||||||
|
|
||||||
let e = self.parse_prefix_expr();
|
let e = self.parse_prefix_expr();
|
||||||
|
@ -3233,7 +3235,7 @@ impl<'a> Parser<'a> {
|
||||||
} else {
|
} else {
|
||||||
let _ = self.parse_pat();
|
let _ = self.parse_pat();
|
||||||
let span = self.span;
|
let span = self.span;
|
||||||
self.obsolete(span, ObsoleteSubsliceMatch);
|
self.obsolete(span, ObsoleteSyntax::SubsliceMatch);
|
||||||
}
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -3349,7 +3351,7 @@ impl<'a> Parser<'a> {
|
||||||
pat = PatBox(sub);
|
pat = PatBox(sub);
|
||||||
let last_span = self.last_span;
|
let last_span = self.last_span;
|
||||||
hi = last_span.hi;
|
hi = last_span.hi;
|
||||||
self.obsolete(last_span, ObsoleteOwnedPattern);
|
self.obsolete(last_span, ObsoleteSyntax::OwnedPattern);
|
||||||
return P(ast::Pat {
|
return P(ast::Pat {
|
||||||
id: ast::DUMMY_NODE_ID,
|
id: ast::DUMMY_NODE_ID,
|
||||||
node: pat,
|
node: pat,
|
||||||
|
@ -4463,7 +4465,7 @@ impl<'a> Parser<'a> {
|
||||||
self.bump();
|
self.bump();
|
||||||
drop(self.expect_self_ident());
|
drop(self.expect_self_ident());
|
||||||
let last_span = self.last_span;
|
let last_span = self.last_span;
|
||||||
self.obsolete(last_span, ObsoleteOwnedSelf)
|
self.obsolete(last_span, ObsoleteSyntax::OwnedSelf)
|
||||||
}
|
}
|
||||||
SelfStatic
|
SelfStatic
|
||||||
}
|
}
|
||||||
|
@ -4514,7 +4516,7 @@ impl<'a> Parser<'a> {
|
||||||
self.bump();
|
self.bump();
|
||||||
drop(self.expect_self_ident());
|
drop(self.expect_self_ident());
|
||||||
let last_span = self.last_span;
|
let last_span = self.last_span;
|
||||||
self.obsolete(last_span, ObsoleteOwnedSelf);
|
self.obsolete(last_span, ObsoleteSyntax::OwnedSelf);
|
||||||
SelfStatic
|
SelfStatic
|
||||||
} else {
|
} else {
|
||||||
SelfStatic
|
SelfStatic
|
||||||
|
@ -5343,7 +5345,7 @@ impl<'a> Parser<'a> {
|
||||||
self.bump();
|
self.bump();
|
||||||
let path = self.parse_str();
|
let path = self.parse_str();
|
||||||
let span = self.span;
|
let span = self.span;
|
||||||
self.obsolete(span, ObsoleteExternCrateRenaming);
|
self.obsolete(span, ObsoleteSyntax::ExternCrateRenaming);
|
||||||
Some(path)
|
Some(path)
|
||||||
} else if self.eat_keyword(keywords::As) {
|
} else if self.eat_keyword(keywords::As) {
|
||||||
// skip the ident if there is one
|
// skip the ident if there is one
|
||||||
|
@ -6000,7 +6002,7 @@ impl<'a> Parser<'a> {
|
||||||
path.push(id);
|
path.push(id);
|
||||||
}
|
}
|
||||||
let span = mk_sp(path_lo, self.span.hi);
|
let span = mk_sp(path_lo, self.span.hi);
|
||||||
self.obsolete(span, ObsoleteImportRenaming);
|
self.obsolete(span, ObsoleteSyntax::ImportRenaming);
|
||||||
let path = ast::Path {
|
let path = ast::Path {
|
||||||
span: span,
|
span: span,
|
||||||
global: false,
|
global: false,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue