Commit 01bff9e
yimiliya
Handle non-type args in TraitRefPrintSugared
The issue was that `TraitRefPrintSugared` called `type_at(1)`
which panics when the argument is not a type (e.g., an inference variable).
This can happen when there are prior errors in user code, such as
incorrect trait parameters with paren sugar syntax.
The fix uses `get(1).and_then(|arg| arg.as_type())` to safely
check if the argument is a type before accessing it, falling back
to the default printing path if not.1 parent 0d1ac13 commit 01bff9e
File tree
2 files changed
+12
-1
lines changed- compiler/rustc_middle/src/ty/print
- tests/ui/unboxed-closures
2 files changed
+12
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3313 | 3313 | | |
3314 | 3314 | | |
3315 | 3315 | | |
3316 | | - | |
| 3316 | + | |
| 3317 | + | |
3317 | 3318 | | |
3318 | 3319 | | |
3319 | 3320 | | |
| |||
Lines changed: 10 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
0 commit comments