mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-05 19:58:32 +00:00
reduce code duplication
This commit is contained in:
parent
9d29c717ac
commit
6502bd2c96
@ -126,26 +126,15 @@ fn where_predicate(p: &mut Parser) {
|
|||||||
p.error("expected colon");
|
p.error("expected colon");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// test where_pred_for
|
|
||||||
// fn test<F>()
|
|
||||||
// where
|
|
||||||
// for<'a> F: Fn(&'a str)
|
|
||||||
// { }
|
|
||||||
FOR_KW => {
|
|
||||||
p.bump();
|
|
||||||
if p.at(L_ANGLE) {
|
|
||||||
type_param_list(p);
|
|
||||||
types::path_type(p);
|
|
||||||
if p.at(COLON) {
|
|
||||||
bounds(p);
|
|
||||||
} else {
|
|
||||||
p.error("expected colon");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
p.error("expected `<`");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
_ => {
|
_ => {
|
||||||
|
// test where_pred_for
|
||||||
|
// fn test<F>()
|
||||||
|
// where
|
||||||
|
// for<'a> F: Fn(&'a str)
|
||||||
|
// { }
|
||||||
|
if p.at(FOR_KW) {
|
||||||
|
types::for_binder(p);
|
||||||
|
}
|
||||||
types::path_type(p);
|
types::path_type(p);
|
||||||
if p.at(COLON) {
|
if p.at(COLON) {
|
||||||
bounds(p);
|
bounds(p);
|
||||||
|
@ -188,13 +188,22 @@ fn fn_pointer_type(p: &mut Parser) {
|
|||||||
m.complete(p, FN_POINTER_TYPE);
|
m.complete(p, FN_POINTER_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub(super) fn for_binder(p: &mut Parser) {
|
||||||
|
assert!(p.at(FOR_KW));
|
||||||
|
p.bump();
|
||||||
|
if p.at(L_ANGLE) {
|
||||||
|
type_params::opt_type_param_list(p);
|
||||||
|
} else {
|
||||||
|
p.error("expected `<`");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// test for_type
|
// test for_type
|
||||||
// type A = for<'a> fn() -> ();
|
// type A = for<'a> fn() -> ();
|
||||||
pub(super) fn for_type(p: &mut Parser) {
|
pub(super) 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();
|
for_binder(p);
|
||||||
type_params::opt_type_param_list(p);
|
|
||||||
match p.current() {
|
match p.current() {
|
||||||
FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p),
|
FN_KW | UNSAFE_KW | EXTERN_KW => fn_pointer_type(p),
|
||||||
_ if paths::is_path_start(p) => path_type_(p, false),
|
_ if paths::is_path_start(p) => path_type_(p, false),
|
||||||
|
Loading…
Reference in New Issue
Block a user