Fix garbled suggestion for missing lifetime specifier
This commit is contained in:
parent
a4f832b275
commit
f333b4795c
3 changed files with 45 additions and 0 deletions
|
@ -1962,6 +1962,8 @@ impl<'tcx> LifetimeContext<'_, 'tcx> {
|
||||||
hir::GenericParamKind::Type {
|
hir::GenericParamKind::Type {
|
||||||
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
|
synthetic: Some(hir::SyntheticTyParamKind::ImplTrait),
|
||||||
..
|
..
|
||||||
|
} | hir::GenericParamKind::Lifetime {
|
||||||
|
kind: hir::LifetimeParamKind::Elided
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}) {
|
}) {
|
||||||
|
|
16
src/test/ui/suggestions/issue-86667.rs
Normal file
16
src/test/ui/suggestions/issue-86667.rs
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
// Regression test for #86667, where a garbled suggestion was issued for
|
||||||
|
// a missing named lifetime parameter.
|
||||||
|
|
||||||
|
// compile-flags: --edition 2018
|
||||||
|
|
||||||
|
async fn a(s1: &str, s2: &str) -> &str {
|
||||||
|
//~^ ERROR: missing lifetime specifier [E0106]
|
||||||
|
s1
|
||||||
|
}
|
||||||
|
|
||||||
|
fn b(s1: &str, s2: &str) -> &str {
|
||||||
|
//~^ ERROR: missing lifetime specifier [E0106]
|
||||||
|
s1
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {}
|
27
src/test/ui/suggestions/issue-86667.stderr
Normal file
27
src/test/ui/suggestions/issue-86667.stderr
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/issue-86667.rs:6:35
|
||||||
|
|
|
||||||
|
LL | async fn a(s1: &str, s2: &str) -> &str {
|
||||||
|
| ---- ---- ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `s1` or `s2`
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | async fn a<'a>(s1: &'a str, s2: &'a str) -> &'a str {
|
||||||
|
| ^^^^ ^^^^^^^ ^^^^^^^ ^^^
|
||||||
|
|
||||||
|
error[E0106]: missing lifetime specifier
|
||||||
|
--> $DIR/issue-86667.rs:11:29
|
||||||
|
|
|
||||||
|
LL | fn b(s1: &str, s2: &str) -> &str {
|
||||||
|
| ---- ---- ^ expected named lifetime parameter
|
||||||
|
|
|
||||||
|
= help: this function's return type contains a borrowed value, but the signature does not say whether it is borrowed from `s1` or `s2`
|
||||||
|
help: consider introducing a named lifetime parameter
|
||||||
|
|
|
||||||
|
LL | fn b<'a>(s1: &'a str, s2: &'a str) -> &'a str {
|
||||||
|
| ^^^^ ^^^^^^^ ^^^^^^^ ^^^
|
||||||
|
|
||||||
|
error: aborting due to 2 previous errors
|
||||||
|
|
||||||
|
For more information about this error, try `rustc --explain E0106`.
|
Loading…
Add table
Add a link
Reference in a new issue