Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-db/src/path_transform.rs')
-rw-r--r--crates/ide-db/src/path_transform.rs22
1 files changed, 16 insertions, 6 deletions
diff --git a/crates/ide-db/src/path_transform.rs b/crates/ide-db/src/path_transform.rs
index 2d4a6b8b5b..e66f645c00 100644
--- a/crates/ide-db/src/path_transform.rs
+++ b/crates/ide-db/src/path_transform.rs
@@ -1,6 +1,6 @@
//! See [`PathTransform`].
-use crate::helpers::mod_path_to_ast;
+use crate::helpers::mod_path_to_ast_with_factory;
use either::Either;
use hir::{
AsAssocItem, FindPathConfig, HirDisplay, HirFileId, ModuleDef, SemanticsScope,
@@ -354,6 +354,7 @@ impl Ctx<'_> {
}
fn transform_path_(&self, editor: &SyntaxEditor, path: &ast::Path) -> Option<()> {
+ let make = editor.make();
if path.qualifier().is_some() {
return None;
}
@@ -397,7 +398,14 @@ impl Ctx<'_> {
hir::ModuleDef::Trait(trait_ref),
cfg,
)?;
- match make::ty_path(mod_path_to_ast(&found_path, self.target_edition)) {
+ match make
+ .ty_path(mod_path_to_ast_with_factory(
+ make,
+ &found_path,
+ self.target_edition,
+ ))
+ .into()
+ {
ast::Type::PathType(path_ty) => Some(path_ty),
_ => None,
}
@@ -447,7 +455,7 @@ impl Ctx<'_> {
allow_unstable: true,
};
let found_path = self.target_module.find_path(self.source_scope.db, def, cfg)?;
- let res = mod_path_to_ast(&found_path, self.target_edition);
+ let res = mod_path_to_ast_with_factory(make, &found_path, self.target_edition);
let (res_editor, res) = SyntaxEditor::with_ast_node(&res);
if let Some(args) = path.segment().and_then(|it| it.generic_arg_list())
&& let Some(segment) = res.segment()
@@ -501,7 +509,8 @@ impl Ctx<'_> {
)?;
if let Some(qual) =
- mod_path_to_ast(&found_path, self.target_edition).qualifier()
+ mod_path_to_ast_with_factory(make, &found_path, self.target_edition)
+ .qualifier()
{
editor.replace(
path.syntax(),
@@ -524,8 +533,9 @@ impl Ctx<'_> {
fn transform_ident_pat(&self, editor: &SyntaxEditor, ident_pat: &ast::IdentPat) -> Option<()> {
let name = ident_pat.name()?;
+ let make = editor.make();
- let temp_path = make::path_from_text(&name.text());
+ let temp_path = make.path_from_text(&name.text());
let resolution = self.source_scope.speculative_resolve(&temp_path)?;
@@ -580,7 +590,7 @@ impl Ctx<'_> {
let found_path = self.target_module.find_path(self.source_scope.db, def, cfg)?;
editor.replace(
ident_pat.syntax(),
- mod_path_to_ast(&found_path, self.target_edition).syntax(),
+ mod_path_to_ast_with_factory(make, &found_path, self.target_edition).syntax(),
);
Some(())
}