mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-02 14:51:48 +00:00
renames
This commit is contained in:
parent
dc40f1298a
commit
a66c94af1b
11 changed files with 28 additions and 28 deletions
|
@ -130,7 +130,7 @@ fn lambda_expr(p: &mut Parser) -> CompletedMarker {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
p.eat(MOVE_KW);
|
p.eat(MOVE_KW);
|
||||||
params::param_list_opt_types(p);
|
params::param_list_opt_types(p);
|
||||||
if fn_ret_type(p) {
|
if opt_fn_ret_type(p) {
|
||||||
block(p);
|
block(p);
|
||||||
} else {
|
} else {
|
||||||
expr(p);
|
expr(p);
|
||||||
|
|
|
@ -265,7 +265,7 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
|
||||||
let m = lhs.precede(p);
|
let m = lhs.precede(p);
|
||||||
p.bump();
|
p.bump();
|
||||||
name_ref(p);
|
name_ref(p);
|
||||||
type_args::type_arg_list(p, true);
|
type_args::opt_type_arg_list(p, true);
|
||||||
if p.at(L_PAREN) {
|
if p.at(L_PAREN) {
|
||||||
arg_list(p);
|
arg_list(p);
|
||||||
}
|
}
|
||||||
|
|
|
@ -225,7 +225,7 @@ fn function(p: &mut Parser, flavor: ItemFlavor) {
|
||||||
name(p);
|
name(p);
|
||||||
// test function_type_params
|
// test function_type_params
|
||||||
// fn foo<T: Clone + Copy>(){}
|
// fn foo<T: Clone + Copy>(){}
|
||||||
type_params::type_param_list(p);
|
type_params::opt_type_param_list(p);
|
||||||
|
|
||||||
if p.at(L_PAREN) {
|
if p.at(L_PAREN) {
|
||||||
match flavor {
|
match flavor {
|
||||||
|
@ -240,11 +240,11 @@ fn function(p: &mut Parser, flavor: ItemFlavor) {
|
||||||
// test function_ret_type
|
// test function_ret_type
|
||||||
// fn foo() {}
|
// fn foo() {}
|
||||||
// fn bar() -> () {}
|
// fn bar() -> () {}
|
||||||
fn_ret_type(p);
|
opt_fn_ret_type(p);
|
||||||
|
|
||||||
// test function_where_clause
|
// test function_where_clause
|
||||||
// fn foo<T>() where T: Copy {}
|
// fn foo<T>() where T: Copy {}
|
||||||
type_params::where_clause(p);
|
type_params::opt_where_clause(p);
|
||||||
|
|
||||||
// test fn_decl
|
// test fn_decl
|
||||||
// trait T { fn foo(); }
|
// trait T { fn foo(); }
|
||||||
|
@ -263,7 +263,7 @@ fn type_def(p: &mut Parser) {
|
||||||
|
|
||||||
// test type_item_type_params
|
// test type_item_type_params
|
||||||
// type Result<T> = ();
|
// type Result<T> = ();
|
||||||
type_params::type_param_list(p);
|
type_params::opt_type_param_list(p);
|
||||||
|
|
||||||
if p.at(COLON) {
|
if p.at(COLON) {
|
||||||
type_params::bounds(p);
|
type_params::bounds(p);
|
||||||
|
@ -271,7 +271,7 @@ fn type_def(p: &mut Parser) {
|
||||||
|
|
||||||
// test type_item_where_clause
|
// test type_item_where_clause
|
||||||
// type Foo where Foo: Copy = ();
|
// type Foo where Foo: Copy = ();
|
||||||
type_params::where_clause(p);
|
type_params::opt_where_clause(p);
|
||||||
|
|
||||||
if p.eat(EQ) {
|
if p.eat(EQ) {
|
||||||
types::type_(p);
|
types::type_(p);
|
||||||
|
|
|
@ -5,10 +5,10 @@ pub(super) fn struct_def(p: &mut Parser) {
|
||||||
p.bump();
|
p.bump();
|
||||||
|
|
||||||
name(p);
|
name(p);
|
||||||
type_params::type_param_list(p);
|
type_params::opt_type_param_list(p);
|
||||||
match p.current() {
|
match p.current() {
|
||||||
WHERE_KW => {
|
WHERE_KW => {
|
||||||
type_params::where_clause(p);
|
type_params::opt_where_clause(p);
|
||||||
match p.current() {
|
match p.current() {
|
||||||
SEMI => {
|
SEMI => {
|
||||||
p.bump();
|
p.bump();
|
||||||
|
@ -42,8 +42,8 @@ pub(super) fn enum_def(p: &mut Parser) {
|
||||||
assert!(p.at(ENUM_KW));
|
assert!(p.at(ENUM_KW));
|
||||||
p.bump();
|
p.bump();
|
||||||
name(p);
|
name(p);
|
||||||
type_params::type_param_list(p);
|
type_params::opt_type_param_list(p);
|
||||||
type_params::where_clause(p);
|
type_params::opt_where_clause(p);
|
||||||
if p.expect(L_CURLY) {
|
if p.expect(L_CURLY) {
|
||||||
while !p.at(EOF) && !p.at(R_CURLY) {
|
while !p.at(EOF) && !p.at(R_CURLY) {
|
||||||
let var = p.start();
|
let var = p.start();
|
||||||
|
|
|
@ -6,11 +6,11 @@ pub(super) fn trait_def(p: &mut Parser) {
|
||||||
assert!(p.at(TRAIT_KW));
|
assert!(p.at(TRAIT_KW));
|
||||||
p.bump();
|
p.bump();
|
||||||
name(p);
|
name(p);
|
||||||
type_params::type_param_list(p);
|
type_params::opt_type_param_list(p);
|
||||||
if p.at(COLON) {
|
if p.at(COLON) {
|
||||||
type_params::bounds(p);
|
type_params::bounds(p);
|
||||||
}
|
}
|
||||||
type_params::where_clause(p);
|
type_params::opt_where_clause(p);
|
||||||
p.expect(L_CURLY);
|
p.expect(L_CURLY);
|
||||||
// test trait_item_items
|
// test trait_item_items
|
||||||
// impl F {
|
// impl F {
|
||||||
|
@ -31,7 +31,7 @@ pub(super) fn impl_item(p: &mut Parser) {
|
||||||
assert!(p.at(IMPL_KW));
|
assert!(p.at(IMPL_KW));
|
||||||
p.bump();
|
p.bump();
|
||||||
if choose_type_params_over_qpath(p) {
|
if choose_type_params_over_qpath(p) {
|
||||||
type_params::type_param_list(p);
|
type_params::opt_type_param_list(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: never type
|
// TODO: never type
|
||||||
|
@ -44,7 +44,7 @@ pub(super) fn impl_item(p: &mut Parser) {
|
||||||
if p.eat(FOR_KW) {
|
if p.eat(FOR_KW) {
|
||||||
types::type_(p);
|
types::type_(p);
|
||||||
}
|
}
|
||||||
type_params::where_clause(p);
|
type_params::opt_where_clause(p);
|
||||||
p.expect(L_CURLY);
|
p.expect(L_CURLY);
|
||||||
|
|
||||||
// test impl_item_items
|
// test impl_item_items
|
||||||
|
|
|
@ -113,7 +113,7 @@ fn abi(p: &mut Parser) {
|
||||||
abi.complete(p, ABI);
|
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) {
|
if p.at(THIN_ARROW) {
|
||||||
p.bump();
|
p.bump();
|
||||||
types::type_(p);
|
types::type_(p);
|
||||||
|
|
|
@ -45,7 +45,7 @@ fn list_(p: &mut Parser, flavor: Flavor) {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
p.bump();
|
p.bump();
|
||||||
if flavor.type_required() {
|
if flavor.type_required() {
|
||||||
self_param(p);
|
opt_self_param(p);
|
||||||
}
|
}
|
||||||
while !p.at(EOF) && !p.at(ket) {
|
while !p.at(EOF) && !p.at(ket) {
|
||||||
value_parameter(p, flavor);
|
value_parameter(p, flavor);
|
||||||
|
@ -94,7 +94,7 @@ fn value_parameter(p: &mut Parser, flavor: Flavor) {
|
||||||
// fn d(&'a mut self, x: i32) {}
|
// fn d(&'a mut self, x: i32) {}
|
||||||
// fn e(mut self) {}
|
// fn e(mut self) {}
|
||||||
// }
|
// }
|
||||||
fn self_param(p: &mut Parser) {
|
fn opt_self_param(p: &mut Parser) {
|
||||||
let m;
|
let m;
|
||||||
if p.at(SELF_KW) || p.at(MUT_KW) && p.nth(1) == SELF_KW {
|
if p.at(SELF_KW) || p.at(MUT_KW) && p.nth(1) == SELF_KW {
|
||||||
m = p.start();
|
m = p.start();
|
||||||
|
|
|
@ -69,7 +69,7 @@ fn path_segment(p: &mut Parser, mode: Mode, first: bool) {
|
||||||
match p.current() {
|
match p.current() {
|
||||||
IDENT => {
|
IDENT => {
|
||||||
name_ref(p);
|
name_ref(p);
|
||||||
path_generic_args(p, mode);
|
opt_path_type_args(p, mode);
|
||||||
}
|
}
|
||||||
SELF_KW | SUPER_KW => p.bump(),
|
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);
|
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 {
|
match mode {
|
||||||
Mode::Use => return,
|
Mode::Use => return,
|
||||||
Mode::Type => {
|
Mode::Type => {
|
||||||
|
@ -88,11 +88,11 @@ fn path_generic_args(p: &mut Parser, mode: Mode) {
|
||||||
// type F = Box<Fn(x: i32) -> ()>;
|
// type F = Box<Fn(x: i32) -> ()>;
|
||||||
if p.at(L_PAREN) {
|
if p.at(L_PAREN) {
|
||||||
params::param_list_opt_patterns(p);
|
params::param_list_opt_patterns(p);
|
||||||
fn_ret_type(p);
|
opt_fn_ret_type(p);
|
||||||
} else {
|
} 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),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::*;
|
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;
|
let m;
|
||||||
match (colon_colon_required, p.nth(0), p.nth(1)) {
|
match (colon_colon_required, p.nth(0), p.nth(1)) {
|
||||||
(_, COLONCOLON, L_ANGLE) => {
|
(_, COLONCOLON, L_ANGLE) => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use super::*;
|
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) {
|
if !p.at(L_ANGLE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +96,7 @@ pub(super) fn bounds_without_colon(p: &mut Parser) {
|
||||||
// T: Clone + Copy + 'static,
|
// T: Clone + Copy + 'static,
|
||||||
// Iterator::Item: 'a,
|
// 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) {
|
if !p.at(WHERE_KW) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -174,7 +174,7 @@ fn fn_pointer_type(p: &mut Parser) {
|
||||||
}
|
}
|
||||||
// test fn_pointer_type_with_ret
|
// test fn_pointer_type_with_ret
|
||||||
// type F = fn() -> ();
|
// type F = fn() -> ();
|
||||||
fn_ret_type(p);
|
opt_fn_ret_type(p);
|
||||||
m.complete(p, FN_POINTER_TYPE);
|
m.complete(p, FN_POINTER_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -184,7 +184,7 @@ fn for_type(p: &mut Parser) {
|
||||||
assert!(p.at(FOR_KW));
|
assert!(p.at(FOR_KW));
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
p.bump();
|
p.bump();
|
||||||
type_params::type_param_list(p);
|
type_params::opt_type_param_list(p);
|
||||||
type_(p);
|
type_(p);
|
||||||
m.complete(p, FOR_TYPE);
|
m.complete(p, FOR_TYPE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue