-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print fn signature when there is closure argument type mismatch
Fixes #42143. E0281 is totally replaced by E0631. UI tests are updated accordingly.
- Loading branch information
Showing
14 changed files
with
245 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
error[E0631]: type mismatch in closure arguments | ||
--> $DIR/E0631.rs:17:5 | ||
| | ||
17 | foo(|_: isize| {}); | ||
| ^^^ ------------- found signature of `fn(isize) -> _` | ||
| | | ||
| expected signature of `fn(usize) -> _` | ||
| | ||
= note: required by `foo` | ||
|
||
error[E0631]: type mismatch in closure arguments | ||
--> $DIR/E0631.rs:18:5 | ||
| | ||
18 | bar(|_: isize| {}); | ||
| ^^^ ------------- found signature of `fn(isize) -> _` | ||
| | | ||
| expected signature of `fn(usize) -> _` | ||
| | ||
= note: required by `bar` | ||
|
||
error[E0631]: type mismatch in function arguments | ||
--> $DIR/E0631.rs:19:5 | ||
| | ||
19 | foo(f); | ||
| ^^^ | ||
| | | ||
| expected signature of `fn(usize) -> _` | ||
| found signature of `fn(u64) -> _` | ||
| | ||
= note: required by `foo` | ||
|
||
error[E0631]: type mismatch in function arguments | ||
--> $DIR/E0631.rs:20:5 | ||
| | ||
20 | bar(f); | ||
| ^^^ | ||
| | | ||
| expected signature of `fn(usize) -> _` | ||
| found signature of `fn(u64) -> _` | ||
| | ||
= note: required by `bar` | ||
|
||
error: aborting due to 4 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,45 @@ | ||
error[E0593]: closure takes 0 arguments but 2 arguments are required | ||
--> $DIR/closure-arg-count.rs:12:15 | ||
--> $DIR/closure-arg-count.rs:15:15 | ||
| | ||
12 | [1, 2, 3].sort_by(|| panic!()); | ||
15 | [1, 2, 3].sort_by(|| panic!()); | ||
| ^^^^^^^ ----------- takes 0 arguments | ||
| | | ||
| expected closure that takes 2 arguments | ||
|
||
error[E0593]: closure takes 1 argument but 2 arguments are required | ||
--> $DIR/closure-arg-count.rs:13:15 | ||
--> $DIR/closure-arg-count.rs:16:15 | ||
| | ||
13 | [1, 2, 3].sort_by(|tuple| panic!()); | ||
16 | [1, 2, 3].sort_by(|tuple| panic!()); | ||
| ^^^^^^^ ---------------- takes 1 argument | ||
| | | ||
| expected closure that takes 2 arguments | ||
|
||
error[E0308]: mismatched types | ||
--> $DIR/closure-arg-count.rs:14:24 | ||
--> $DIR/closure-arg-count.rs:17:24 | ||
| | ||
14 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!()); | ||
17 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!()); | ||
| ^^^^^^^^^^^^^^^ expected &{integer}, found tuple | ||
| | ||
= note: expected type `&{integer}` | ||
found type `(_, _)` | ||
|
||
error[E0593]: closure takes 1 argument but 2 arguments are required | ||
--> $DIR/closure-arg-count.rs:14:15 | ||
--> $DIR/closure-arg-count.rs:17:15 | ||
| | ||
14 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!()); | ||
17 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!()); | ||
| ^^^^^^^ -------------------------- takes 1 argument | ||
| | | ||
| expected closure that takes 2 arguments | ||
|
||
error: aborting due to 4 previous errors | ||
error[E0593]: closure takes 0 arguments but 1 argument is required | ||
--> $DIR/closure-arg-count.rs:18:5 | ||
| | ||
18 | f(|| panic!()); | ||
| ^ ----------- takes 0 arguments | ||
| | | ||
| expected closure that takes 1 argument | ||
| | ||
= note: required by `f` | ||
|
||
error: aborting due to 5 previous errors | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
fn main() { | ||
let a = [(1u32, 2u32)]; | ||
a.iter().map(|_: (u32, u32)| 45); | ||
a.iter().map(|_: &(u16, u16)| 45); | ||
a.iter().map(|_: (u16, u16)| 45); | ||
} | ||
|
||
fn baz<F: Fn(*mut &u32)>(_: F) {} | ||
fn _test<'a>(f: fn(*mut &'a u32)) { | ||
baz(f); | ||
} |
Oops, something went wrong.