mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-28 14:03:35 +00:00
fix: resolve inference variable before applying adjustments
This commit is contained in:
parent
0dd0dfb7df
commit
1ad11b5366
2 changed files with 17 additions and 1 deletions
|
@ -541,7 +541,7 @@ pub struct ReceiverAdjustments {
|
|||
|
||||
impl ReceiverAdjustments {
|
||||
pub(crate) fn apply(&self, table: &mut InferenceTable<'_>, ty: Ty) -> (Ty, Vec<Adjustment>) {
|
||||
let mut ty = ty;
|
||||
let mut ty = table.resolve_ty_shallow(&ty);
|
||||
let mut adjust = Vec::new();
|
||||
for _ in 0..self.autoderefs {
|
||||
match autoderef::autoderef_step(table, ty.clone()) {
|
||||
|
|
|
@ -1707,3 +1707,19 @@ impl<T, const N: usize> Trait for [T; N] {
|
|||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unsize_array_with_inference_variable() {
|
||||
check_types(
|
||||
r#"
|
||||
//- minicore: try, slice
|
||||
use core::ops::ControlFlow;
|
||||
fn foo() -> ControlFlow<(), [usize; 1]> { loop {} }
|
||||
fn bar() -> ControlFlow<(), ()> {
|
||||
let a = foo()?.len();
|
||||
//^ usize
|
||||
ControlFlow::Continue(())
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue