Skip to content

Commit 5f279d5

Browse files
Merge #8426
8426: Track recursion limit when expanding custom derive r=jonas-schievink a=jonas-schievink You can write a custom derive that expands to itself: ```rust #[proc_macro_derive(Derive)] pub fn derive(item: TokenStream) -> TokenStream { let mut out: TokenStream = "#[derive(Derive)]".parse().unwrap(); out.extend(item); out } ``` rustc reports a recursion limit error, but rust-analyzer used to spin in name resolution and eventually fail with "name resolution is stuck". This makes it fail fast by respecting the recursion depth of the invocation. bors r+ Co-authored-by: Jonas Schievink <[email protected]>
2 parents 94d9fc2 + 0147747 commit 5f279d5

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

crates/hir_def/src/nameres/collector.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -836,7 +836,7 @@ impl DefCollector<'_> {
836836
self.resolve_derive_macro(directive.module_id, &path)
837837
}) {
838838
Ok(call_id) => {
839-
resolved.push((directive.module_id, call_id, 0));
839+
resolved.push((directive.module_id, call_id, directive.depth));
840840
res = ReachedFixedPoint::No;
841841
return false;
842842
}

0 commit comments

Comments
 (0)