Commit ee52e7b
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_path unconditionally accessed a
canonical path record via get_record, asserting that such a record
always exists. However, some AST nodes (e.g. inline items inside const
expressions) are not guaranteed to have canonical paths, leading to an
ICE.
Update canonical path lookup to be optional and handle the absence of a
record explicitly, avoiding the assertion failure.
gcc/rust/ChangeLog:
* resolve/rust-name-resolution-context.h
(CanonicalPathCtx::get_path): Move implementation to source file.
(CanonicalPathCtx::get_path_opt): New helper returning an optional
canonical path.
* resolve/rust-name-resolution-context.cc
(CanonicalPathCtx::get_path): Use optional canonical path lookup
and return empty path instead of asserting on missing records.
Signed-off-by: shreyas-omkar <shreyashegdeplus06@gmail.com>1 parent 9ed1331 commit ee52e7b
File tree
3 files changed
+37
-4
lines changed- gcc
- rust/resolve
- testsuite/rust/compile
3 files changed
+37
-4
lines changed| 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