internal: better naming
This commit is contained in:
parent
3dc2aeea0f
commit
ed84717869
@ -34,8 +34,8 @@
|
||||
mod params;
|
||||
mod paths;
|
||||
mod patterns;
|
||||
mod type_args;
|
||||
mod type_params;
|
||||
mod generic_args;
|
||||
mod generic_params;
|
||||
mod types;
|
||||
|
||||
use crate::{
|
||||
|
@ -486,7 +486,7 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
|
||||
let m = lhs.precede(p);
|
||||
p.bump_any();
|
||||
name_ref(p);
|
||||
type_args::opt_generic_arg_list(p, true);
|
||||
generic_args::opt_generic_arg_list(p, true);
|
||||
if p.at(T!['(']) {
|
||||
arg_list(p);
|
||||
}
|
||||
|
@ -23,38 +23,6 @@ pub(super) fn opt_generic_arg_list(p: &mut Parser, colon_colon_required: bool) {
|
||||
m.complete(p, GENERIC_ARG_LIST);
|
||||
}
|
||||
|
||||
pub(super) fn const_arg(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
// FIXME: duplicates the code below
|
||||
match p.current() {
|
||||
T!['{'] => {
|
||||
expressions::block_expr(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
k if k.is_literal() => {
|
||||
expressions::literal(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
T![true] | T![false] => {
|
||||
expressions::literal(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
T![-] => {
|
||||
let lm = p.start();
|
||||
p.bump(T![-]);
|
||||
expressions::literal(p);
|
||||
lm.complete(p, PREFIX_EXPR);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
_ => {
|
||||
let lm = p.start();
|
||||
paths::use_path(p);
|
||||
lm.complete(p, PATH_EXPR);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// test type_arg
|
||||
// type A = B<'static, i32, 1, { 2 }, Item=u64, true, false>;
|
||||
fn generic_arg(p: &mut Parser) {
|
||||
@ -94,7 +62,7 @@ fn generic_arg(p: &mut Parser) {
|
||||
}
|
||||
// NameRef<...>:
|
||||
T![:] => {
|
||||
type_params::bounds(p);
|
||||
generic_params::bounds(p);
|
||||
|
||||
path_seg.abandon(p);
|
||||
path.abandon(p);
|
||||
@ -137,3 +105,35 @@ fn generic_arg(p: &mut Parser) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn const_arg(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
// FIXME: duplicates the code above
|
||||
match p.current() {
|
||||
T!['{'] => {
|
||||
expressions::block_expr(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
k if k.is_literal() => {
|
||||
expressions::literal(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
T![true] | T![false] => {
|
||||
expressions::literal(p);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
T![-] => {
|
||||
let lm = p.start();
|
||||
p.bump(T![-]);
|
||||
expressions::literal(p);
|
||||
lm.complete(p, PREFIX_EXPR);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
_ => {
|
||||
let lm = p.start();
|
||||
paths::use_path(p);
|
||||
lm.complete(p, PATH_EXPR);
|
||||
m.complete(p, CONST_ARG);
|
||||
}
|
||||
}
|
||||
}
|
@ -82,7 +82,7 @@ fn const_param(p: &mut Parser, m: Marker) {
|
||||
// struct B<const N: i32 = {}>;
|
||||
// struct C<const N: i32 = some::CONST>;
|
||||
p.bump(T![=]);
|
||||
type_args::const_arg(p);
|
||||
generic_args::const_arg(p);
|
||||
}
|
||||
|
||||
m.complete(p, CONST_PARAM);
|
@ -284,15 +284,15 @@ fn type_alias(p: &mut Parser, m: Marker) {
|
||||
|
||||
// test type_item_type_params
|
||||
// type Result<T> = ();
|
||||
type_params::opt_generic_param_list(p);
|
||||
generic_params::opt_generic_param_list(p);
|
||||
|
||||
if p.at(T![:]) {
|
||||
type_params::bounds(p);
|
||||
generic_params::bounds(p);
|
||||
}
|
||||
|
||||
// test type_item_where_clause
|
||||
// type Foo where Foo: Copy = ();
|
||||
type_params::opt_where_clause(p);
|
||||
generic_params::opt_where_clause(p);
|
||||
if p.eat(T![=]) {
|
||||
types::type_(p);
|
||||
}
|
||||
@ -383,7 +383,7 @@ fn fn_(p: &mut Parser, m: Marker) {
|
||||
name_r(p, ITEM_RECOVERY_SET);
|
||||
// test function_type_params
|
||||
// fn foo<T: Clone + Copy>(){}
|
||||
type_params::opt_generic_param_list(p);
|
||||
generic_params::opt_generic_param_list(p);
|
||||
|
||||
if p.at(T!['(']) {
|
||||
params::param_list_fn_def(p);
|
||||
@ -397,7 +397,7 @@ fn fn_(p: &mut Parser, m: Marker) {
|
||||
|
||||
// test function_where_clause
|
||||
// fn foo<T>() where T: Copy {}
|
||||
type_params::opt_where_clause(p);
|
||||
generic_params::opt_where_clause(p);
|
||||
|
||||
if p.at(T![;]) {
|
||||
// test fn_decl
|
||||
|
@ -17,10 +17,10 @@ pub(super) fn union(p: &mut Parser, m: Marker) {
|
||||
|
||||
fn struct_or_union(p: &mut Parser, m: Marker, is_struct: bool) {
|
||||
name_r(p, ITEM_RECOVERY_SET);
|
||||
type_params::opt_generic_param_list(p);
|
||||
generic_params::opt_generic_param_list(p);
|
||||
match p.current() {
|
||||
T![where] => {
|
||||
type_params::opt_where_clause(p);
|
||||
generic_params::opt_where_clause(p);
|
||||
match p.current() {
|
||||
T![;] => p.bump(T![;]),
|
||||
T!['{'] => record_field_list(p),
|
||||
@ -42,7 +42,7 @@ fn struct_or_union(p: &mut Parser, m: Marker, is_struct: bool) {
|
||||
tuple_field_list(p);
|
||||
// test tuple_struct_where
|
||||
// struct S<T>(T) where T: Clone;
|
||||
type_params::opt_where_clause(p);
|
||||
generic_params::opt_where_clause(p);
|
||||
p.expect(T![;]);
|
||||
}
|
||||
_ => p.error(if is_struct { "expected `;`, `{`, or `(`" } else { "expected `{`" }),
|
||||
@ -53,8 +53,8 @@ fn struct_or_union(p: &mut Parser, m: Marker, is_struct: bool) {
|
||||
pub(super) fn enum_(p: &mut Parser, m: Marker) {
|
||||
p.bump(T![enum]);
|
||||
name_r(p, ITEM_RECOVERY_SET);
|
||||
type_params::opt_generic_param_list(p);
|
||||
type_params::opt_where_clause(p);
|
||||
generic_params::opt_generic_param_list(p);
|
||||
generic_params::opt_where_clause(p);
|
||||
if p.at(T!['{']) {
|
||||
variant_list(p);
|
||||
} else {
|
||||
|
@ -8,17 +8,17 @@ pub(super) fn trait_(p: &mut Parser, m: Marker) {
|
||||
|
||||
// test trait_item_generic_params
|
||||
// trait X<U: Debug + Display> {}
|
||||
type_params::opt_generic_param_list(p);
|
||||
generic_params::opt_generic_param_list(p);
|
||||
|
||||
if p.eat(T![=]) {
|
||||
// test trait_alias
|
||||
// trait Z<U> = T<U>;
|
||||
type_params::bounds_without_colon(p);
|
||||
generic_params::bounds_without_colon(p);
|
||||
|
||||
// test trait_alias_where_clause
|
||||
// trait Z<U> = T<U> where U: Copy;
|
||||
// trait Z<U> = where Self: T<U>;
|
||||
type_params::opt_where_clause(p);
|
||||
generic_params::opt_where_clause(p);
|
||||
p.expect(T![;]);
|
||||
m.complete(p, TRAIT);
|
||||
return;
|
||||
@ -27,12 +27,12 @@ pub(super) fn trait_(p: &mut Parser, m: Marker) {
|
||||
if p.at(T![:]) {
|
||||
// test trait_item_bounds
|
||||
// trait T: Hash + Clone {}
|
||||
type_params::bounds(p);
|
||||
generic_params::bounds(p);
|
||||
}
|
||||
|
||||
// test trait_item_where_clause
|
||||
// trait T where Self: Copy {}
|
||||
type_params::opt_where_clause(p);
|
||||
generic_params::opt_where_clause(p);
|
||||
|
||||
if p.at(T!['{']) {
|
||||
assoc_item_list(p);
|
||||
@ -47,7 +47,7 @@ pub(super) fn trait_(p: &mut Parser, m: Marker) {
|
||||
pub(super) fn impl_(p: &mut Parser, m: Marker) {
|
||||
p.bump(T![impl]);
|
||||
if p.at(T![<]) && not_a_qualified_path(p) {
|
||||
type_params::opt_generic_param_list(p);
|
||||
generic_params::opt_generic_param_list(p);
|
||||
}
|
||||
|
||||
// test impl_item_const
|
||||
@ -64,7 +64,7 @@ pub(super) fn impl_(p: &mut Parser, m: Marker) {
|
||||
if p.eat(T![for]) {
|
||||
impl_type(p);
|
||||
}
|
||||
type_params::opt_where_clause(p);
|
||||
generic_params::opt_where_clause(p);
|
||||
if p.at(T!['{']) {
|
||||
assoc_item_list(p);
|
||||
} else {
|
||||
|
@ -117,9 +117,9 @@ fn opt_path_type_args(p: &mut Parser, mode: Mode) {
|
||||
params::param_list_fn_trait(p);
|
||||
opt_ret_type(p);
|
||||
} else {
|
||||
type_args::opt_generic_arg_list(p, false)
|
||||
generic_args::opt_generic_arg_list(p, false)
|
||||
}
|
||||
}
|
||||
Mode::Expr => type_args::opt_generic_arg_list(p, true),
|
||||
Mode::Expr => generic_args::opt_generic_arg_list(p, true),
|
||||
}
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ pub(super) fn for_binder(p: &mut Parser) {
|
||||
assert!(p.at(T![for]));
|
||||
p.bump(T![for]);
|
||||
if p.at(T![<]) {
|
||||
type_params::opt_generic_param_list(p);
|
||||
generic_params::opt_generic_param_list(p);
|
||||
} else {
|
||||
p.error("expected `<`");
|
||||
}
|
||||
@ -254,7 +254,7 @@ fn impl_trait_type(p: &mut Parser) {
|
||||
assert!(p.at(T![impl]));
|
||||
let m = p.start();
|
||||
p.bump(T![impl]);
|
||||
type_params::bounds_without_colon(p);
|
||||
generic_params::bounds_without_colon(p);
|
||||
m.complete(p, IMPL_TRAIT_TYPE);
|
||||
}
|
||||
|
||||
@ -264,7 +264,7 @@ fn dyn_trait_type(p: &mut Parser) {
|
||||
assert!(p.at(T![dyn]));
|
||||
let m = p.start();
|
||||
p.bump(T![dyn]);
|
||||
type_params::bounds_without_colon(p);
|
||||
generic_params::bounds_without_colon(p);
|
||||
m.complete(p, DYN_TRAIT_TYPE);
|
||||
}
|
||||
|
||||
@ -339,7 +339,7 @@ fn opt_type_bounds_as_dyn_trait_type(p: &mut Parser, type_marker: CompletedMarke
|
||||
p.eat(T![+]);
|
||||
|
||||
// Parse rest of the bounds into the TYPE_BOUND_LIST
|
||||
let m = type_params::bounds_without_colon_m(p, m);
|
||||
let m = generic_params::bounds_without_colon_m(p, m);
|
||||
|
||||
// Finally precede everything with DYN_TRAIT_TYPE
|
||||
m.precede(p).complete(p, DYN_TRAIT_TYPE);
|
||||
|
Loading…
Reference in New Issue
Block a user