Skip to content

Commit f90664b

Browse files
bors[bot]lnicola
andauthored
Merge #7228
7228: Avoid string copy in complete_attribute r=Veykril a=lnicola Co-authored-by: Laurențiu Nicola <[email protected]>
2 parents 1ed1c14 + 9772de4 commit f90664b

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

crates/completion/src/completions/attribute.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,17 @@ pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext)
2121

2222
let attribute = ctx.attribute_under_caret.as_ref()?;
2323
match (attribute.path(), attribute.token_tree()) {
24-
(Some(path), Some(token_tree)) => match path.to_string().as_str() {
25-
"derive" => complete_derive(acc, ctx, token_tree),
26-
"feature" => complete_lint(acc, ctx, token_tree, FEATURES),
27-
"allow" | "warn" | "deny" | "forbid" => {
24+
(Some(path), Some(token_tree)) => {
25+
let path = path.syntax().text();
26+
if path == "derive" {
27+
complete_derive(acc, ctx, token_tree)
28+
} else if path == "feature" {
29+
complete_lint(acc, ctx, token_tree, FEATURES)
30+
} else if path == "allow" || path == "warn" || path == "deny" || path == "forbid" {
2831
complete_lint(acc, ctx, token_tree.clone(), DEFAULT_LINT_COMPLETIONS);
2932
complete_lint(acc, ctx, token_tree, CLIPPY_LINTS);
3033
}
31-
_ => {}
32-
},
34+
}
3335
(_, Some(_token_tree)) => {}
3436
_ => complete_attribute_start(acc, ctx, attribute),
3537
}

0 commit comments

Comments
 (0)