Gracefully handle mistyping -> as => in function return type

This commit is contained in:
mibac138 2020-10-14 22:27:48 +02:00
parent c4926d01ad
commit 5404deeb64
9 changed files with 96 additions and 6 deletions

View file

@ -0,0 +1,18 @@
// run-rustfix
#![allow(unused)]
fn a() -> usize { 0 }
//~^ ERROR return types are denoted using `->`
fn bar(_: u32) {}
fn baz() -> *const dyn Fn(u32) { unimplemented!() }
fn foo() {
match () {
_ if baz() == &bar as &dyn Fn(u32) => (),
() => (),
}
}
fn main() {
}

View file

@ -0,0 +1,18 @@
// run-rustfix
#![allow(unused)]
fn a() => usize { 0 }
//~^ ERROR return types are denoted using `->`
fn bar(_: u32) {}
fn baz() -> *const dyn Fn(u32) { unimplemented!() }
fn foo() {
match () {
_ if baz() == &bar as &dyn Fn(u32) => (),
() => (),
}
}
fn main() {
}

View file

@ -0,0 +1,8 @@
error: return types are denoted using `->`
--> $DIR/fn-fat-arrow-return.rs:3:8
|
LL | fn a() => usize { 0 }
| ^^ help: use `->` instead
error: aborting due to previous error

View file

@ -0,0 +1,10 @@
fn a() => impl Fn() => bool {
//~^ ERROR return types are denoted using `->`
//~| ERROR expected `;` or `{`, found `=>`
unimplemented!()
}
fn main() {
let foo = |a: bool| => bool { a };
dbg!(foo(false));
}

View file

@ -0,0 +1,14 @@
error: return types are denoted using `->`
--> $DIR/fn-fat-arrow-return2.rs:1:8
|
LL | fn a() => impl Fn() => bool {
| ^^ help: use `->` instead
error: expected `;` or `{`, found `=>`
--> $DIR/fn-fat-arrow-return2.rs:1:21
|
LL | fn a() => impl Fn() => bool {
| ^^ expected `;` or `{`
error: aborting due to 2 previous errors