Merge #4303
4303: Remove false positive attr compleitons r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
This commit is contained in:
commit
15de338703
@ -2,16 +2,21 @@
|
||||
|
||||
use hir::{Adt, HasVisibility, PathResolution, ScopeDef};
|
||||
use ra_syntax::AstNode;
|
||||
use rustc_hash::FxHashSet;
|
||||
use test_utils::tested_by;
|
||||
|
||||
use crate::completion::{CompletionContext, Completions};
|
||||
use rustc_hash::FxHashSet;
|
||||
|
||||
pub(super) fn complete_qualified_path(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
let path = match &ctx.path_prefix {
|
||||
Some(path) => path.clone(),
|
||||
_ => return,
|
||||
None => return,
|
||||
};
|
||||
|
||||
if ctx.attribute_under_caret.is_some() {
|
||||
return;
|
||||
}
|
||||
|
||||
let scope = ctx.scope();
|
||||
let context_module = scope.module();
|
||||
|
||||
@ -1325,4 +1330,18 @@ mod tests {
|
||||
"###
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dont_complete_attr() {
|
||||
assert_debug_snapshot!(
|
||||
do_reference_completion(
|
||||
r"
|
||||
mod foo { pub struct Foo; }
|
||||
#[foo::<|>]
|
||||
fn f() {}
|
||||
"
|
||||
),
|
||||
@r###"[]"###
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -8,9 +8,12 @@ use hir::{Adt, ModuleDef, Type};
|
||||
use ra_syntax::AstNode;
|
||||
|
||||
pub(super) fn complete_unqualified_path(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
if (!ctx.is_trivial_path && !ctx.is_pat_binding_or_const)
|
||||
|| ctx.record_lit_syntax.is_some()
|
||||
if !(ctx.is_trivial_path || ctx.is_pat_binding_or_const) {
|
||||
return;
|
||||
}
|
||||
if ctx.record_lit_syntax.is_some()
|
||||
|| ctx.record_pat_syntax.is_some()
|
||||
|| ctx.attribute_under_caret.is_some()
|
||||
{
|
||||
return;
|
||||
}
|
||||
@ -1369,4 +1372,18 @@ mod tests {
|
||||
"###
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn dont_complete_attr() {
|
||||
assert_debug_snapshot!(
|
||||
do_reference_completion(
|
||||
r"
|
||||
struct Foo;
|
||||
#[<|>]
|
||||
fn f() {}
|
||||
"
|
||||
),
|
||||
@r###"[]"###
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user