10229: fix: do not complete builtin attributes for qualified paths r=Veykril a=Veykril

bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-09-13 22:31:39 +00:00 committed by GitHub
commit 249ebdd076
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 1 deletions

View File

@ -22,7 +22,11 @@ mod repr;
pub(crate) fn complete_attribute(acc: &mut Completions, ctx: &CompletionContext) -> Option<()> {
let attribute = ctx.attribute_under_caret.as_ref()?;
match (attribute.path().and_then(|p| p.as_single_name_ref()), attribute.token_tree()) {
let name_ref = match attribute.path() {
Some(p) => Some(p.as_single_name_ref()?),
None => None,
};
match (name_ref, attribute.token_tree()) {
(Some(path), Some(token_tree)) => match path.text().as_str() {
"derive" => derive::complete_derive(acc, ctx, token_tree),
"repr" => repr::complete_repr(acc, ctx, token_tree),

View File

@ -33,6 +33,18 @@ use self as this;
)
}
#[test]
fn doesnt_complete_qualified() {
check(
r#"
struct Foo;
#[foo::$0]
use self as this;
"#,
expect![[r#""#]],
)
}
#[test]
fn inside_nested_attr() {
check(r#"#[cfg($0)]"#, expect![[]])