This repository was archived by the owner on May 28, 2025. It is now read-only.
Commit fde5564
committed
Auto merge of rust-lang#17505 - ShoyuVanilla:issue-17199, r=Veykril
Use proper `ImplTraits` in `insert_inference_vars_for_impl_trait`
Fixes rust-lang#17199 and fixes rust-lang#17403
In the previous implementation, I passed `rpits` as a function parameter and used `idx` of `ImplTraitId` for indexing `ImplTrait`.
https://github.com/rust-lang/rust-analyzer/blob/4e836c622a7bdab41be8e82733dd9fe40af128b2/crates/hir-ty/src/infer.rs#L881-L887
But that `idx` is rather a "local" one, so in the cases like mentioned issues, the async function that can be expanded roughly as
```rust
type TypeAlias = impl Something;
fn expanded_async() -> impl Future<Output = TypeAlias> { ... }
```
there are two bundles of `ImplTraits`; one for the `impl Future` and the other one for `TypeAlias`.
So using `idx` with `rpits` returns `ImplTrait` for `impl Future` even if we are asking for `TypeAlias` and this caused a stack overflow.
This PR is a fix for that implementation miss 😅File tree
2 files changed
+38
-31
lines changed- src/tools/rust-analyzer/crates/hir-ty/src
- tests
2 files changed
+38
-31
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
835 | 835 | | |
836 | 836 | | |
837 | 837 | | |
838 | | - | |
839 | | - | |
840 | | - | |
841 | | - | |
842 | | - | |
| 838 | + | |
843 | 839 | | |
844 | 840 | | |
845 | 841 | | |
| |||
862 | 858 | | |
863 | 859 | | |
864 | 860 | | |
865 | | - | |
866 | | - | |
867 | | - | |
868 | | - | |
869 | | - | |
870 | | - | |
| 861 | + | |
871 | 862 | | |
872 | 863 | | |
873 | 864 | | |
| |||
878 | 869 | | |
879 | 870 | | |
880 | 871 | | |
881 | | - | |
882 | | - | |
883 | | - | |
884 | | - | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
885 | 884 | | |
886 | | - | |
887 | | - | |
| 885 | + | |
| 886 | + | |
888 | 887 | | |
889 | 888 | | |
890 | 889 | | |
891 | 890 | | |
892 | 891 | | |
893 | 892 | | |
894 | 893 | | |
895 | | - | |
896 | | - | |
897 | | - | |
898 | | - | |
899 | | - | |
| 894 | + | |
| 895 | + | |
900 | 896 | | |
901 | 897 | | |
902 | 898 | | |
| |||
983 | 979 | | |
984 | 980 | | |
985 | 981 | | |
986 | | - | |
987 | | - | |
988 | | - | |
989 | | - | |
990 | 982 | | |
991 | | - | |
992 | | - | |
993 | | - | |
994 | | - | |
995 | | - | |
| 983 | + | |
996 | 984 | | |
997 | 985 | | |
998 | 986 | | |
| |||
Lines changed: 19 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1999 | 1999 | | |
2000 | 2000 | | |
2001 | 2001 | | |
| 2002 | + | |
| 2003 | + | |
| 2004 | + | |
| 2005 | + | |
| 2006 | + | |
| 2007 | + | |
| 2008 | + | |
| 2009 | + | |
| 2010 | + | |
| 2011 | + | |
| 2012 | + | |
| 2013 | + | |
| 2014 | + | |
| 2015 | + | |
| 2016 | + | |
| 2017 | + | |
| 2018 | + | |
| 2019 | + | |
| 2020 | + | |
0 commit comments