Commit 816cbd4
committed
gccrs: Fix ICE with invalid init expression in TuplePattern LetStmt
The compiler was throwing an ICE when a Type Alias was used as a value
in a LetStmt (e.g., `let () = ::X = ();`). This occurred because the
backend pattern compiler received an `error_mark_node` for the
initialization expression and failed to handle it.
This patch adds a check in `CompileStmt` to detect if the initialization
expression is an `error_mark_node`. To prevent regression failures in
other tests (excess errors), this check is restricted specifically to
`TuplePattern`, which was the source of the crash. If detected, we now
emit a proper error message and exit early.
gcc/rust/ChangeLog:
* backend/rust-compile-stmt.cc (CompileStmt::visit): Check for
error_mark_node in init expression for TuplePatterns and exit
early if found.
gcc/testsuite/ChangeLog:
* rust/compile/issue-4161.rs: New test.
Signed-off-by: Harishankar P P <harishankarpp7@gmail.com>1 parent 341fc10 commit 816cbd4
File tree
3 files changed
+17
-2
lines changed- gcc
- rust
- backend
- checks/lints
- testsuite/rust/compile
3 files changed
+17
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
77 | 88 | | |
78 | 89 | | |
79 | 90 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
268 | 268 | | |
269 | 269 | | |
270 | 270 | | |
271 | | - | |
272 | | - | |
273 | 271 | | |
274 | 272 | | |
275 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
0 commit comments