We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 5d41aff + 85f9235 commit 600283fCopy full SHA for 600283f
crates/hir-ty/src/infer/closure.rs
@@ -462,7 +462,7 @@ impl InferenceContext<'_> {
462
}
463
464
fn expr_ty(&mut self, expr: ExprId) -> Ty {
465
- self.infer_expr_no_expect(expr)
+ self.result[expr].clone()
466
467
468
fn is_upvar(&self, place: &HirPlace) -> bool {
crates/hir-ty/src/tests/regression.rs
@@ -1067,6 +1067,23 @@ fn parse_arule() {
1067
)
1068
1069
1070
+#[test]
1071
+fn nested_closure() {
1072
+ check_types(
1073
+ r#"
1074
+//- minicore: fn, option
1075
+
1076
+fn map<T, U>(o: Option<T>, f: impl FnOnce(T) -> U) -> Option<U> { loop {} }
1077
1078
+fn test() {
1079
+ let o = Some(Some(2));
1080
+ map(o, |s| map(s, |x| x));
1081
+ // ^ i32
1082
+}
1083
+ "#,
1084
+ );
1085
1086
1087
#[test]
1088
fn call_expected_type_closure() {
1089
check_types(
0 commit comments