Skip to content

Commit 92e393c

Browse files
committed
Auto merge of rust-lang#13624 - lowr:fix/unsize-array-inference-variable, r=lnicola
fix: resolve inference variable before applying adjustments Fixes rust-lang#13619
2 parents 0dd0dfb + 1ad11b5 commit 92e393c

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

crates/hir-ty/src/method_resolution.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ pub struct ReceiverAdjustments {
541541

542542
impl ReceiverAdjustments {
543543
pub(crate) fn apply(&self, table: &mut InferenceTable<'_>, ty: Ty) -> (Ty, Vec<Adjustment>) {
544-
let mut ty = ty;
544+
let mut ty = table.resolve_ty_shallow(&ty);
545545
let mut adjust = Vec::new();
546546
for _ in 0..self.autoderefs {
547547
match autoderef::autoderef_step(table, ty.clone()) {

crates/hir-ty/src/tests/regression.rs

+16
Original file line numberDiff line numberDiff line change
@@ -1707,3 +1707,19 @@ impl<T, const N: usize> Trait for [T; N] {
17071707
"#,
17081708
);
17091709
}
1710+
1711+
#[test]
1712+
fn unsize_array_with_inference_variable() {
1713+
check_types(
1714+
r#"
1715+
//- minicore: try, slice
1716+
use core::ops::ControlFlow;
1717+
fn foo() -> ControlFlow<(), [usize; 1]> { loop {} }
1718+
fn bar() -> ControlFlow<(), ()> {
1719+
let a = foo()?.len();
1720+
//^ usize
1721+
ControlFlow::Continue(())
1722+
}
1723+
"#,
1724+
);
1725+
}

0 commit comments

Comments
 (0)