Skip to content

Commit a0b8112

Browse files
The type after pattern adjustments is stored in the last adjustment, not the first
1 parent d9ac90b commit a0b8112

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/infer/pat.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ impl<'db> InferenceContext<'_, 'db> {
416416
.result
417417
.pat_adjustments
418418
.get(&pat)
419-
.and_then(|it| it.first())
419+
.and_then(|it| it.last())
420420
.unwrap_or(&self.result.type_of_pat[pat])
421421
}
422422

src/tools/rust-analyzer/crates/hir-ty/src/tests/patterns.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1259,3 +1259,22 @@ fn main() {
12591259
"#,
12601260
);
12611261
}
1262+
1263+
#[test]
1264+
fn destructuring_assign_ref() {
1265+
check_no_mismatches(
1266+
r#"
1267+
struct Foo;
1268+
1269+
fn foo() -> (&'static Foo, u32) {
1270+
(&Foo, 0)
1271+
}
1272+
1273+
fn bar() {
1274+
let ext: &Foo;
1275+
let v;
1276+
(ext, v) = foo();
1277+
}
1278+
"#,
1279+
);
1280+
}

0 commit comments

Comments
 (0)