mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-28 18:43:01 +00:00
fix: do not offer completions within macro strings
This commit is contained in:
parent
4a03036744
commit
cb0221d774
3 changed files with 72 additions and 1 deletions
|
|
@ -417,6 +417,15 @@ fn analyze(
|
|||
derive_ctx,
|
||||
} = expansion_result;
|
||||
|
||||
if original_token.kind() != self_token.kind()
|
||||
// FIXME: This check can be removed once we use speculative database forking for completions
|
||||
&& !(original_token.kind().is_punct() || original_token.kind().is_trivia())
|
||||
&& !(SyntaxKind::is_any_identifier(original_token.kind())
|
||||
&& SyntaxKind::is_any_identifier(self_token.kind()))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
|
||||
// Overwrite the path kind for derives
|
||||
if let Some((original_file, file_with_fake_ident, offset, origin_attr)) = derive_ctx {
|
||||
if let Some(ast::NameLike::NameRef(name_ref)) =
|
||||
|
|
|
|||
|
|
@ -713,6 +713,28 @@ struct Foo;
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn issue_17479() {
|
||||
check(
|
||||
r#"
|
||||
//- proc_macros: issue_17479
|
||||
fn main() {
|
||||
proc_macros::issue_17479!("te$0");
|
||||
}
|
||||
"#,
|
||||
expect![""],
|
||||
);
|
||||
check(
|
||||
r#"
|
||||
//- proc_macros: issue_17479
|
||||
fn main() {
|
||||
proc_macros::issue_17479!("$0");
|
||||
}
|
||||
"#,
|
||||
expect![""],
|
||||
)
|
||||
}
|
||||
|
||||
mod cfg {
|
||||
use super::*;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue