提交 270730f5 编写于 作者: F Fausto

add suggestion to update trait if error is in impl

上级 abcccc91
......@@ -167,7 +167,9 @@ fn suggest_adding_lifetime_params(
if let Some(anon_reg) = self.tcx().is_suitable_region(sub) {
let hir_id = self.tcx().hir().local_def_id_to_hir_id(anon_reg.def_id);
let generics = match self.tcx().hir().get(hir_id) {
let node = self.tcx().hir().get(hir_id);
let is_impl = matches!(&node, hir::Node::ImplItem(_));
let generics = match node {
hir::Node::Item(&hir::Item {
kind: hir::ItemKind::Fn(_, ref generics, ..),
..
......@@ -209,8 +211,12 @@ fn suggest_adding_lifetime_params(
suggestions.push(new_param_suggestion);
}
let mut sugg = String::from("consider introducing a named lifetime parameter");
if is_impl {
sugg.push_str(" and update trait if needed");
}
err.multipart_suggestion(
"consider introducing a named lifetime parameter",
sugg.as_str(),
suggestions,
Applicability::MaybeIncorrect,
);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册