mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
rename struct -> record, pos -> tuple
This commit is contained in:
parent
c12dce0073
commit
5b18a4eef9
78 changed files with 640 additions and 634 deletions
|
@ -559,8 +559,8 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
|
|||
paths::expr_path(p);
|
||||
match p.current() {
|
||||
T!['{'] if !r.forbid_structs => {
|
||||
named_field_list(p);
|
||||
(m.complete(p, STRUCT_LIT), BlockLike::NotBlock)
|
||||
record_field_list(p);
|
||||
(m.complete(p, RECORD_LIT), BlockLike::NotBlock)
|
||||
}
|
||||
T![!] => {
|
||||
let block_like = items::macro_call_after_excl(p);
|
||||
|
@ -570,20 +570,20 @@ fn path_expr(p: &mut Parser, r: Restrictions) -> (CompletedMarker, BlockLike) {
|
|||
}
|
||||
}
|
||||
|
||||
// test struct_lit
|
||||
// test record_lit
|
||||
// fn foo() {
|
||||
// S {};
|
||||
// S { x, y: 32, };
|
||||
// S { x, y: 32, ..Default::default() };
|
||||
// TupleStruct { 0: 1 };
|
||||
// }
|
||||
pub(crate) fn named_field_list(p: &mut Parser) {
|
||||
pub(crate) fn record_field_list(p: &mut Parser) {
|
||||
assert!(p.at(T!['{']));
|
||||
let m = p.start();
|
||||
p.bump();
|
||||
while !p.at(EOF) && !p.at(T!['}']) {
|
||||
match p.current() {
|
||||
// test struct_literal_field_with_attr
|
||||
// test record_literal_field_with_attr
|
||||
// fn main() {
|
||||
// S { #[cfg(test)] field: 1 }
|
||||
// }
|
||||
|
@ -594,7 +594,7 @@ pub(crate) fn named_field_list(p: &mut Parser) {
|
|||
if p.eat(T![:]) {
|
||||
expr(p);
|
||||
}
|
||||
m.complete(p, NAMED_FIELD);
|
||||
m.complete(p, RECORD_FIELD);
|
||||
}
|
||||
T![..] => {
|
||||
p.bump();
|
||||
|
@ -608,5 +608,5 @@ pub(crate) fn named_field_list(p: &mut Parser) {
|
|||
}
|
||||
}
|
||||
p.expect(T!['}']);
|
||||
m.complete(p, NAMED_FIELD_LIST);
|
||||
m.complete(p, RECORD_FIELD_LIST);
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ mod traits;
|
|||
mod use_item;
|
||||
|
||||
pub(crate) use self::{
|
||||
expressions::{match_arm_list, named_field_list},
|
||||
nominal::{enum_variant_list, named_field_def_list},
|
||||
expressions::{match_arm_list, record_field_list},
|
||||
nominal::{enum_variant_list, record_field_def_list},
|
||||
traits::{impl_item_list, trait_item_list},
|
||||
use_item::use_tree_list,
|
||||
};
|
||||
|
|
|
@ -13,7 +13,7 @@ pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) {
|
|||
T![;] => {
|
||||
p.bump();
|
||||
}
|
||||
T!['{'] => named_field_def_list(p),
|
||||
T!['{'] => record_field_def_list(p),
|
||||
_ => {
|
||||
//FIXME: special case `(` error message
|
||||
p.error("expected `;` or `{`");
|
||||
|
@ -23,9 +23,9 @@ pub(super) fn struct_def(p: &mut Parser, m: Marker, kind: SyntaxKind) {
|
|||
T![;] if kind == T![struct] => {
|
||||
p.bump();
|
||||
}
|
||||
T!['{'] => named_field_def_list(p),
|
||||
T!['{'] => record_field_def_list(p),
|
||||
T!['('] if kind == T![struct] => {
|
||||
pos_field_def_list(p);
|
||||
tuple_field_def_list(p);
|
||||
// test tuple_struct_where
|
||||
// struct Test<T>(T) where T: Clone;
|
||||
// struct Test<T>(T);
|
||||
|
@ -70,8 +70,8 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
|
|||
if p.at(IDENT) {
|
||||
name(p);
|
||||
match p.current() {
|
||||
T!['{'] => named_field_def_list(p),
|
||||
T!['('] => pos_field_def_list(p),
|
||||
T!['{'] => record_field_def_list(p),
|
||||
T!['('] => tuple_field_def_list(p),
|
||||
T![=] => {
|
||||
p.bump();
|
||||
expressions::expr(p);
|
||||
|
@ -91,7 +91,7 @@ pub(crate) fn enum_variant_list(p: &mut Parser) {
|
|||
m.complete(p, ENUM_VARIANT_LIST);
|
||||
}
|
||||
|
||||
pub(crate) fn named_field_def_list(p: &mut Parser) {
|
||||
pub(crate) fn record_field_def_list(p: &mut Parser) {
|
||||
assert!(p.at(T!['{']));
|
||||
let m = p.start();
|
||||
p.bump();
|
||||
|
@ -100,17 +100,17 @@ pub(crate) fn named_field_def_list(p: &mut Parser) {
|
|||
error_block(p, "expected field");
|
||||
continue;
|
||||
}
|
||||
named_field_def(p);
|
||||
record_field_def(p);
|
||||
if !p.at(T!['}']) {
|
||||
p.expect(T![,]);
|
||||
}
|
||||
}
|
||||
p.expect(T!['}']);
|
||||
m.complete(p, NAMED_FIELD_DEF_LIST);
|
||||
m.complete(p, RECORD_FIELD_DEF_LIST);
|
||||
|
||||
fn named_field_def(p: &mut Parser) {
|
||||
fn record_field_def(p: &mut Parser) {
|
||||
let m = p.start();
|
||||
// test field_attrs
|
||||
// test record_field_attrs
|
||||
// struct S {
|
||||
// #[serde(with = "url_serde")]
|
||||
// pub uri: Uri,
|
||||
|
@ -121,7 +121,7 @@ pub(crate) fn named_field_def_list(p: &mut Parser) {
|
|||
name(p);
|
||||
p.expect(T![:]);
|
||||
types::type_(p);
|
||||
m.complete(p, NAMED_FIELD_DEF);
|
||||
m.complete(p, RECORD_FIELD_DEF);
|
||||
} else {
|
||||
m.abandon(p);
|
||||
p.err_and_bump("expected field declaration");
|
||||
|
@ -129,7 +129,7 @@ pub(crate) fn named_field_def_list(p: &mut Parser) {
|
|||
}
|
||||
}
|
||||
|
||||
fn pos_field_def_list(p: &mut Parser) {
|
||||
fn tuple_field_def_list(p: &mut Parser) {
|
||||
assert!(p.at(T!['(']));
|
||||
let m = p.start();
|
||||
if !p.expect(T!['(']) {
|
||||
|
@ -137,7 +137,7 @@ fn pos_field_def_list(p: &mut Parser) {
|
|||
}
|
||||
while !p.at(T![')']) && !p.at(EOF) {
|
||||
let m = p.start();
|
||||
// test pos_field_attrs
|
||||
// test tuple_field_attrs
|
||||
// struct S (
|
||||
// #[serde(with = "url_serde")]
|
||||
// pub Uri,
|
||||
|
@ -154,12 +154,12 @@ fn pos_field_def_list(p: &mut Parser) {
|
|||
break;
|
||||
}
|
||||
types::type_(p);
|
||||
m.complete(p, POS_FIELD_DEF);
|
||||
m.complete(p, TUPLE_FIELD_DEF);
|
||||
|
||||
if !p.at(T![')']) {
|
||||
p.expect(T![,]);
|
||||
}
|
||||
}
|
||||
p.expect(T![')']);
|
||||
m.complete(p, POS_FIELD_DEF_LIST);
|
||||
m.complete(p, TUPLE_FIELD_DEF_LIST);
|
||||
}
|
||||
|
|
|
@ -127,8 +127,8 @@ fn path_pat(p: &mut Parser) -> CompletedMarker {
|
|||
TUPLE_STRUCT_PAT
|
||||
}
|
||||
T!['{'] => {
|
||||
field_pat_list(p);
|
||||
STRUCT_PAT
|
||||
record_field_pat_list(p);
|
||||
RECORD_PAT
|
||||
}
|
||||
_ => PATH_PAT,
|
||||
};
|
||||
|
@ -149,21 +149,21 @@ fn tuple_pat_fields(p: &mut Parser) {
|
|||
p.expect(T![')']);
|
||||
}
|
||||
|
||||
// test field_pat_list
|
||||
// test record_field_pat_list
|
||||
// fn foo() {
|
||||
// let S {} = ();
|
||||
// let S { f, ref mut g } = ();
|
||||
// let S { h: _, ..} = ();
|
||||
// let S { h: _, } = ();
|
||||
// }
|
||||
fn field_pat_list(p: &mut Parser) {
|
||||
fn record_field_pat_list(p: &mut Parser) {
|
||||
assert!(p.at(T!['{']));
|
||||
let m = p.start();
|
||||
p.bump();
|
||||
while !p.at(EOF) && !p.at(T!['}']) {
|
||||
match p.current() {
|
||||
T![..] => p.bump(),
|
||||
IDENT if p.nth(1) == T![:] => field_pat(p),
|
||||
IDENT if p.nth(1) == T![:] => record_field_pat(p),
|
||||
T!['{'] => error_block(p, "expected ident"),
|
||||
_ => {
|
||||
bind_pat(p, false);
|
||||
|
@ -174,10 +174,10 @@ fn field_pat_list(p: &mut Parser) {
|
|||
}
|
||||
}
|
||||
p.expect(T!['}']);
|
||||
m.complete(p, FIELD_PAT_LIST);
|
||||
m.complete(p, RECORD_FIELD_PAT_LIST);
|
||||
}
|
||||
|
||||
fn field_pat(p: &mut Parser) {
|
||||
fn record_field_pat(p: &mut Parser) {
|
||||
assert!(p.at(IDENT));
|
||||
assert!(p.nth(1) == T![:]);
|
||||
|
||||
|
@ -185,7 +185,7 @@ fn field_pat(p: &mut Parser) {
|
|||
name(p);
|
||||
p.bump();
|
||||
pattern(p);
|
||||
m.complete(p, FIELD_PAT);
|
||||
m.complete(p, RECORD_FIELD_PAT);
|
||||
}
|
||||
|
||||
// test placeholder_pat
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue