mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Avoid string copy in complete_attribute
This commit is contained in:
parent
6a0a47dd14
commit
9772de401e
1 changed files with 8 additions and 6 deletions
|
@ -21,15 +21,17 @@ pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext)
|
||||||
|
|
||||||
let attribute = ctx.attribute_under_caret.as_ref()?;
|
let attribute = ctx.attribute_under_caret.as_ref()?;
|
||||||
match (attribute.path(), attribute.token_tree()) {
|
match (attribute.path(), attribute.token_tree()) {
|
||||||
(Some(path), Some(token_tree)) => match path.to_string().as_str() {
|
(Some(path), Some(token_tree)) => {
|
||||||
"derive" => complete_derive(acc, ctx, token_tree),
|
let path = path.syntax().text();
|
||||||
"feature" => complete_lint(acc, ctx, token_tree, FEATURES),
|
if path == "derive" {
|
||||||
"allow" | "warn" | "deny" | "forbid" => {
|
complete_derive(acc, ctx, token_tree)
|
||||||
|
} else if path == "feature" {
|
||||||
|
complete_lint(acc, ctx, token_tree, FEATURES)
|
||||||
|
} else if path == "allow" || path == "warn" || path == "deny" || path == "forbid" {
|
||||||
complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINT_COMPLETIONS);
|
complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINT_COMPLETIONS);
|
||||||
complete_lint(acc, ctx, token_tree, CLIPPY_LINTS);
|
complete_lint(acc, ctx, token_tree, CLIPPY_LINTS);
|
||||||
}
|
}
|
||||||
_ => {}
|
}
|
||||||
},
|
|
||||||
(_, Some(_token_tree)) => {}
|
(_, Some(_token_tree)) => {}
|
||||||
_ => complete_attribute_start(acc, ctx, attribute),
|
_ => complete_attribute_start(acc, ctx, attribute),
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue