libsyntax: Stop parsing bare functions in preparation for switching them over

This commit is contained in:
Patrick Walton 2013-03-07 15:44:21 -08:00
parent d18f785457
commit bd2d17e4a1
8 changed files with 40 additions and 9 deletions

View File

@ -599,7 +599,9 @@ pub mod linear {
}
/// Visit the values representing the intersection
pure fn intersection(&self, other: &LinearSet<T>, f: &fn(&T) -> bool) {
pure fn intersection(&self,
other: &LinearSet<T>,
f: &fn(&T) -> bool) {
for self.each |v| {
if other.contains(v) {
if !f(v) { return }

View File

@ -67,7 +67,10 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T }
* Iterate over the range [`start`,`start`+`step`..`stop`)
*
*/
pub pure fn range_step(start: T, stop: T, step: T_SIGNED, it: &fn(T) -> bool) {
pub pure fn range_step(start: T,
stop: T,
step: T_SIGNED,
it: &fn(T) -> bool) {
let mut i = start;
if step == 0 {
fail!(~"range_step called with step == 0");

View File

@ -491,7 +491,10 @@ pub pure fn split(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] {
* Splits a string into substrings using a character function, cutting at
* most `count` times.
*/
pub pure fn splitn(s: &str, sepfn: &fn(char) -> bool, count: uint) -> ~[~str] {
pub pure fn splitn(s: &str,
sepfn: &fn(char) -> bool,
count: uint)
-> ~[~str] {
split_inner(s, sepfn, count, true)
}
@ -1246,8 +1249,11 @@ pub pure fn find_from(s: &str, start: uint, f: &fn(char)
* or equal to `len(s)`. `start` must be the index of a character
* boundary, as defined by `is_char_boundary`.
*/
pub pure fn find_between(s: &str, start: uint, end: uint, f: &fn(char) -> bool)
-> Option<uint> {
pub pure fn find_between(s: &str,
start: uint,
end: uint,
f: &fn(char) -> bool)
-> Option<uint> {
fail_unless!(start <= end);
fail_unless!(end <= len(s));
fail_unless!(is_char_boundary(s, start));

View File

@ -81,7 +81,10 @@ impl<T> Map<uint, T> for TrieMap<T> {
/// Visit all values in order
#[inline(always)]
pure fn each_value(&self, f: &fn(&T) -> bool) { self.each(|&(_, v)| f(v)) }
pure fn each_value(&self,
f: &fn(&T) -> bool) {
self.each(|&(_, v)| f(v))
}
/// Return the value corresponding to the key in the map
#[inline(hint)]

View File

@ -68,7 +68,7 @@ pub unsafe fn read(prompt: ~str) -> Option<~str> {
}
}
pub type CompletionCb = @fn(~str, fn(~str));
pub type CompletionCb<'self> = @fn(~str, &'self fn(~str));
fn complete_key(_v: @CompletionCb) {}

View File

@ -138,7 +138,9 @@ impl<K: TotalOrd, V> Map<K, V> for TreeMap<K, V> {
pure fn each_key(&self, f: &fn(&K) -> bool) { self.each(|&(k, _)| f(k)) }
/// Visit all values in order
pure fn each_value(&self, f: &fn(&V) -> bool) { self.each(|&(_, v)| f(v)) }
pure fn each_value(&self, f: &fn(&V) -> bool) {
self.each(|&(_, v)| f(v))
}
/// Return the value corresponding to the key in the map
pure fn find(&self, key: &K) -> Option<&self/V> {

View File

@ -53,6 +53,7 @@ pub enum ObsoleteSyntax {
ObsoleteRecordPattern,
ObsoleteAssertion,
ObsoletePostFnTySigil,
ObsoleteBareFnType,
}
impl to_bytes::IterBytes for ObsoleteSyntax {
@ -166,6 +167,10 @@ pub impl Parser {
"Rather than `fn@`, `fn~`, or `fn&`, \
write `@fn`, `~fn`, and `&fn` respectively"
),
ObsoleteBareFnType => (
"bare function type",
"use `&fn` or `extern fn` instead"
),
};
self.report(sp, kind, kind_str, desc);

View File

@ -76,7 +76,11 @@ use parse::obsolete::{ObsoleteUnsafeBlock, ObsoleteImplSyntax};
use parse::obsolete::{ObsoleteTraitBoundSeparator, ObsoleteMutOwnedPointer};
use parse::obsolete::{ObsoleteMutVector, ObsoleteTraitImplVisibility};
use parse::obsolete::{ObsoleteRecordType, ObsoleteRecordPattern};
<<<<<<< HEAD
use parse::obsolete::{ObsoleteAssertion, ObsoletePostFnTySigil};
=======
use parse::obsolete::{ObsoleteAssertion, ObsoleteBareFnType};
>>>>>>> libsyntax: Stop parsing bare functions in preparation for switching them over
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};
@ -647,8 +651,14 @@ pub impl Parser {
} else if self.eat_keyword(&~"extern") {
self.parse_ty_bare_fn()
} else if self.token_is_closure_keyword(&copy *self.token) {
<<<<<<< HEAD
// self.warn(fmt!("Old-school closure keyword"));
self.parse_ty_closure(ast::BorrowedSigil, None)
=======
let result = self.parse_ty_closure(None, None);
self.obsolete(*self.last_span, ObsoleteBareFnType);
result
>>>>>>> libsyntax: Stop parsing bare functions in preparation for switching them over
} else if *self.token == token::MOD_SEP
|| is_ident_or_path(&*self.token) {
let path = self.parse_path_with_tps(colons_before_params);
@ -2813,7 +2823,7 @@ pub impl Parser {
fn parse_fn_decl_with_self(
&self,
parse_arg_fn:
fn(&Parser) -> arg_or_capture_item
&fn(&Parser) -> arg_or_capture_item
) -> (self_ty, fn_decl) {
fn maybe_parse_self_ty(
cnstr: &fn(+v: mutability) -> ast::self_ty_,