10402: fix: Don't show flyimport completions in use renames r=Veykril a=Veykril

Fixes https://github.com/rust-analyzer/rust-analyzer/issues/10367
bors r+

Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
bors[bot] 2021-09-30 16:18:09 +00:00 committed by GitHub
commit 4f3ce62b0d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 0 deletions

View File

@ -1220,4 +1220,17 @@ fn function() {
"#]],
);
}
#[test]
fn flyimport_rename() {
check(
r#"
mod module {
pub struct Struct;
}
use self as Str$0;
"#,
expect![[r#""#]],
);
}
}

View File

@ -383,6 +383,7 @@ impl<'a> CompletionContext<'a> {
| ImmediateLocation::ModDeclaration(_)
| ImmediateLocation::RecordPat(_)
| ImmediateLocation::RecordExpr(_)
| ImmediateLocation::Rename
)
)
}

View File

@ -32,6 +32,7 @@ pub(crate) enum ImmediatePrevSibling {
pub(crate) enum ImmediateLocation {
Use,
UseTree,
Rename,
Impl,
Trait,
RecordField,
@ -201,6 +202,7 @@ pub(crate) fn determine_location(
ast::Use(_it) => ImmediateLocation::Use,
ast::UseTree(_it) => ImmediateLocation::UseTree,
ast::UseTreeList(_it) => ImmediateLocation::UseTree,
ast::Rename(_it) => ImmediateLocation::Rename,
ast::StmtList(_it) => ImmediateLocation::StmtList,
ast::SourceFile(_it) => ImmediateLocation::ItemList,
ast::ItemList(_it) => ImmediateLocation::ItemList,