Skip to content

Commit 15de338

Browse files
bors[bot]matklad
andauthored
Merge #4303
4303: Remove false positive attr compleitons r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <[email protected]>
2 parents a1ccd09 + b211c58 commit 15de338

File tree

2 files changed

+40
-4
lines changed

2 files changed

+40
-4
lines changed

crates/ra_ide/src/completion/complete_qualified_path.rs

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,21 @@
22
33
use hir::{Adt, HasVisibility, PathResolution, ScopeDef};
44
use ra_syntax::AstNode;
5+
use rustc_hash::FxHashSet;
56
use test_utils::tested_by;
67

78
use crate::completion::{CompletionContext, Completions};
8-
use rustc_hash::FxHashSet;
99

1010
pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionContext) {
1111
let path = match &ctx.path_prefix {
1212
Some(path) => path.clone(),
13-
_ => return,
13+
None => return,
1414
};
15+
16+
if ctx.attribute_under_caret.is_some() {
17+
return;
18+
}
19+
1520
let scope = ctx.scope();
1621
let context_module = scope.module();
1722

@@ -1325,4 +1330,18 @@ mod tests {
13251330
"###
13261331
);
13271332
}
1333+
1334+
#[test]
1335+
fn dont_complete_attr() {
1336+
assert_debug_snapshot!(
1337+
do_reference_completion(
1338+
r"
1339+
mod foo { pub struct Foo; }
1340+
#[foo::<|>]
1341+
fn f() {}
1342+
"
1343+
),
1344+
@r###"[]"###
1345+
)
1346+
}
13281347
}

crates/ra_ide/src/completion/complete_unqualified_path.rs

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ use hir::{Adt, ModuleDef, Type};
88
use ra_syntax::AstNode;
99

1010
pub(super) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) {
11-
if (!ctx.is_trivial_path && !ctx.is_pat_binding_or_const)
12-
|| ctx.record_lit_syntax.is_some()
11+
if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) {
12+
return;
13+
}
14+
if ctx.record_lit_syntax.is_some()
1315
|| ctx.record_pat_syntax.is_some()
16+
|| ctx.attribute_under_caret.is_some()
1417
{
1518
return;
1619
}
@@ -1369,4 +1372,18 @@ mod tests {
13691372
"###
13701373
)
13711374
}
1375+
1376+
#[test]
1377+
fn dont_complete_attr() {
1378+
assert_debug_snapshot!(
1379+
do_reference_completion(
1380+
r"
1381+
struct Foo;
1382+
#[<|>]
1383+
fn f() {}
1384+
"
1385+
),
1386+
@r###"[]"###
1387+
)
1388+
}
13721389
}

0 commit comments

Comments
 (0)