Unnamed repository; edit this file 'description' to name the repository.
Improve comments
Florian Diebold 2022-06-24
parent c80c348 · commit 45fd5e6
-rw-r--r--crates/hir-def/src/nameres/collector.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/crates/hir-def/src/nameres/collector.rs b/crates/hir-def/src/nameres/collector.rs
index 09594d1e61..9901df2af0 100644
--- a/crates/hir-def/src/nameres/collector.rs
+++ b/crates/hir-def/src/nameres/collector.rs
@@ -421,15 +421,15 @@ impl DefCollector<'_> {
}
}
- /// When the fixed-point loop reaches a stable state, we might still have some unresolved
- /// attributes (or unexpanded attribute proc macros) left over. This takes one of them, and
- /// feeds the item it's applied to back into name resolution.
+ /// When the fixed-point loop reaches a stable state, we might still have
+ /// some unresolved attributes left over. This takes one of them, and feeds
+ /// the item it's applied to back into name resolution.
///
/// This effectively ignores the fact that the macro is there and just treats the items as
/// normal code.
///
- /// This improves UX when proc macros are turned off or don't work, and replicates the behavior
- /// before we supported proc. attribute macros.
+ /// This improves UX for unresolved attributes, and replicates the
+ /// behavior before we supported proc. attribute macros.
fn reseed_with_unresolved_attribute(&mut self) -> ReachedFixedPoint {
cov_mark::hit!(unresolved_attribute_fallback);
@@ -1229,6 +1229,7 @@ impl DefCollector<'_> {
);
let loc: MacroCallLoc = self.db.lookup_intern_macro_call(call_id);
+ // If proc attribute macro expansion is disabled, skip expanding it here
if !self.db.enable_proc_attr_macros() {
self.def_map.diagnostics.push(DefDiagnostic::unresolved_proc_macro(
directive.module_id,
@@ -1250,8 +1251,10 @@ impl DefCollector<'_> {
if let MacroDefKind::ProcMacro(exp, ..) = loc.def.kind {
if exp.is_dummy() {
- // Proc macros that cannot be expanded are treated as not
- // resolved, in order to fall back later.
+ // If there's no expander for the proc macro (e.g.
+ // because proc macros are disabled, or building the
+ // proc macro crate failed), report this and skip
+ // expansion like we would if it was disabled
self.def_map.diagnostics.push(DefDiagnostic::unresolved_proc_macro(
directive.module_id,
loc.kind,