mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Merge commit 'baee6b338b
' into sync-from-ra
This commit is contained in:
parent
0155385b57
commit
aa55ce9567
139 changed files with 4248 additions and 1042 deletions
|
@ -165,6 +165,40 @@ pub(crate) mod entry {
|
|||
}
|
||||
m.complete(p, ERROR);
|
||||
}
|
||||
|
||||
pub(crate) fn eager_macro_input(p: &mut Parser<'_>) {
|
||||
let m = p.start();
|
||||
|
||||
let closing_paren_kind = match p.current() {
|
||||
T!['{'] => T!['}'],
|
||||
T!['('] => T![')'],
|
||||
T!['['] => T![']'],
|
||||
_ => {
|
||||
p.error("expected `{`, `[`, `(`");
|
||||
while !p.at(EOF) {
|
||||
p.bump_any();
|
||||
}
|
||||
m.complete(p, ERROR);
|
||||
return;
|
||||
}
|
||||
};
|
||||
p.bump_any();
|
||||
while !p.at(EOF) && !p.at(closing_paren_kind) {
|
||||
expressions::expr(p);
|
||||
if !p.at(EOF) && !p.at(closing_paren_kind) {
|
||||
p.expect(T![,]);
|
||||
}
|
||||
}
|
||||
p.expect(closing_paren_kind);
|
||||
if p.at(EOF) {
|
||||
m.complete(p, MACRO_EAGER_INPUT);
|
||||
return;
|
||||
}
|
||||
while !p.at(EOF) {
|
||||
p.bump_any();
|
||||
}
|
||||
m.complete(p, ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -328,9 +328,6 @@ fn macro_rules(p: &mut Parser<'_>, m: Marker) {
|
|||
p.bump_remap(T![macro_rules]);
|
||||
p.expect(T![!]);
|
||||
|
||||
if p.at(IDENT) {
|
||||
name(p);
|
||||
}
|
||||
// Special-case `macro_rules! try`.
|
||||
// This is a hack until we do proper edition support
|
||||
|
||||
|
@ -340,6 +337,8 @@ fn macro_rules(p: &mut Parser<'_>, m: Marker) {
|
|||
let m = p.start();
|
||||
p.bump_remap(IDENT);
|
||||
m.complete(p, NAME);
|
||||
} else {
|
||||
name(p);
|
||||
}
|
||||
|
||||
match p.current() {
|
||||
|
|
|
@ -75,6 +75,8 @@ pub enum TopEntryPoint {
|
|||
/// Edge case -- macros generally don't expand to attributes, with the
|
||||
/// exception of `cfg_attr` which does!
|
||||
MetaItem,
|
||||
/// Edge case 2 -- eager macros expand their input to a delimited list of comma separated expressions
|
||||
MacroEagerInput,
|
||||
}
|
||||
|
||||
impl TopEntryPoint {
|
||||
|
@ -87,6 +89,7 @@ impl TopEntryPoint {
|
|||
TopEntryPoint::Type => grammar::entry::top::type_,
|
||||
TopEntryPoint::Expr => grammar::entry::top::expr,
|
||||
TopEntryPoint::MetaItem => grammar::entry::top::meta_item,
|
||||
TopEntryPoint::MacroEagerInput => grammar::entry::top::eager_macro_input,
|
||||
};
|
||||
let mut p = parser::Parser::new(input);
|
||||
entry_point(&mut p);
|
||||
|
|
|
@ -223,7 +223,8 @@ fn n_attached_trivias<'a>(
|
|||
) -> usize {
|
||||
match kind {
|
||||
CONST | ENUM | FN | IMPL | MACRO_CALL | MACRO_DEF | MACRO_RULES | MODULE | RECORD_FIELD
|
||||
| STATIC | STRUCT | TRAIT | TUPLE_FIELD | TYPE_ALIAS | UNION | USE | VARIANT => {
|
||||
| STATIC | STRUCT | TRAIT | TUPLE_FIELD | TYPE_ALIAS | UNION | USE | VARIANT
|
||||
| EXTERN_CRATE => {
|
||||
let mut res = 0;
|
||||
let mut trivias = trivias.enumerate().peekable();
|
||||
|
||||
|
|
|
@ -262,6 +262,7 @@ pub enum SyntaxKind {
|
|||
TYPE_BOUND_LIST,
|
||||
MACRO_ITEMS,
|
||||
MACRO_STMTS,
|
||||
MACRO_EAGER_INPUT,
|
||||
#[doc(hidden)]
|
||||
__LAST,
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue