mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-27 09:14:20 +00:00
Auto merge of #14550 - HKalbasi:mir, r=HKalbasi
Fix inference in nested closures fix https://github.com/rust-lang/rust-analyzer/pull/14470#issuecomment-1503084796
This commit is contained in:
commit
600283f2de
@ -462,7 +462,7 @@ impl InferenceContext<'_> {
|
||||
}
|
||||
|
||||
fn expr_ty(&mut self, expr: ExprId) -> Ty {
|
||||
self.infer_expr_no_expect(expr)
|
||||
self.result[expr].clone()
|
||||
}
|
||||
|
||||
fn is_upvar(&self, place: &HirPlace) -> bool {
|
||||
|
@ -1067,6 +1067,23 @@ fn parse_arule() {
|
||||
)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nested_closure() {
|
||||
check_types(
|
||||
r#"
|
||||
//- minicore: fn, option
|
||||
|
||||
fn map<T, U>(o: Option<T>, f: impl FnOnce(T) -> U) -> Option<U> { loop {} }
|
||||
|
||||
fn test() {
|
||||
let o = Some(Some(2));
|
||||
map(o, |s| map(s, |x| x));
|
||||
// ^ i32
|
||||
}
|
||||
"#,
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn call_expected_type_closure() {
|
||||
check_types(
|
||||
|
Loading…
Reference in New Issue
Block a user