libsyntax: Stop parsing pure
and static
This commit is contained in:
parent
d60a7259f9
commit
fa70709e07
@ -311,7 +311,7 @@ impl Task {
|
||||
};
|
||||
}
|
||||
|
||||
static priv fn build_start_wrapper(start: ~fn()) -> ~fn() {
|
||||
priv fn build_start_wrapper(start: ~fn()) -> ~fn() {
|
||||
// XXX: The old code didn't have this extra allocation
|
||||
let wrapper: ~fn() = || {
|
||||
start();
|
||||
|
@ -57,7 +57,7 @@ struct PackageScript {
|
||||
}
|
||||
|
||||
impl PackageScript {
|
||||
static fn parse(parent: &Path) -> Result<PackageScript, ~str> {
|
||||
fn parse(parent: &Path) -> Result<PackageScript, ~str> {
|
||||
let script = parent.push(~"pkg.rs");
|
||||
|
||||
if !os::path_exists(&script) {
|
||||
|
@ -59,6 +59,8 @@ pub enum ObsoleteSyntax {
|
||||
ObsoleteImplicitSelf,
|
||||
ObsoleteLifetimeNotation,
|
||||
ObsoleteConstManagedPointer,
|
||||
ObsoletePurity,
|
||||
ObsoleteStaticMethod,
|
||||
}
|
||||
|
||||
impl to_bytes::IterBytes for ObsoleteSyntax {
|
||||
@ -198,6 +200,14 @@ pub impl Parser {
|
||||
"const `@` pointer",
|
||||
"instead of `@const Foo`, write `@Foo`"
|
||||
),
|
||||
ObsoletePurity => (
|
||||
"pure function",
|
||||
"remove `pure`"
|
||||
),
|
||||
ObsoleteStaticMethod => (
|
||||
"`static` notation",
|
||||
"`static` is superfluous; remove it"
|
||||
),
|
||||
};
|
||||
|
||||
self.report(sp, kind, kind_str, desc);
|
||||
|
@ -80,6 +80,7 @@ use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil};
|
||||
use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum};
|
||||
use parse::obsolete::{ObsoleteMode, ObsoleteImplicitSelf};
|
||||
use parse::obsolete::{ObsoleteLifetimeNotation, ObsoleteConstManagedPointer};
|
||||
use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod};
|
||||
use parse::prec::{as_prec, token_to_binop};
|
||||
use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
|
||||
use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
|
||||
@ -413,7 +414,7 @@ pub impl Parser {
|
||||
|
||||
fn parse_purity(&self) -> purity {
|
||||
if self.eat_keyword(&~"pure") {
|
||||
// NB: We parse this as impure for bootstrapping purposes.
|
||||
self.obsolete(*self.last_span, ObsoletePurity);
|
||||
return impure_fn;
|
||||
} else if self.eat_keyword(&~"unsafe") {
|
||||
return unsafe_fn;
|
||||
@ -2684,7 +2685,7 @@ pub impl Parser {
|
||||
|
||||
fn parse_optional_purity(&self) -> ast::purity {
|
||||
if self.eat_keyword(&~"pure") {
|
||||
// NB: We parse this as impure for bootstrapping purposes.
|
||||
self.obsolete(*self.last_span, ObsoletePurity);
|
||||
ast::impure_fn
|
||||
} else if self.eat_keyword(&~"unsafe") {
|
||||
ast::unsafe_fn
|
||||
@ -3341,8 +3342,14 @@ pub impl Parser {
|
||||
else if self.eat_keyword(&~"priv") { private }
|
||||
else { inherited }
|
||||
}
|
||||
|
||||
fn parse_staticness(&self) -> bool {
|
||||
self.eat_keyword(&~"static")
|
||||
if self.eat_keyword(&~"static") {
|
||||
self.obsolete(*self.last_span, ObsoleteStaticMethod);
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
// given a termination token and a vector of already-parsed
|
||||
@ -3580,6 +3587,7 @@ pub impl Parser {
|
||||
fn parse_fn_purity(&self) -> purity {
|
||||
if self.eat_keyword(&~"fn") { impure_fn }
|
||||
else if self.eat_keyword(&~"pure") {
|
||||
self.obsolete(*self.last_span, ObsoletePurity);
|
||||
self.expect_keyword(&~"fn");
|
||||
// NB: We parse this as impure for bootstrapping purposes.
|
||||
impure_fn
|
||||
@ -3979,7 +3987,7 @@ pub impl Parser {
|
||||
}
|
||||
if items_allowed && self.eat_keyword(&~"pure") {
|
||||
// PURE FUNCTION ITEM
|
||||
// NB: We parse this as impure for bootstrapping purposes.
|
||||
self.obsolete(*self.last_span, ObsoletePurity);
|
||||
self.expect_keyword(&~"fn");
|
||||
let (ident, item_, extra_attrs) = self.parse_item_fn(impure_fn);
|
||||
return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_,
|
||||
|
@ -11,14 +11,14 @@
|
||||
|
||||
pub mod num {
|
||||
pub trait Num2 {
|
||||
static fn from_int2(n: int) -> Self;
|
||||
fn from_int2(n: int) -> Self;
|
||||
}
|
||||
}
|
||||
|
||||
pub mod float {
|
||||
impl ::num::Num2 for float {
|
||||
#[inline]
|
||||
static fn from_int2(n: int) -> float { return n as float; }
|
||||
fn from_int2(n: int) -> float { return n as float; }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user