diff --git a/crates/ide_completion/src/completions/flyimport.rs b/crates/ide_completion/src/completions/flyimport.rs index 9e6d26640e7..d7c8c54315c 100644 --- a/crates/ide_completion/src/completions/flyimport.rs +++ b/crates/ide_completion/src/completions/flyimport.rs @@ -1220,4 +1220,17 @@ fn function() { "#]], ); } + + #[test] + fn flyimport_rename() { + check( + r#" +mod module { + pub struct Struct; +} +use self as Str$0; + "#, + expect![[r#""#]], + ); + } } diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs index 9d3e894a3db..ddf8722bc85 100644 --- a/crates/ide_completion/src/context.rs +++ b/crates/ide_completion/src/context.rs @@ -383,6 +383,7 @@ pub(crate) fn is_path_disallowed(&self) -> bool { | ImmediateLocation::ModDeclaration(_) | ImmediateLocation::RecordPat(_) | ImmediateLocation::RecordExpr(_) + | ImmediateLocation::Rename ) ) } diff --git a/crates/ide_completion/src/patterns.rs b/crates/ide_completion/src/patterns.rs index 381a6a83aac..d5d81bf2f16 100644 --- a/crates/ide_completion/src/patterns.rs +++ b/crates/ide_completion/src/patterns.rs @@ -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,