aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-04-08 17:51:11 +0100
committerGitHub <[email protected]>2021-04-08 17:51:11 +0100
commit5f279d57f0cba600eae8c550654a00b4268812ac (patch)
tree29195bd210adb94fbf8d5780484c931d8ffd5d66 /crates
parent94d9fc2a28ea5d97e3a9293b9dac05bdb00304cc (diff)
parent014774764a2a9bd029046e01c757c9892572c0b0 (diff)
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]>
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_def/src/nameres/collector.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs
index 492d8c71f..6dbbe2d05 100644
--- a/crates/hir_def/src/nameres/collector.rs
+++ b/crates/hir_def/src/nameres/collector.rs
@@ -836,7 +836,7 @@ impl DefCollector<'_> {
836 self.resolve_derive_macro(directive.module_id, &path) 836 self.resolve_derive_macro(directive.module_id, &path)
837 }) { 837 }) {
838 Ok(call_id) => { 838 Ok(call_id) => {
839 resolved.push((directive.module_id, call_id, 0)); 839 resolved.push((directive.module_id, call_id, directive.depth));
840 res = ReachedFixedPoint::No; 840 res = ReachedFixedPoint::No;
841 return false; 841 return false;
842 } 842 }