Commit ed34bbd
committed
gccrs: avoid ICE when canonical path record is missing
This fixes an Internal Compiler Error (ICE) in canonical path resolution
triggered by const-generic expressions containing inline item
definitions (e.g. structs inside const blocks).
Previously, CanonicalPathCtx::get_record unconditionally asserted that
a canonical path record exists for a NodeId. However, not all AST nodes
(e.g. inline items in const expressions) are guaranteed to have canonical
paths, leading to an ICE.
Introduce optional canonical path lookup and update callers to handle
the absence of a canonical path explicitly, avoiding the assertion
failure.
gcc/rust/ChangeLog:
* resolve/rust-name-resolution-context.h
(CanonicalPathCtx::get_path_opt): New helper returning an optional
canonical path.
* resolve/rust-name-resolution-context.cc: Use optional canonical
path lookup instead of asserting on missing records. * testsuite/rust/compile/issue-4143.rs: New regression test.
Signed-off-by: shreyas-omkar <shreyashegdeplus06@gmail.com>1 parent 4c81795 commit ed34bbd
3 files changed
Lines changed: 37 additions & 4 deletions
File tree
- gcc
- rust/resolve
- testsuite/rust/compile
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
184 | 184 | | |
185 | 185 | | |
186 | 186 | | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
187 | 196 | | |
188 | 197 | | |
189 | 198 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
359 | 359 | | |
360 | 360 | | |
361 | 361 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
| 362 | + | |
366 | 363 | | |
367 | 364 | | |
368 | 365 | | |
| |||
380 | 377 | | |
381 | 378 | | |
382 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
383 | 388 | | |
384 | 389 | | |
385 | 390 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
0 commit comments