Don't point out return span on every E0308

This commit is contained in:
Michael Goulet 2022-08-04 02:55:40 +00:00
parent 1b57946a40
commit c62a8ea9df
5 changed files with 59 additions and 28 deletions

View file

@ -6,11 +6,6 @@ LL | Foo(())
| |
| arguments to this struct are incorrect
|
note: return type inferred to be `{integer}` here
--> $DIR/issue-84128.rs:10:20
|
LL | return Foo(0);
| ^^^^^^
note: tuple struct defined here
--> $DIR/issue-84128.rs:5:8
|

View file

@ -0,0 +1,18 @@
// edition:2021
async fn f(_: &()) {}
//~^ NOTE function defined here
//~| NOTE
// Second note is the span of the underlined argument, I think...
fn main() {
(|| async {
Err::<(), ()>(())?;
f(());
//~^ ERROR mismatched types
//~| NOTE arguments to this function are incorrect
//~| NOTE expected `&()`, found `()`
//~| HELP consider borrowing here
Ok::<(), ()>(())
})();
}

View file

@ -0,0 +1,19 @@
error[E0308]: mismatched types
--> $DIR/dont-point-return-on-E0308.rs:10:11
|
LL | f(());
| - ^^
| | |
| | expected `&()`, found `()`
| | help: consider borrowing here: `&()`
| arguments to this function are incorrect
|
note: function defined here
--> $DIR/dont-point-return-on-E0308.rs:3:10
|
LL | async fn f(_: &()) {}
| ^ ------
error: aborting due to previous error
For more information about this error, try `rustc --explain E0308`.