nandi/rustnimpublic Fork
⑂ b714bd2
Commits
⬇ Clone ▾
git clone https://git.rickub.com/nandi/rustnim.git
git clone ssh://git@rickub.com/nandi/rustnim.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

Download ZIP

Count alias substitutions, not descent, against the cycle budget

Making `expand` walk the whole type meant every structural step also charged
against the depth limit, so `Vec<HashMap<String, Vec<..>>>` was reported as a
cyclic alias. A type is a finite tree; only substitution can loop.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
nandithebull committed 2026-09-19T18:12:57-07:00 Browse files
b714bd2 parent: 406427b
modified src/lower.rs +5 -2
@@ -1425,7 +1425,10 @@ impl Lowerer {
14251425 // outermost node.
14261426 use syn::Type;
14271427 let mut nested = t.clone();
1428- let rec = |me: &Self, e: &syn::Type| me.expand(e, depth + 1);
1428+ // `depth` counts alias substitutions, not descent into the type: a
1429+ // deeply nested type is not a cycle, and charging it against the same
1430+ // budget made `Vec<HashMap<String, Vec<..>>>` look like one.
1431+ let rec = |me: &Self, e: &syn::Type| me.expand(e, depth);
14291432 match &mut nested {
14301433 Type::Reference(r) => {
14311434 *r.elem = rec(self, &r.elem)?;
@@ -1482,7 +1485,7 @@ impl Lowerer {
14821485 if let syn::PathArguments::AngleBracketed(a) = &mut seg.arguments {
14831486 for g in a.args.iter_mut() {
14841487 if let GenericArgument::Type(at) = g {
1485- *at = self.expand(at, depth + 1)?;
1488+ *at = self.expand(at, depth)?;
14861489 }
14871490 }
14881491 }
@@ -1425,7 +1425,10 @@ impl Lowerer {
1425 // outermost node.1425 // outermost node.
1426 use syn::Type;1426 use syn::Type;
1427 let mut nested = t.clone();1427 let mut nested = t.clone();
1428- let rec = |me: &Self, e: &syn::Type| me.expand(e, depth + 1);1428+ // `depth` counts alias substitutions, not descent into the type: a
1429+ // deeply nested type is not a cycle, and charging it against the same
1430+ // budget made `Vec<HashMap<String, Vec<..>>>` look like one.
1431+ let rec = |me: &Self, e: &syn::Type| me.expand(e, depth);
1429 match &mut nested {1432 match &mut nested {
1430 Type::Reference(r) => {1433 Type::Reference(r) => {
1431 *r.elem = rec(self, &r.elem)?;1434 *r.elem = rec(self, &r.elem)?;
@@ -1482,7 +1485,7 @@ impl Lowerer {
1482 if let syn::PathArguments::AngleBracketed(a) = &mut seg.arguments {1485 if let syn::PathArguments::AngleBracketed(a) = &mut seg.arguments {
1483 for g in a.args.iter_mut() {1486 for g in a.args.iter_mut() {
1484 if let GenericArgument::Type(at) = g {1487 if let GenericArgument::Type(at) = g {
1485- *at = self.expand(at, depth + 1)?;1488+ *at = self.expand(at, depth)?;
1486 }1489 }
1487 }1490 }
1488 }1491 }