# rustc — CWE-407 Diamond Recursion Scan — CLEAN

Scanned: `compiler/rustc_trait_selection/src/`, `compiler/rustc_infer/src/traits/`, `compiler/rustc_middle/src/ty/`

(Note: sparse clone — only `rustc_infer`, `rustc_middle`, `rustc_trait_selection` crates present.
`rustc_type_ir` contains the `Elaborator` struct; it re-exports into scope via `pub use rustc_middle::ty::elaborate::*`.)

## Functions Examined

| Function | File | Guard | Verdict |
|----------|------|-------|---------|
| `transitive_bounds_that_define_assoc_item` | rustc_infer/traits/util.rs | `if !seen.insert(...) { continue; }` | CLEAN |
| vtable DFS loop | rustc_trait_selection/traits/vtable.rs | `visited.insert(super_trait)` as guard in `.find()` | CLEAN |
| `auto_trait` predicate loop | rustc_trait_selection/traits/auto_trait.rs | `if !already_visited.insert(pred)` | CLEAN |
| `seen_projection_preds` | rustc_trait_selection/traits/util.rs | `if !seen_projection_preds.insert(...)` | CLEAN |
| `checked_wf_args` | rustc_trait_selection/src/traits/query/... | `if !checked_wf_args.insert(arg)` | CLEAN |

## Note

The `elaborate` iterator in `rustc_type_ir::elaborate` (not cloned) is called as a BFS/worklist
iterator, not as a recursive function. The sparse-clone boundary stops here; the pattern as used
through all call sites in the 3 available crates is iterator-based with deduplication guards.

**Scan verdict: CLEAN — no CWE-407 diamond recursion defects found in cloned crates.**
