mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-08-31 15:47:31 +00:00
Add some sanity checks
This commit is contained in:
parent
cbca4effce
commit
020c00e44d
1 changed files with 10 additions and 1 deletions
|
@ -115,6 +115,11 @@ impl<'a> CompletionContext<'a> {
|
|||
find_node_at_offset::<ast::MacroCall>(&original_file, offset),
|
||||
find_node_at_offset::<ast::MacroCall>(&hypothetical_file, offset),
|
||||
) {
|
||||
if actual_macro_call.path().as_ref().map(|s| s.syntax().text())
|
||||
!= macro_call_with_fake_ident.path().as_ref().map(|s| s.syntax().text())
|
||||
{
|
||||
break;
|
||||
}
|
||||
if let (Some(actual_expansion), Some(hypothetical_expansion)) = (
|
||||
ctx.sema.expand(&actual_macro_call),
|
||||
ctx.sema.expand_hypothetical(
|
||||
|
@ -123,11 +128,15 @@ impl<'a> CompletionContext<'a> {
|
|||
fake_ident_token,
|
||||
),
|
||||
) {
|
||||
let new_offset = hypothetical_expansion.1.text_range().start();
|
||||
if new_offset >= actual_expansion.text_range().end() {
|
||||
break;
|
||||
}
|
||||
// TODO check that the expansions 'look the same' up to the inserted token?
|
||||
original_file = actual_expansion;
|
||||
hypothetical_file = hypothetical_expansion.0;
|
||||
fake_ident_token = hypothetical_expansion.1;
|
||||
offset = fake_ident_token.text_range().start();
|
||||
offset = new_offset;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue