Commit 3b2788c
authored
refactor: fix
`canonicalize_refs` used `cx.hir_map().node_to_hir_id` and
unconditionally called `typeck(parent)`. When `MutVisitNodes` descends
into attribute tokens or items without bodies (e.g., `extern` decls) the
HIR map lacks a node or typeck tables, so the walk panicked with
`span_bug!("can't type-check body …")`.
This PR swaps to `opt_node_to_hir_id` so attribute-only nodes
short-circuit before we ever try to fetch HIR expressions, keeping the
transform aligned with what rustc actually lowers, and checks
`maybe_body_owned_by(parent)` before querying typeck tables; this skips
extern items and other definitions without bodies, avoiding the
`primary_body_of` unwrap panic while still running the transform over
real bodies.canonicalize_refs in libxml transforms (#1450)1 file changed
+13
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
18 | | - | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
19 | 24 | | |
20 | 25 | | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
21 | 33 | | |
22 | 34 | | |
23 | 35 | | |
| |||
0 commit comments