Commit 0130dcb
committed
Fix ICE in fn_delegation when child segment resolves to a trait
When a delegation path like `reuse Trait::<> as bar4` has only one
segment resolving to a trait (not a function), the child args
processing in `get_delegation_user_specified_args` called
`lower_generic_args_of_path` with `self_ty = None`. Since the trait's
generics have `has_self = true`, this triggered
`assert!(self_ty.is_some())`.
Fix by computing and providing `self_ty` when the child segment's
`def_id` has `has_self`. In valid delegation code the child segment
always resolves to a function, so this only affects error recovery.1 parent b90dc1e commit 0130dcb
File tree
3 files changed
+35
-1
lines changed- compiler/rustc_hir_analysis/src
- tests/ui/delegation
3 files changed
+35
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
613 | 625 | | |
614 | 626 | | |
615 | 627 | | |
616 | 628 | | |
617 | 629 | | |
618 | 630 | | |
619 | | - | |
| 631 | + | |
620 | 632 | | |
621 | 633 | | |
622 | 634 | | |
| |||
Lines changed: 13 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
Lines changed: 9 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
0 commit comments