Skip to content

Commit ab0bb26

Browse files
Point to where missing return type should go
1 parent 05c6221 commit ab0bb26

36 files changed

+58
-58
lines changed

compiler/rustc_hir_analysis/src/check/compare_impl_item.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ fn report_trait_method_mismatch<'tcx>(
11881188
let ap = Applicability::MachineApplicable;
11891189
match sig.decl.output {
11901190
hir::FnRetTy::DefaultReturn(sp) => {
1191-
let sugg = format!("-> {} ", trait_sig.output());
1191+
let sugg = format!(" -> {}", trait_sig.output());
11921192
diag.span_suggestion_verbose(sp, msg, sugg, ap);
11931193
}
11941194
hir::FnRetTy::Return(hir_ty) => {

compiler/rustc_hir_typeck/src/errors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub struct AddressOfTemporaryTaken {
110110
pub enum AddReturnTypeSuggestion {
111111
#[suggestion(
112112
hir_typeck_add_return_type_add,
113-
code = "-> {found} ",
113+
code = " -> {found}",
114114
applicability = "machine-applicable"
115115
)]
116116
Add {
@@ -120,7 +120,7 @@ pub enum AddReturnTypeSuggestion {
120120
},
121121
#[suggestion(
122122
hir_typeck_add_return_type_missing_here,
123-
code = "-> _ ",
123+
code = " -> _",
124124
applicability = "has-placeholders"
125125
)]
126126
MissingHere {

compiler/rustc_infer/src/errors/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,13 @@ impl<'a> SourceKindMultiSuggestion<'a> {
194194
data: &'a FnRetTy<'a>,
195195
should_wrap_expr: Option<Span>,
196196
) -> Self {
197-
let (arrow, post) = match data {
198-
FnRetTy::DefaultReturn(_) => ("-> ", " "),
199-
_ => ("", ""),
197+
let arrow = match data {
198+
FnRetTy::DefaultReturn(_) => " -> ",
199+
_ => "",
200200
};
201201
let (start_span, start_span_code, end_span) = match should_wrap_expr {
202-
Some(end_span) => (data.span(), format!("{arrow}{ty_info}{post}{{ "), Some(end_span)),
203-
None => (data.span(), format!("{arrow}{ty_info}{post}"), None),
202+
Some(end_span) => (data.span(), format!("{arrow}{ty_info} {{"), Some(end_span)),
203+
None => (data.span(), format!("{arrow}{ty_info}"), None),
204204
};
205205
Self::ClosureReturn { start_span, start_span_code, end_span }
206206
}

compiler/rustc_parse/src/parser/ty.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl<'a> Parser<'a> {
247247
)?;
248248
FnRetTy::Ty(ty)
249249
} else {
250-
FnRetTy::Default(self.token.span.shrink_to_lo())
250+
FnRetTy::Default(self.prev_token.span.shrink_to_hi())
251251
})
252252
}
253253

tests/ui/associated-type-bounds/issue-71443-1.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0308]: mismatched types
22
--> $DIR/issue-71443-1.rs:6:5
33
|
44
LL | fn hello<F: for<'a> Iterator<Item: 'a>>() {
5-
| - help: try adding a return type: `-> Incorrect`
5+
| - help: try adding a return type: `-> Incorrect`
66
LL | Incorrect
77
| ^^^^^^^^^ expected `()`, found `Incorrect`
88

tests/ui/async-await/async-await-let-else.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ error[E0277]: `Rc<()>` cannot be sent between threads safely
2222
--> $DIR/async-await-let-else.rs:47:13
2323
|
2424
LL | async fn foo2(x: Option<bool>) {
25-
| - within this `impl Future<Output = ()>`
25+
| - within this `impl Future<Output = ()>`
2626
...
2727
LL | is_send(foo2(Some(true)));
2828
| ------- ^^^^^^^^^^^^^^^^ `Rc<()>` cannot be sent between threads safely

tests/ui/async-await/issue-64130-3-other.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ error[E0277]: the trait bound `Foo: Qux` is not satisfied in `impl Future<Output
22
--> $DIR/issue-64130-3-other.rs:25:12
33
|
44
LL | async fn bar() {
5-
| - within this `impl Future<Output = ()>`
5+
| - within this `impl Future<Output = ()>`
66
...
77
LL | is_qux(bar());
88
| ^^^^^ within `impl Future<Output = ()>`, the trait `Qux` is not implemented for `Foo`

tests/ui/async-await/issues/issue-67893.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ LL | g(issue_67893::run())
66
| |
77
| required by a bound introduced by this call
88
|
9-
::: $DIR/auxiliary/issue_67893.rs:9:20
9+
::: $DIR/auxiliary/issue_67893.rs:9:19
1010
|
1111
LL | pub async fn run() {
12-
| - within this `impl Future<Output = ()>`
12+
| - within this `impl Future<Output = ()>`
1313
|
1414
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `MutexGuard<'_, ()>`
1515
= note: required because it captures the following types: `Arc<Mutex<()>>`, `MutexGuard<'_, ()>`, `impl Future<Output = ()>`

tests/ui/async-await/mutually-recursive-async-impl-trait-type.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
error[E0733]: recursion in an `async fn` requires boxing
2-
--> $DIR/mutually-recursive-async-impl-trait-type.rs:5:18
2+
--> $DIR/mutually-recursive-async-impl-trait-type.rs:5:17
33
|
44
LL | async fn rec_1() {
5-
| ^ recursive `async fn`
5+
| ^ recursive `async fn`
66
|
77
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`
88
= note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion
99

1010
error[E0733]: recursion in an `async fn` requires boxing
11-
--> $DIR/mutually-recursive-async-impl-trait-type.rs:9:18
11+
--> $DIR/mutually-recursive-async-impl-trait-type.rs:9:17
1212
|
1313
LL | async fn rec_2() {
14-
| ^ recursive `async fn`
14+
| ^ recursive `async fn`
1515
|
1616
= note: a recursive `async fn` must be rewritten to return a boxed `dyn Future`
1717
= note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion

tests/ui/async-await/partial-drop-partial-reinit.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | gimme_send(foo());
77
| required by a bound introduced by this call
88
...
99
LL | async fn foo() {
10-
| - within this `impl Future<Output = ()>`
10+
| - within this `impl Future<Output = ()>`
1111
|
1212
= help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `NotSend`
1313
= note: required because it appears within the type `(NotSend,)`

0 commit comments

Comments
 (0)