fallback to provided signature in the event of a type error
This prevents regressions on some annoying cases.
This commit is contained in:
parent
053383dbef
commit
e8a96c97f4
4 changed files with 249 additions and 176 deletions
|
|
@ -40,14 +40,14 @@ fn expect_free_supply_bound() {
|
|||
// Here, we are given a function whose region is bound at closure level,
|
||||
// but we expect one bound in the argument. Error results.
|
||||
with_closure_expecting_fn_with_free_region(|x: fn(&u32), y| {});
|
||||
//~^ ERROR mismatched types
|
||||
//~^ ERROR type mismatch in closure arguments
|
||||
}
|
||||
|
||||
fn expect_bound_supply_free_from_fn<'x>(x: &'x u32) {
|
||||
// Here, we are given a `fn(&u32)` but we expect a `fn(&'x
|
||||
// u32)`. In principle, this could be ok, but we demand equality.
|
||||
with_closure_expecting_fn_with_bound_region(|x: fn(&'x u32), y| {});
|
||||
//~^ ERROR mismatched types
|
||||
//~^ ERROR type mismatch in closure arguments
|
||||
}
|
||||
|
||||
fn expect_bound_supply_free_from_closure() {
|
||||
|
|
@ -56,7 +56,7 @@ fn expect_bound_supply_free_from_closure() {
|
|||
// the argument level.
|
||||
type Foo<'a> = fn(&'a u32);
|
||||
with_closure_expecting_fn_with_bound_region(|_x: Foo<'_>, y| {});
|
||||
//~^ ERROR mismatched types
|
||||
//~^ ERROR type mismatch in closure arguments
|
||||
}
|
||||
|
||||
fn expect_bound_supply_bound<'x>(x: &'x u32) {
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ fn a() {
|
|||
fn b() {
|
||||
// Here we take the supplied types, resulting in an error later on.
|
||||
with_closure(|x: u32, y: i32| {
|
||||
//~^ ERROR mismatched types
|
||||
//~^ ERROR type mismatch in closure arguments
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,23 +14,6 @@ error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument
|
|||
| |
|
||||
| expected closure that takes 2 arguments
|
||||
|
||||
error: non-reference pattern used to match a reference (see issue #42640)
|
||||
--> $DIR/closure-arg-count.rs:17:24
|
||||
|
|
||||
17 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!());
|
||||
| ^^^^^^^^^^^^^^^ help: consider using: `&(tuple, tuple2)`
|
||||
|
|
||||
= help: add #![feature(match_default_bindings)] to the crate attributes to enable
|
||||
|
||||
error[E0308]: mismatched types
|
||||
--> $DIR/closure-arg-count.rs:17:24
|
||||
|
|
||||
17 | [1, 2, 3].sort_by(|(tuple, tuple2)| panic!());
|
||||
| ^^^^^^^^^^^^^^^ expected integral variable, found tuple
|
||||
|
|
||||
= note: expected type `{integer}`
|
||||
found type `(_, _)`
|
||||
|
||||
error[E0593]: closure is expected to take 2 arguments, but it takes 1 argument
|
||||
--> $DIR/closure-arg-count.rs:17:15
|
||||
|
|
||||
|
|
@ -73,5 +56,5 @@ error[E0593]: closure is expected to take a single 2-tuple as argument, but it t
|
|||
| |
|
||||
| expected closure that takes a single 2-tuple as argument
|
||||
|
||||
error: aborting due to 9 previous errors
|
||||
error: aborting due to 7 previous errors
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue