mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-11-03 13:23:25 +00:00
Fix a case where completion was unable to expand a macro
Which caused the macros of the popular `tracing` crate to not offer completions. The reason is rather complicated: it boils down to macro ignoring their input and completion always choosing the first expansion.
This commit is contained in:
parent
e0c11f631e
commit
02d47f3a81
16 changed files with 604 additions and 368 deletions
|
|
@ -72,8 +72,19 @@ pub(super) fn item_or_macro(p: &mut Parser<'_>, stop_on_r_curly: bool, is_in_ext
|
|||
// macro_rules! ()
|
||||
// macro_rules! []
|
||||
if paths::is_use_path_start(p) {
|
||||
macro_call(p, m);
|
||||
return;
|
||||
paths::use_path(p);
|
||||
// Do not create a MACRO_CALL node here if this isn't a macro call, this causes problems with completion.
|
||||
|
||||
// test_err path_item_without_excl
|
||||
// foo
|
||||
if p.at(T![!]) {
|
||||
macro_call(p, m);
|
||||
return;
|
||||
} else {
|
||||
m.complete(p, ERROR);
|
||||
p.error("expected an item");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
m.abandon(p);
|
||||
|
|
@ -410,8 +421,7 @@ fn fn_(p: &mut Parser<'_>, m: Marker) {
|
|||
}
|
||||
|
||||
fn macro_call(p: &mut Parser<'_>, m: Marker) {
|
||||
assert!(paths::is_use_path_start(p));
|
||||
paths::use_path(p);
|
||||
assert!(p.at(T![!]));
|
||||
match macro_call_after_excl(p) {
|
||||
BlockLike::Block => (),
|
||||
BlockLike::NotBlock => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue