Skip to content

Commit bd2d17e

Browse files
committed
libsyntax: Stop parsing bare functions in preparation for switching them over
1 parent d18f785 commit bd2d17e

File tree

8 files changed

+40
-9
lines changed

8 files changed

+40
-9
lines changed

src/libcore/hashmap.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,9 @@ pub mod linear {
599599
}
600600

601601
/// Visit the values representing the intersection
602-
pure fn intersection(&self, other: &LinearSet<T>, f: &fn(&T) -> bool) {
602+
pure fn intersection(&self,
603+
other: &LinearSet<T>,
604+
f: &fn(&T) -> bool) {
603605
for self.each |v| {
604606
if other.contains(v) {
605607
if !f(v) { return }

src/libcore/num/uint-template.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,10 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T }
6767
* Iterate over the range [`start`,`start`+`step`..`stop`)
6868
*
6969
*/
70-
pub pure fn range_step(start: T, stop: T, step: T_SIGNED, it: &fn(T) -> bool) {
70+
pub pure fn range_step(start: T,
71+
stop: T,
72+
step: T_SIGNED,
73+
it: &fn(T) -> bool) {
7174
let mut i = start;
7275
if step == 0 {
7376
fail!(~"range_step called with step == 0");

src/libcore/str.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,10 @@ pub pure fn split(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] {
491491
* Splits a string into substrings using a character function, cutting at
492492
* most `count` times.
493493
*/
494-
pub pure fn splitn(s: &str, sepfn: &fn(char) -> bool, count: uint) -> ~[~str] {
494+
pub pure fn splitn(s: &str,
495+
sepfn: &fn(char) -> bool,
496+
count: uint)
497+
-> ~[~str] {
495498
split_inner(s, sepfn, count, true)
496499
}
497500

@@ -1246,8 +1249,11 @@ pub pure fn find_from(s: &str, start: uint, f: &fn(char)
12461249
* or equal to `len(s)`. `start` must be the index of a character
12471250
* boundary, as defined by `is_char_boundary`.
12481251
*/
1249-
pub pure fn find_between(s: &str, start: uint, end: uint, f: &fn(char) -> bool)
1250-
-> Option<uint> {
1252+
pub pure fn find_between(s: &str,
1253+
start: uint,
1254+
end: uint,
1255+
f: &fn(char) -> bool)
1256+
-> Option<uint> {
12511257
fail_unless!(start <= end);
12521258
fail_unless!(end <= len(s));
12531259
fail_unless!(is_char_boundary(s, start));

src/libcore/trie.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,10 @@ impl<T> Map<uint, T> for TrieMap<T> {
8181

8282
/// Visit all values in order
8383
#[inline(always)]
84-
pure fn each_value(&self, f: &fn(&T) -> bool) { self.each(|&(_, v)| f(v)) }
84+
pure fn each_value(&self,
85+
f: &fn(&T) -> bool) {
86+
self.each(|&(_, v)| f(v))
87+
}
8588

8689
/// Return the value corresponding to the key in the map
8790
#[inline(hint)]

src/libstd/rl.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub unsafe fn read(prompt: ~str) -> Option<~str> {
6868
}
6969
}
7070

71-
pub type CompletionCb = @fn(~str, fn(~str));
71+
pub type CompletionCb<'self> = @fn(~str, &'self fn(~str));
7272

7373
fn complete_key(_v: @CompletionCb) {}
7474

src/libstd/treemap.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,9 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
138138
pure fn each_key(&self, f: &fn(&K) -> bool) { self.each(|&(k, _)| f(k)) }
139139

140140
/// Visit all values in order
141-
pure fn each_value(&self, f: &fn(&V) -> bool) { self.each(|&(_, v)| f(v)) }
141+
pure fn each_value(&self, f: &fn(&V) -> bool) {
142+
self.each(|&(_, v)| f(v))
143+
}
142144

143145
/// Return the value corresponding to the key in the map
144146
pure fn find(&self, key: &K) -> Option<&self/V> {

src/libsyntax/parse/obsolete.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub enum ObsoleteSyntax {
5353
ObsoleteRecordPattern,
5454
ObsoleteAssertion,
5555
ObsoletePostFnTySigil,
56+
ObsoleteBareFnType,
5657
}
5758

5859
impl to_bytes::IterBytes for ObsoleteSyntax {
@@ -166,6 +167,10 @@ pub impl Parser {
166167
"Rather than `fn@`, `fn~`, or `fn&`, \
167168
write `@fn`, `~fn`, and `&fn` respectively"
168169
),
170+
ObsoleteBareFnType => (
171+
"bare function type",
172+
"use `&fn` or `extern fn` instead"
173+
),
169174
};
170175

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

src/libsyntax/parse/parser.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,11 @@ use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
7676
use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer};
7777
use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility};
7878
use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern};
79+
<<<<<<< HEAD
7980
use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil};
81+
=======
82+
use parse::obsolete::{ObsoleteAssertion, ObsoleteBareFnType};
83+
>>>>>>> libsyntax: Stop parsing bare functions in preparation for switching them over
8084
use parse::prec::{as_prec, token_to_binop};
8185
use parse::token::{can_begin_expr, is_ident, is_ident_or_path};
8286
use parse::token::{is_plain_ident, INTERPOLATED, special_idents};
@@ -647,8 +651,14 @@ pub impl Parser {
647651
} else if self.eat_keyword(&~"extern") {
648652
self.parse_ty_bare_fn()
649653
} else if self.token_is_closure_keyword(&copy *self.token) {
654+
<<<<<<< HEAD
650655
// self.warn(fmt!("Old-school closure keyword"));
651656
self.parse_ty_closure(ast::BorrowedSigil, None)
657+
=======
658+
let result = self.parse_ty_closure(None, None);
659+
self.obsolete(*self.last_span, ObsoleteBareFnType);
660+
result
661+
>>>>>>> libsyntax: Stop parsing bare functions in preparation for switching them over
652662
} else if *self.token == token::MOD_SEP
653663
|| is_ident_or_path(&*self.token) {
654664
let path = self.parse_path_with_tps(colons_before_params);
@@ -2813,7 +2823,7 @@ pub impl Parser {
28132823
fn parse_fn_decl_with_self(
28142824
&self,
28152825
parse_arg_fn:
2816-
fn(&Parser) -> arg_or_capture_item
2826+
&fn(&Parser) -> arg_or_capture_item
28172827
) -> (self_ty, fn_decl) {
28182828
fn maybe_parse_self_ty(
28192829
cnstr: &fn(+v: mutability) -> ast::self_ty_,

0 commit comments

Comments
 (0)