Skip to content

Commit 5d8e2dc

Browse files
committed
libsyntax: Stop parsing pure and static
1 parent 3eda11a commit 5d8e2dc

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

src/libcore/rt/sched.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,7 @@ impl Task {
311311
};
312312
}
313313

314-
static priv fn build_start_wrapper(start: ~fn()) -> ~fn() {
314+
priv fn build_start_wrapper(start: ~fn()) -> ~fn() {
315315
// XXX: The old code didn't have this extra allocation
316316
let wrapper: ~fn() = || {
317317
start();

src/librustpkg/rustpkg.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct PackageScript {
5757
}
5858

5959
impl PackageScript {
60-
static fn parse(parent: &Path) -> Result<PackageScript, ~str> {
60+
fn parse(parent: &Path) -> Result<PackageScript, ~str> {
6161
let script = parent.push(~"pkg.rs");
6262

6363
if !os::path_exists(&script) {

src/libsyntax/parse/obsolete.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ pub enum ObsoleteSyntax {
5959
ObsoleteImplicitSelf,
6060
ObsoleteLifetimeNotation,
6161
ObsoleteConstManagedPointer,
62+
ObsoletePurity,
63+
ObsoleteStaticMethod,
6264
}
6365

6466
impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -198,6 +200,14 @@ pub impl Parser {
198200
"const `@` pointer",
199201
"instead of `@const Foo`, write `@Foo`"
200202
),
203+
ObsoletePurity => (
204+
"pure function",
205+
"remove `pure`"
206+
),
207+
ObsoleteStaticMethod => (
208+
"`static` notation",
209+
"`static` is superfluous; remove it"
210+
),
201211
};
202212

203213
self.report(sp, kind, kind_str, desc);

src/libsyntax/parse/parser.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil};
8080
use parse::obsolete::{ObsoleteBareFnType, ObsoleteNewtypeEnum};
8181
use parse::obsolete::{ObsoleteMode, ObsoleteImplicitSelf};
8282
use parse::obsolete::{ObsoleteLifetimeNotation, ObsoleteConstManagedPointer};
83+
use parse::obsolete::{ObsoletePurity, ObsoleteStaticMethod};
8384
use parse::prec::{as_prec, token_to_binop};
8485
use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
8586
use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
@@ -413,7 +414,7 @@ pub impl Parser {
413414

414415
fn parse_purity(&self) -> purity {
415416
if self.eat_keyword(&~"pure") {
416-
// NB: We parse this as impure for bootstrapping purposes.
417+
self.obsolete(*self.last_span, ObsoletePurity);
417418
return impure_fn;
418419
} else if self.eat_keyword(&~"unsafe") {
419420
return unsafe_fn;
@@ -2684,7 +2685,7 @@ pub impl Parser {
26842685

26852686
fn parse_optional_purity(&self) -> ast::purity {
26862687
if self.eat_keyword(&~"pure") {
2687-
// NB: We parse this as impure for bootstrapping purposes.
2688+
self.obsolete(*self.last_span, ObsoletePurity);
26882689
ast::impure_fn
26892690
} else if self.eat_keyword(&~"unsafe") {
26902691
ast::unsafe_fn
@@ -3338,8 +3339,14 @@ pub impl Parser {
33383339
else if self.eat_keyword(&~"priv") { private }
33393340
else { inherited }
33403341
}
3342+
33413343
fn parse_staticness(&self) -> bool {
3342-
self.eat_keyword(&~"static")
3344+
if self.eat_keyword(&~"static") {
3345+
self.obsolete(*self.last_span, ObsoleteStaticMethod);
3346+
true
3347+
} else {
3348+
false
3349+
}
33433350
}
33443351

33453352
// given a termination token and a vector of already-parsed
@@ -3577,6 +3584,7 @@ pub impl Parser {
35773584
fn parse_fn_purity(&self) -> purity {
35783585
if self.eat_keyword(&~"fn") { impure_fn }
35793586
else if self.eat_keyword(&~"pure") {
3587+
self.obsolete(*self.last_span, ObsoletePurity);
35803588
self.expect_keyword(&~"fn");
35813589
// NB: We parse this as impure for bootstrapping purposes.
35823590
impure_fn
@@ -3976,7 +3984,7 @@ pub impl Parser {
39763984
}
39773985
if items_allowed && self.eat_keyword(&~"pure") {
39783986
// PURE FUNCTION ITEM
3979-
// NB: We parse this as impure for bootstrapping purposes.
3987+
self.obsolete(*self.last_span, ObsoletePurity);
39803988
self.expect_keyword(&~"fn");
39813989
let (ident, item_, extra_attrs) = self.parse_item_fn(impure_fn);
39823990
return iovi_item(self.mk_item(lo, self.last_span.hi, ident, item_,

src/test/auxiliary/static_fn_inline_xc_aux.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@
1111

1212
pub mod num {
1313
pub trait Num2 {
14-
static fn from_int2(n: int) -> Self;
14+
fn from_int2(n: int) -> Self;
1515
}
1616
}
1717

1818
pub mod float {
1919
impl ::num::Num2 for float {
2020
#[inline]
21-
static fn from_int2(n: int) -> float { return n as float; }
21+
fn from_int2(n: int) -> float { return n as float; }
2222
}
2323
}
2424

0 commit comments

Comments
 (0)