diff options
| author | Florian Diebold <flodiebold@gmail.com> | 2022-06-24 14:19:18 +0200 |
|---|---|---|
| committer | Florian Diebold <flodiebold@gmail.com> | 2022-06-24 14:19:18 +0200 |
| commit | 45fd5e697f6d7cf1d09c6c465cb008eabd1c63fb (patch) | |
| tree | 4d5e675d3c5095b30c013b4c75990111517b7ec7 | |
| parent | c80c34867fab85bfa0ac3661e8abd264991af324 (diff) | |
| download | rust-45fd5e697f6d7cf1d09c6c465cb008eabd1c63fb.tar.gz rust-45fd5e697f6d7cf1d09c6c465cb008eabd1c63fb.zip | |
Improve comments
| -rw-r--r-- | crates/hir-def/src/nameres/collector.rs | 17 |
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 09594d1e616..9901df2af08 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, |
