This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit e20180d
committed
Auto merge of rust-lang#17893 - ShoyuVanilla:issue-17871, r=flodiebold
fix: Panic while hovering associated function with type annotation on generic param that not inherited from its container type
Fixes rust-lang#17871
We call `generic_args_sans_defaults` here;
https://github.com/rust-lang/rust-analyzer/blob/64a140527b383e3a2fe95908881624fc5374c60c/crates/hir-ty/src/display.rs#L1021-L1034
but the following substitution inside that function panic in rust-lang#17871;
https://github.com/rust-lang/rust-analyzer/blob/64a140527b383e3a2fe95908881624fc5374c60c/crates/hir-ty/src/display.rs#L1468
it's because the `Binders.binder` inside `default_parameters` has a same length with the generics of the function we are hovering on, but the generics of it is split into two, `fn_params` and `parent_params`.
Because of this, it may panic if the function has one or more default parameters and both `fn_params` and `parent_params` are non-empty, like the case in the title of this PR.
So, we must call `generic_args_sans_default` first and then split it into `fn_params` and `parent_params`File tree
2 files changed
+35
-8
lines changed- src/tools/rust-analyzer/crates
- hir-ty/src
- ide/src/hover
2 files changed
+35
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1019 | 1019 | | |
1020 | 1020 | | |
1021 | 1021 | | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
1022 | 1026 | | |
1023 | 1027 | | |
1024 | 1028 | | |
| 1029 | + | |
| 1030 | + | |
1025 | 1031 | | |
1026 | 1032 | | |
1027 | 1033 | | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | | - | |
1032 | | - | |
1033 | | - | |
1034 | | - | |
1035 | 1034 | | |
1036 | 1035 | | |
1037 | 1036 | | |
1038 | 1037 | | |
1039 | 1038 | | |
1040 | 1039 | | |
1041 | | - | |
| 1040 | + | |
1042 | 1041 | | |
1043 | 1042 | | |
1044 | 1043 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8602 | 8602 | | |
8603 | 8603 | | |
8604 | 8604 | | |
| 8605 | + | |
| 8606 | + | |
| 8607 | + | |
| 8608 | + | |
| 8609 | + | |
| 8610 | + | |
| 8611 | + | |
| 8612 | + | |
| 8613 | + | |
| 8614 | + | |
| 8615 | + | |
| 8616 | + | |
| 8617 | + | |
| 8618 | + | |
| 8619 | + | |
| 8620 | + | |
| 8621 | + | |
| 8622 | + | |
| 8623 | + | |
| 8624 | + | |
| 8625 | + | |
| 8626 | + | |
| 8627 | + | |
| 8628 | + | |
| 8629 | + | |
| 8630 | + | |
| 8631 | + | |
| 8632 | + | |
0 commit comments