1
Fork 0

Rollup merge of #116296 - compiler-errors:default-return, r=estebank

More accurately point to where default return type should go

When getting the "default return type" span, instead of pointing to the low span of the next token, point to the high span of the previous token. This:

1. Makes forming return type suggestions more uniform, since we expect them all in the same place.
2. Arguably makes labels easier to understand, since we're pointing to where the implicit `-> ()` would've gone, rather than the starting brace or the semicolon.

r? ```@estebank```
This commit is contained in:
Jubilee 2023-10-05 00:56:29 -07:00 committed by GitHub
commit cfce3a919d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
42 changed files with 105 additions and 89 deletions

View file

@ -1189,7 +1189,7 @@ fn report_trait_method_mismatch<'tcx>(
let ap = Applicability::MachineApplicable;
match sig.decl.output {
hir::FnRetTy::DefaultReturn(sp) => {
let sugg = format!("-> {} ", trait_sig.output());
let sugg = format!(" -> {}", trait_sig.output());
diag.span_suggestion_verbose(sp, msg, sugg, ap);
}
hir::FnRetTy::Return(hir_ty) => {