提交 bb502c48 编写于 作者: E Esteban Küber

Provide verbose suggestion for new output type

上级 5af3dec5
......@@ -338,20 +338,18 @@ fn compare_predicate_entailment<'tcx>(
ImplItemKind::Fn(ref sig, _)
if sig.header.asyncness == hir::IsAsync::NotAsync =>
{
let (span, sugg) = match sig.decl.output {
let msg = "change the output type to match the trait";
let ap = Applicability::MachineApplicable;
match sig.decl.output {
hir::FnRetTy::DefaultReturn(sp) => {
(sp, format!(" -> {} ", trait_sig.output()))
let sugg = format!("-> {} ", trait_sig.output());
diag.span_suggestion_verbose(sp, msg, sugg, ap);
}
hir::FnRetTy::Return(hir_ty) => {
(hir_ty.span, trait_sig.output().to_string())
let sugg = trait_sig.output().to_string();
diag.span_suggestion(hir_ty.span, msg, sugg, ap);
}
};
diag.span_suggestion(
span,
"change the output type to match the trait",
sugg,
Applicability::MachineApplicable,
);
}
_ => {}
};
......
......@@ -32,13 +32,14 @@ LL | fn bar(self) -> Option<()>;
| ---------- type in trait
...
LL | fn bar(self) {}
| ^
| |
| expected enum `Option`, found `()`
| help: change the output type to match the trait: `-> Option<()>`
| ^ expected enum `Option`, found `()`
|
= note: expected fn pointer `fn(MyFuture) -> Option<()>`
found fn pointer `fn(MyFuture)`
help: change the output type to match the trait
|
LL | fn bar(self) -> Option<()> {}
| ^^^^^^^^^^^^^
error: aborting due to 3 previous errors
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册