Revert "feat: Implement module_path macro"

This commit is contained in:
Lukas Wirth 2024-08-27 08:19:09 +02:00 committed by GitHub
parent 095926ea6f
commit fa48bc216c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
20 changed files with 71 additions and 278 deletions

View file

@ -365,6 +365,7 @@ impl<'db> SemanticsImpl<'db> {
_,
BuiltinFnLikeExpander::Column
| BuiltinFnLikeExpander::File
| BuiltinFnLikeExpander::ModulePath
| BuiltinFnLikeExpander::Asm
| BuiltinFnLikeExpander::LlvmAsm
| BuiltinFnLikeExpander::GlobalAsm
@ -482,26 +483,10 @@ impl<'db> SemanticsImpl<'db> {
let SourceAnalyzer { file_id, resolver, .. } =
self.analyze_no_infer(actual_macro_call.syntax())?;
let macro_call = InFile::new(file_id, actual_macro_call);
let macro_call_id = macro_call
.as_call_id(
self.db.upcast(),
resolver.module(),
|path| {
resolver.resolve_path_as_macro_def(
self.db.upcast(),
path,
Some(MacroSubNs::Bang),
)
},
|module| {
resolver
.module()
.def_map(self.db.upcast())
.path_for_module(self.db.upcast(), module)
},
)
.ok()?
.value?;
let krate = resolver.krate();
let macro_call_id = macro_call.as_call_id(self.db.upcast(), krate, |path| {
resolver.resolve_path_as_macro_def(self.db.upcast(), path, Some(MacroSubNs::Bang))
})?;
hir_expand::db::expand_speculative(
self.db.upcast(),
macro_call_id,

View file

@ -839,25 +839,12 @@ impl SourceAnalyzer {
db: &dyn HirDatabase,
macro_call: InFile<&ast::MacroCall>,
) -> Option<MacroFileId> {
let krate = self.resolver.krate();
// FIXME: This causes us to parse, generally this is the wrong approach for resolving a
// macro call to a macro call id!
let macro_call_id = macro_call
.as_call_id(
db.upcast(),
self.resolver.module(),
|path| {
self.resolver.resolve_path_as_macro_def(
db.upcast(),
path,
Some(MacroSubNs::Bang),
)
},
|module| {
self.resolver.module().def_map(db.upcast()).path_for_module(db.upcast(), module)
},
)
.ok()?
.value?;
let macro_call_id = macro_call.as_call_id(db.upcast(), krate, |path| {
self.resolver.resolve_path_as_macro_def(db.upcast(), path, Some(MacroSubNs::Bang))
})?;
// why the 64?
Some(macro_call_id.as_macro_file()).filter(|it| it.expansion_level(db.upcast()) < 64)
}