Don't suggest adding 'static
lifetime to arguments
Fixes #69350 This is almost always the wrong this to do
This commit is contained in:
parent
31bd868c39
commit
bc6330d47a
11 changed files with 10 additions and 41 deletions
|
@ -114,12 +114,16 @@ impl<'a, 'tcx> NiceRegionError<'a, 'tcx> {
|
|||
);
|
||||
|
||||
diag.span_label(span, format!("lifetime `{}` required", named));
|
||||
diag.span_suggestion(
|
||||
new_ty_span,
|
||||
&format!("add explicit lifetime `{}` to {}", named, span_label_var),
|
||||
new_ty.to_string(),
|
||||
Applicability::Unspecified,
|
||||
);
|
||||
// Suggesting `'static` is nearly always incorrect, and can steer users
|
||||
// down the wrong path.
|
||||
if *named != ty::ReStatic {
|
||||
diag.span_suggestion(
|
||||
new_ty_span,
|
||||
&format!("add explicit lifetime `{}` to {}", named, span_label_var),
|
||||
new_ty.to_string(),
|
||||
Applicability::Unspecified,
|
||||
);
|
||||
}
|
||||
|
||||
Some(diag)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue