Rust: type inference: add test for closure argument

This commit is contained in:
Arthur Baars
2025-07-11 15:02:04 +02:00
parent 32e7a9d445
commit 519905ee9e
2 changed files with 23 additions and 5 deletions

View File

@@ -2378,6 +2378,15 @@ pub mod pattern_matching_experimental {
}
}
mod closures {
pub fn f() {
Some(1).map(|x| {
let x = x; // $ MISSING: type=x:i32
println!("{x}");
}); // $ method=map
}
}
fn main() {
field_access::f(); // $ method=f
method_impl::f(); // $ method=f
@@ -2408,4 +2417,5 @@ fn main() {
dereference::test(); // $ method=test
pattern_matching::test_all_patterns(); // $ method=test_all_patterns
pattern_matching_experimental::box_patterns(); // $ method=box_patterns
closures::f() // $ method=f
}

View File

@@ -4112,11 +4112,19 @@ inferType
| main.rs:2375:26:2375:43 | "Nested boxed: {}\\n" | &T | {EXTERNAL LOCATION} | str |
| main.rs:2375:26:2375:59 | FormatArgsExpr | | {EXTERNAL LOCATION} | Arguments |
| main.rs:2375:26:2375:59 | MacroExpr | | {EXTERNAL LOCATION} | Arguments |
| main.rs:2383:5:2383:20 | ...::f(...) | | main.rs:72:5:72:21 | Foo |
| main.rs:2384:5:2384:60 | ...::g(...) | | main.rs:72:5:72:21 | Foo |
| main.rs:2384:20:2384:38 | ...::Foo {...} | | main.rs:72:5:72:21 | Foo |
| main.rs:2384:41:2384:59 | ...::Foo {...} | | main.rs:72:5:72:21 | Foo |
| main.rs:2400:5:2400:15 | ...::f(...) | | {EXTERNAL LOCATION} | trait Future |
| main.rs:2383:9:2383:15 | Some(...) | | {EXTERNAL LOCATION} | Option |
| main.rs:2383:9:2383:15 | Some(...) | T | {EXTERNAL LOCATION} | i32 |
| main.rs:2383:9:2386:10 | ... .map(...) | | {EXTERNAL LOCATION} | Option |
| main.rs:2383:14:2383:14 | 1 | | {EXTERNAL LOCATION} | i32 |
| main.rs:2385:22:2385:26 | "{x}\\n" | | file://:0:0:0:0 | & |
| main.rs:2385:22:2385:26 | "{x}\\n" | &T | {EXTERNAL LOCATION} | str |
| main.rs:2385:22:2385:26 | FormatArgsExpr | | {EXTERNAL LOCATION} | Arguments |
| main.rs:2385:22:2385:26 | MacroExpr | | {EXTERNAL LOCATION} | Arguments |
| main.rs:2392:5:2392:20 | ...::f(...) | | main.rs:72:5:72:21 | Foo |
| main.rs:2393:5:2393:60 | ...::g(...) | | main.rs:72:5:72:21 | Foo |
| main.rs:2393:20:2393:38 | ...::Foo {...} | | main.rs:72:5:72:21 | Foo |
| main.rs:2393:41:2393:59 | ...::Foo {...} | | main.rs:72:5:72:21 | Foo |
| main.rs:2409:5:2409:15 | ...::f(...) | | {EXTERNAL LOCATION} | trait Future |
| pattern_matching.rs:13:26:133:1 | { ... } | | {EXTERNAL LOCATION} | Option |
| pattern_matching.rs:14:9:14:13 | value | | {EXTERNAL LOCATION} | Option |
| pattern_matching.rs:14:9:14:13 | value | T | {EXTERNAL LOCATION} | i32 |