mirror of
https://github.com/rust-lang/rust.git
synced 2025-05-03 05:27:36 +00:00
Make name_ref to accept numeric names optionally
This commit is contained in:
parent
957b5ed23a
commit
fa24e20867
@ -273,8 +273,8 @@ fn name(p: &mut Parser) {
|
|||||||
name_r(p, TokenSet::empty())
|
name_r(p, TokenSet::empty())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn name_ref(p: &mut Parser) {
|
fn name_ref(p: &mut Parser, allow_numeric_names: bool) {
|
||||||
if p.at(IDENT) || p.at(INT_NUMBER) {
|
if p.at(IDENT) || (allow_numeric_names && p.at(INT_NUMBER)) {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
p.bump();
|
p.bump();
|
||||||
m.complete(p, NAME_REF);
|
m.complete(p, NAME_REF);
|
||||||
|
@ -458,7 +458,7 @@ fn method_call_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
|
|||||||
assert!(p.at(T![.]) && p.nth(1) == IDENT && (p.nth(2) == T!['('] || p.nth(2) == T![::]));
|
assert!(p.at(T![.]) && p.nth(1) == IDENT && (p.nth(2) == T!['('] || p.nth(2) == T![::]));
|
||||||
let m = lhs.precede(p);
|
let m = lhs.precede(p);
|
||||||
p.bump();
|
p.bump();
|
||||||
name_ref(p);
|
name_ref(p, false);
|
||||||
type_args::opt_type_arg_list(p, true);
|
type_args::opt_type_arg_list(p, true);
|
||||||
if p.at(T!['(']) {
|
if p.at(T!['(']) {
|
||||||
arg_list(p);
|
arg_list(p);
|
||||||
@ -485,7 +485,7 @@ fn field_expr(p: &mut Parser, lhs: CompletedMarker) -> CompletedMarker {
|
|||||||
let m = lhs.precede(p);
|
let m = lhs.precede(p);
|
||||||
p.bump();
|
p.bump();
|
||||||
if p.at(IDENT) {
|
if p.at(IDENT) {
|
||||||
name_ref(p)
|
name_ref(p, false)
|
||||||
} else if p.at(INT_NUMBER) {
|
} else if p.at(INT_NUMBER) {
|
||||||
p.bump();
|
p.bump();
|
||||||
} else if p.at(FLOAT_NUMBER) {
|
} else if p.at(FLOAT_NUMBER) {
|
||||||
@ -587,7 +587,7 @@ pub(crate) fn named_field_list(p: &mut Parser) {
|
|||||||
IDENT | INT_NUMBER | T![#] => {
|
IDENT | INT_NUMBER | T![#] => {
|
||||||
let m = p.start();
|
let m = p.start();
|
||||||
attributes::outer_attributes(p);
|
attributes::outer_attributes(p);
|
||||||
name_ref(p);
|
name_ref(p, true);
|
||||||
if p.eat(T![:]) {
|
if p.eat(T![:]) {
|
||||||
expr(p);
|
expr(p);
|
||||||
}
|
}
|
||||||
|
@ -279,7 +279,7 @@ fn extern_crate_item(p: &mut Parser, m: Marker) {
|
|||||||
p.bump();
|
p.bump();
|
||||||
assert!(p.at(T![crate]));
|
assert!(p.at(T![crate]));
|
||||||
p.bump();
|
p.bump();
|
||||||
name_ref(p);
|
name_ref(p, false);
|
||||||
opt_alias(p);
|
opt_alias(p);
|
||||||
p.expect(T![;]);
|
p.expect(T![;]);
|
||||||
m.complete(p, EXTERN_CRATE_ITEM);
|
m.complete(p, EXTERN_CRATE_ITEM);
|
||||||
|
@ -71,7 +71,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, false);
|
||||||
opt_path_type_args(p, mode);
|
opt_path_type_args(p, mode);
|
||||||
}
|
}
|
||||||
// test crate_path
|
// test crate_path
|
||||||
|
@ -38,12 +38,12 @@ fn type_arg(p: &mut Parser) {
|
|||||||
// test associated_type_bounds
|
// test associated_type_bounds
|
||||||
// fn print_all<T: Iterator<Item: Display>>(printables: T) {}
|
// fn print_all<T: Iterator<Item: Display>>(printables: T) {}
|
||||||
IDENT if p.nth(1) == T![:] => {
|
IDENT if p.nth(1) == T![:] => {
|
||||||
name_ref(p);
|
name_ref(p, false);
|
||||||
type_params::bounds(p);
|
type_params::bounds(p);
|
||||||
m.complete(p, ASSOC_TYPE_ARG);
|
m.complete(p, ASSOC_TYPE_ARG);
|
||||||
}
|
}
|
||||||
IDENT if p.nth(1) == T![=] => {
|
IDENT if p.nth(1) == T![=] => {
|
||||||
name_ref(p);
|
name_ref(p, false);
|
||||||
p.bump();
|
p.bump();
|
||||||
types::type_(p);
|
types::type_(p);
|
||||||
m.complete(p, ASSOC_TYPE_ARG);
|
m.complete(p, ASSOC_TYPE_ARG);
|
||||||
|
Loading…
Reference in New Issue
Block a user