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.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/ide-db/src/path_transform.rs b/crates/ide-db/src/path_transform.rs
index 4a27035afd..48305c2082 100644
--- a/crates/ide-db/src/path_transform.rs
+++ b/crates/ide-db/src/path_transform.rs
@@ -152,7 +152,7 @@ impl<'a> PathTransform<'a> {
db,
node,
&db.expansion_span_map(file_id),
- self.target_scope.module().krate().into(),
+ self.target_scope.module().krate(db).into(),
)
}
}
@@ -174,7 +174,7 @@ impl<'a> PathTransform<'a> {
let mut type_substs: FxHashMap<hir::TypeParam, ast::Type> = Default::default();
let mut const_substs: FxHashMap<hir::ConstParam, SyntaxNode> = Default::default();
let mut defaulted_params: Vec<DefaultedParam> = Default::default();
- let target_edition = target_module.krate().edition(self.source_scope.db);
+ let target_edition = target_module.krate(db).edition(self.source_scope.db);
self.generic_def
.into_iter()
.flat_map(|it| it.type_or_const_params(db))
@@ -219,7 +219,7 @@ impl<'a> PathTransform<'a> {
}
(Either::Left(k), None) => {
if let Some(default) =
- k.default(db, target_module.krate().to_display_target(db))
+ k.default(db, target_module.krate(db).to_display_target(db))
&& let Some(default) = default.expr()
{
const_substs.insert(k, default.syntax().clone_for_update());
@@ -546,6 +546,13 @@ impl Ctx<'_> {
match resolution {
hir::PathResolution::Def(def) if def.as_assoc_item(self.source_scope.db).is_none() => {
+ // Macros cannot be used in pattern position, and identifiers that happen
+ // to have the same name as macros (like parameter names `vec`, `format`, etc.)
+ // are bindings, not references. Don't qualify them.
+ if matches!(def, hir::ModuleDef::Macro(_)) {
+ return None;
+ }
+
let cfg = FindPathConfig {
prefer_no_std: false,
prefer_prelude: true,