rust-analyzer/crates
bors 469b06214a Auto merge of #17916 - ShoyuVanilla:issue-17711, r=Veykril
fix: Wrong BoundVar index when lowering impl trait parameter of parent generics

Fixes #17711

From the following test code;

```rust
//- minicore: deref
use core::ops::Deref;

struct Struct<'a, T>(&'a T);

trait Trait {}

impl<'a, T: Deref<Target = impl Trait>> Struct<'a, T> {
    fn foo(&self) -> &Self { self }

    fn bar(&self) {
        let _ = self.foo();
    }

}
```

when we call `register_obligations_for_call` for `let _ = self.foo();`,

07659783fd/crates/hir-ty/src/infer/expr.rs (L1939-L1952)

we are querying `generic_predicates` and it has `T: Deref<Target = impl Trait>` predicate from the parent `impl Struct`;

07659783fd/crates/hir-ty/src/lower.rs (L375-L399)

but as we can see above, lowering `TypeRef = impl Trait` doesn't take into account the parent generic parameters, so the `BoundVar` index here is `0`, as `fn foo` has no generic args other than parent's,

But this `BoundVar` is pointing at `'a` in `<'a, T: Deref<Target = impl Trait>>`.
So, in the first code reference `register_obligations_for_call`'s L:1948 - `.substitute(Interner, parameters)`, we are substituting `'a` with `Ty`, not `Lifetime` and this makes panic inside the chalk.

This PR fixes this wrong `BoundVar` index in such cases
2024-08-17 17:00:52 +00:00
..
base-db Remove unnecessary CfgFlag definition in project-model 2024-08-07 14:27:59 +02:00
cfg Remove unnecessary CfgFlag definition in project-model 2024-08-07 14:27:59 +02:00
hir Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykril 2024-08-16 13:49:32 +00:00
hir-def Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykril 2024-08-16 13:49:32 +00:00
hir-expand Properly account for editions in names 2024-08-16 16:46:24 +03:00
hir-ty fix: Wrong BoundVar index when lowering impl trait parameter of parent generics 2024-08-17 22:33:27 +09:00
ide Auto merge of #17900 - darichey:exclude-vendored-libraries, r=davidbarsky 2024-08-16 14:25:36 +00:00
ide-assists Properly account for editions in names 2024-08-16 16:46:24 +03:00
ide-completion Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykril 2024-08-16 13:49:32 +00:00
ide-db Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykril 2024-08-16 13:49:32 +00:00
ide-diagnostics Auto merge of #17905 - ChayimFriedman2:edition-dependent-raw-keyword, r=Veykril 2024-08-16 13:49:32 +00:00
ide-ssr Properly account for editions in names 2024-08-16 16:46:24 +03:00
intern Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
limit Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
load-cargo Auto merge of #17864 - Veykril:lsif, r=Veykril 2024-08-12 12:34:31 +00:00
mbe Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
parser Properly account for editions in names 2024-08-16 16:46:24 +03:00
paths Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
proc-macro-api Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
proc-macro-srv Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
proc-macro-srv-cli Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
profile Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
project-model minor: log error when sysroot can't be discovered 2024-08-09 03:50:48 +08:00
rust-analyzer Auto merge of #17900 - darichey:exclude-vendored-libraries, r=davidbarsky 2024-08-16 14:25:36 +00:00
salsa Fix and enable unsafe_op_in_unsafe_fn 2024-07-25 08:41:30 +03:00
span Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
stdx Use crossbeam-channel from the workspace 2024-08-09 23:48:03 +02:00
syntax Pin rowan to 0.15.15 2024-08-17 21:35:07 +09:00
syntax-bridge Properly account for editions in names 2024-08-16 16:46:24 +03:00
test-fixture Newtype ErasedFileAstId 2024-08-05 13:46:47 +02:00
test-utils Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
text-edit Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
toolchain Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
tt Replace [package.repository] = "…" of published crates with [package.repository.workspace] = true 2024-08-06 00:26:42 +02:00
vfs Use Sender instead of boxed closure in vfs 2024-08-09 23:40:32 +02:00
vfs-notify Auto merge of #17843 - mo8it:flycheck, r=Veykril 2024-08-12 09:27:47 +00:00