diff options
| author | Michael Goulet <michael@errs.io> | 2024-11-02 03:42:10 +0000 |
|---|---|---|
| committer | Michael Goulet <michael@errs.io> | 2024-11-02 03:42:10 +0000 |
| commit | 78bbc648c5b2e6e092167d2ed593cd89f06dd37f (patch) | |
| tree | 2703a043ef2b9f32ea067f4380dce22a536be7f5 /tests | |
| parent | 7c7bb7dc017545db732f5cffec684bbaeae0a9a0 (diff) | |
| download | rust-78bbc648c5b2e6e092167d2ed593cd89f06dd37f.tar.gz rust-78bbc648c5b2e6e092167d2ed593cd89f06dd37f.zip | |
Fix closure arg extraction in extract_callable_info
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/closures/correct-args-on-call-suggestion.rs | 7 | ||||
| -rw-r--r-- | tests/ui/closures/correct-args-on-call-suggestion.stderr | 20 |
2 files changed, 27 insertions, 0 deletions
diff --git a/tests/ui/closures/correct-args-on-call-suggestion.rs b/tests/ui/closures/correct-args-on-call-suggestion.rs new file mode 100644 index 00000000000..fa7915a7c03 --- /dev/null +++ b/tests/ui/closures/correct-args-on-call-suggestion.rs @@ -0,0 +1,7 @@ +// Ensure we give the right args when we suggest calling a closure. + +fn main() { + let x = |a: i32, b: i32| a + b; + let y: i32 = x; + //~^ ERROR mismatched types +} diff --git a/tests/ui/closures/correct-args-on-call-suggestion.stderr b/tests/ui/closures/correct-args-on-call-suggestion.stderr new file mode 100644 index 00000000000..2613c7776b2 --- /dev/null +++ b/tests/ui/closures/correct-args-on-call-suggestion.stderr @@ -0,0 +1,20 @@ +error[E0308]: mismatched types + --> $DIR/correct-args-on-call-suggestion.rs:5:18 + | +LL | let x = |a: i32, b: i32| a + b; + | ---------------- the found closure +LL | let y: i32 = x; + | --- ^ expected `i32`, found closure + | | + | expected due to this + | + = note: expected type `i32` + found closure `{closure@$DIR/correct-args-on-call-suggestion.rs:4:13: 4:29}` +help: use parentheses to call this closure + | +LL | let y: i32 = x(/* i32 */, /* i32 */); + | ++++++++++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. |
