Handle methods in try diagnostic
The diagnostic for diagnostic for methods and trait provided methods would only show the empty string: error[E0277]: the `?` operator can only be used in that returns `Result` or `Option` (or another type that implements `std::ops::Try`) Handle the missing cases so it reads ``a method'' / ``an async method'' / ``a trait method'' respectively. Signed-off-by: Philipp Gesang <phg@phi-gamma.net>
This commit is contained in:
parent
ce361fb24f
commit
5dee7dddf2
1 changed files with 18 additions and 0 deletions
|
@ -67,6 +67,24 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> {
|
|||
"a function"
|
||||
})
|
||||
})
|
||||
} else if let hir::Node::TraitItem(hir::TraitItem {
|
||||
kind: hir::TraitItemKind::Method(_, hir::TraitMethod::Provided(body_id)),
|
||||
..
|
||||
}) = &node
|
||||
{
|
||||
self.describe_generator(*body_id).or_else(|| Some("a trait method"))
|
||||
} else if let hir::Node::ImplItem(hir::ImplItem {
|
||||
kind: hir::ImplItemKind::Method(sig, body_id),
|
||||
..
|
||||
}) = &node
|
||||
{
|
||||
self.describe_generator(*body_id).or_else(|| {
|
||||
Some(if let hir::FnHeader { asyncness: hir::IsAsync::Async, .. } = sig.header {
|
||||
"an async method"
|
||||
} else {
|
||||
"a method"
|
||||
})
|
||||
})
|
||||
} else if let hir::Node::Expr(hir::Expr {
|
||||
kind: hir::ExprKind::Closure(_is_move, _, body_id, _, gen_movability),
|
||||
..
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue