This commit is contained in:
Aleksey Kladov 2018-08-24 02:14:10 +03:00
parent dc40f1298a
commit a66c94af1b
11 changed files with 28 additions and 28 deletions

View File

@ -130,7 +130,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
let m = p.start();
p.eat(MOVE_KW);
params::param_list_opt_types(p);
if fn_ret_type(p) {
if opt_fn_ret_type(p) {
block(p);
} else {
expr(p);

View File

@ -265,7 +265,7 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
let m = lhs.precede(p);
p.bump();
name_ref(p);
type_args::type_arg_list(p, true);
type_args::opt_type_arg_list(p, true);
if p.at(L_PAREN) {
arg_list(p);
}

View File

@ -225,7 +225,7 @@ fn function(p: &mut Parser, flavor: ItemFlavor) {
name(p);
// test function_type_params
// fn foo<T: Clone + Copy>(){}
type_params::type_param_list(p);
type_params::opt_type_param_list(p);
if p.at(L_PAREN) {
match flavor {
@ -240,11 +240,11 @@ fn function(p: &mut Parser, flavor: ItemFlavor) {
// test function_ret_type
// fn foo() {}
// fn bar() -> () {}
fn_ret_type(p);
opt_fn_ret_type(p);
// test function_where_clause
// fn foo<T>() where T: Copy {}
type_params::where_clause(p);
type_params::opt_where_clause(p);
// test fn_decl
// trait T { fn foo(); }
@ -263,7 +263,7 @@ fn type_def(p: &mut Parser) {
// test type_item_type_params
// type Result<T> = ();
type_params::type_param_list(p);
type_params::opt_type_param_list(p);
if p.at(COLON) {
type_params::bounds(p);
@ -271,7 +271,7 @@ fn type_def(p: &mut Parser) {
// test type_item_where_clause
// type Foo where Foo: Copy = ();
type_params::where_clause(p);
type_params::opt_where_clause(p);
if p.eat(EQ) {
types::type_(p);

View File

@ -5,10 +5,10 @@ pub(super) fn struct_def(p: &mut Parser) {
p.bump();
name(p);
type_params::type_param_list(p);
type_params::opt_type_param_list(p);
match p.current() {
WHERE_KW => {
type_params::where_clause(p);
type_params::opt_where_clause(p);
match p.current() {
SEMI => {
p.bump();
@ -42,8 +42,8 @@ pub(super) fn enum_def(p: &mut Parser) {
assert!(p.at(ENUM_KW));
p.bump();
name(p);
type_params::type_param_list(p);
type_params::where_clause(p);
type_params::opt_type_param_list(p);
type_params::opt_where_clause(p);
if p.expect(L_CURLY) {
while !p.at(EOF) && !p.at(R_CURLY) {
let var = p.start();

View File

@ -6,11 +6,11 @@ pub(super) fn trait_def(p: &mut Parser) {
assert!(p.at(TRAIT_KW));
p.bump();
name(p);
type_params::type_param_list(p);
type_params::opt_type_param_list(p);
if p.at(COLON) {
type_params::bounds(p);
}
type_params::where_clause(p);
type_params::opt_where_clause(p);
p.expect(L_CURLY);
// test trait_item_items
// impl F {
@ -31,7 +31,7 @@ pub(super) fn impl_item(p: &mut Parser) {
assert!(p.at(IMPL_KW));
p.bump();
if choose_type_params_over_qpath(p) {
type_params::type_param_list(p);
type_params::opt_type_param_list(p);
}
// TODO: never type
@ -44,7 +44,7 @@ pub(super) fn impl_item(p: &mut Parser) {
if p.eat(FOR_KW) {
types::type_(p);
}
type_params::where_clause(p);
type_params::opt_where_clause(p);
p.expect(L_CURLY);
// test impl_item_items

View File

@ -113,7 +113,7 @@ fn abi(p: &mut Parser) {
abi.complete(p, ABI);
}
fn fn_ret_type(p: &mut Parser) -> bool {
fn opt_fn_ret_type(p: &mut Parser) -> bool {
if p.at(THIN_ARROW) {
p.bump();
types::type_(p);

View File

@ -45,7 +45,7 @@ fn list_(p: &mut Parser, flavor: Flavor) {
let m = p.start();
p.bump();
if flavor.type_required() {
self_param(p);
opt_self_param(p);
}
while !p.at(EOF) && !p.at(ket) {
value_parameter(p, flavor);
@ -94,7 +94,7 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) {
// fn d(&'a mut self, x: i32) {}
// fn e(mut self) {}
// }
fn self_param(p: &mut Parser) {
fn opt_self_param(p: &mut Parser) {
let m;
if p.at(SELF_KW) || p.at(MUT_KW) && p.nth(1) == SELF_KW {
m = p.start();

View File

@ -69,7 +69,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
match p.current() {
IDENT => {
name_ref(p);
path_generic_args(p, mode);
opt_path_type_args(p, mode);
}
SELF_KW | SUPER_KW => p.bump(),
_ => {
@ -80,7 +80,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
m.complete(p, PATH_SEGMENT);
}
fn path_generic_args(p: &mut Parser, mode: Mode) {
fn opt_path_type_args(p: &mut Parser, mode: Mode) {
match mode {
Mode::Use => return,
Mode::Type => {
@ -88,11 +88,11 @@ fn path_generic_args(p: &mut Parser, mode: Mode) {
// type F = Box<Fn(x: i32) -> ()>;
if p.at(L_PAREN) {
params::param_list_opt_patterns(p);
fn_ret_type(p);
opt_fn_ret_type(p);
} else {
type_args::type_arg_list(p, false)
type_args::opt_type_arg_list(p, false)
}
},
Mode::Expr => type_args::type_arg_list(p, true),
Mode::Expr => type_args::opt_type_arg_list(p, true),
}
}

View File

@ -1,6 +1,6 @@
use super::*;
pub(super) fn type_arg_list(p: &mut Parser, colon_colon_required: bool) {
pub(super) fn opt_type_arg_list(p: &mut Parser, colon_colon_required: bool) {
let m;
match (colon_colon_required, p.nth(0), p.nth(1)) {
(_, COLONCOLON, L_ANGLE) => {

View File

@ -1,6 +1,6 @@
use super::*;
pub(super) fn type_param_list(p: &mut Parser) {
pub(super) fn opt_type_param_list(p: &mut Parser) {
if !p.at(L_ANGLE) {
return;
}
@ -96,7 +96,7 @@ pub(super) fn bounds_without_colon(p: &mut Parser) {
// T: Clone + Copy + 'static,
// Iterator::Item: 'a,
// {}
pub(super) fn where_clause(p: &mut Parser) {
pub(super) fn opt_where_clause(p: &mut Parser) {
if !p.at(WHERE_KW) {
return;
}

View File

@ -174,7 +174,7 @@ fn fn_pointer_type(p: &mut Parser) {
}
// test fn_pointer_type_with_ret
// type F = fn() -> ();
fn_ret_type(p);
opt_fn_ret_type(p);
m.complete(p, FN_POINTER_TYPE);
}
@ -184,7 +184,7 @@ fn for_type(p: &mut Parser) {
assert!(p.at(FOR_KW));
let m = p.start();
p.bump();
type_params::type_param_list(p);
type_params::opt_type_param_list(p);
type_(p);
m.complete(p, FOR_TYPE);
}