From 439ef6d76279268eb80e33afffafa22597e22776 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Fri, 7 May 2021 19:44:32 +0200 Subject: Fix suggestions for missing return type lifetime parameters --- compiler/rustc_errors/src/diagnostic.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'compiler/rustc_errors/src') diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index b2f6a0c1014..405dd2e68c6 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -299,6 +299,30 @@ impl Diagnostic { self } + /// [`Diagnostic::multipart_suggestion()`] but you can set the [`SuggestionStyle`]. + pub fn multipart_suggestion_with_style( + &mut self, + msg: &str, + suggestion: Vec<(Span, String)>, + applicability: Applicability, + style: SuggestionStyle, + ) -> &mut Self { + assert!(!suggestion.is_empty()); + self.suggestions.push(CodeSuggestion { + substitutions: vec![Substitution { + parts: suggestion + .into_iter() + .map(|(span, snippet)| SubstitutionPart { snippet, span }) + .collect(), + }], + msg: msg.to_owned(), + style, + applicability, + tool_metadata: Default::default(), + }); + self + } + /// Prints out a message with for a multipart suggestion without showing the suggested code. /// /// This is intended to be used for suggestions that are obvious in what the changes need to -- cgit 1.4.1-3-g733a5 From 2448c7698ef186ead88bd7980f2cac28c55111a8 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Mon, 10 May 2021 14:59:54 +0200 Subject: More minor fixes suggested by @jackh726 --- compiler/rustc_errors/src/diagnostic.rs | 18 +- compiler/rustc_resolve/src/late/diagnostics.rs | 6 +- src/test/ui/return-elided-lifetime.rs | 37 ---- src/test/ui/return-elided-lifetime.stderr | 198 --------------------- src/test/ui/suggestions/return-elided-lifetime.rs | 37 ++++ .../ui/suggestions/return-elided-lifetime.stderr | 198 +++++++++++++++++++++ 6 files changed, 244 insertions(+), 250 deletions(-) delete mode 100644 src/test/ui/return-elided-lifetime.rs delete mode 100644 src/test/ui/return-elided-lifetime.stderr create mode 100644 src/test/ui/suggestions/return-elided-lifetime.rs create mode 100644 src/test/ui/suggestions/return-elided-lifetime.stderr (limited to 'compiler/rustc_errors/src') diff --git a/compiler/rustc_errors/src/diagnostic.rs b/compiler/rustc_errors/src/diagnostic.rs index 405dd2e68c6..14ccced2c6a 100644 --- a/compiler/rustc_errors/src/diagnostic.rs +++ b/compiler/rustc_errors/src/diagnostic.rs @@ -283,20 +283,12 @@ impl Diagnostic { suggestion: Vec<(Span, String)>, applicability: Applicability, ) -> &mut Self { - assert!(!suggestion.is_empty()); - self.suggestions.push(CodeSuggestion { - substitutions: vec![Substitution { - parts: suggestion - .into_iter() - .map(|(span, snippet)| SubstitutionPart { snippet, span }) - .collect(), - }], - msg: msg.to_owned(), - style: SuggestionStyle::ShowCode, + self.multipart_suggestion_with_style( + msg, + suggestion, applicability, - tool_metadata: Default::default(), - }); - self + SuggestionStyle::ShowCode, + ) } /// [`Diagnostic::multipart_suggestion()`] but you can set the [`SuggestionStyle`]. diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 9b82d8afd2b..fdde687d486 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1905,9 +1905,11 @@ impl<'tcx> LifetimeContext<'_, 'tcx> { let spans_suggs: Vec<_> = formatters .into_iter() - .filter_map(|fmt| fmt) .zip(spans_with_counts.iter()) - .map(|(formatter, (span, _))| (*span, formatter(name))) + .filter_map(|(fmt, (span, _))| { + if let Some(formatter) = fmt { Some((formatter, span)) } else { None } + }) + .map(|(formatter, span)| (*span, formatter(name))) .collect(); err.multipart_suggestion_with_style( &format!( diff --git a/src/test/ui/return-elided-lifetime.rs b/src/test/ui/return-elided-lifetime.rs deleted file mode 100644 index ca336bbb056..00000000000 --- a/src/test/ui/return-elided-lifetime.rs +++ /dev/null @@ -1,37 +0,0 @@ -/* Checks all four scenarios possible in report_elision_failure() of - * rustc_resolve::late::lifetimes::LifetimeContext related to returning - * borrowed values, in various configurations. - */ - -fn f1() -> &i32 { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -fn f1_() -> (&i32, &i32) { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -//~^^ ERROR missing lifetime specifier [E0106] - -fn f2(a: i32, b: i32) -> &i32 { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -fn f2_(a: i32, b: i32) -> (&i32, &i32) { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -//~^^ ERROR missing lifetime specifier [E0106] - -struct S<'a, 'b> { a: &'a i32, b: &'b i32 } -fn f3(s: &S) -> &i32 { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -fn f3_(s: &S, t: &S) -> (&i32, &i32) { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -//~^^ ERROR missing lifetime specifier [E0106] - -fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &i32 { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -//~^^ ERROR missing lifetime specifier [E0106] - -fn f5<'a>(a: &'a i32, b: &i32) -> &i32 { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &i32) { loop {} } -//~^ ERROR missing lifetime specifier [E0106] -//~^^ ERROR missing lifetime specifier [E0106] - -fn main() {} diff --git a/src/test/ui/return-elided-lifetime.stderr b/src/test/ui/return-elided-lifetime.stderr deleted file mode 100644 index 888cd5e58ab..00000000000 --- a/src/test/ui/return-elided-lifetime.stderr +++ /dev/null @@ -1,198 +0,0 @@ -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:6:12 - | -LL | fn f1() -> &i32 { loop {} } - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime - | -LL | fn f1() -> &'static i32 { loop {} } - | ^^^^^^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:8:14 - | -LL | fn f1_() -> (&i32, &i32) { loop {} } - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime - | -LL | fn f1_() -> (&'static i32, &i32) { loop {} } - | ^^^^^^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:8:20 - | -LL | fn f1_() -> (&i32, &i32) { loop {} } - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from -help: consider using the `'static` lifetime - | -LL | fn f1_() -> (&i32, &'static i32) { loop {} } - | ^^^^^^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:12:26 - | -LL | fn f2(a: i32, b: i32) -> &i32 { loop {} } - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments -help: consider using the `'static` lifetime - | -LL | fn f2(a: i32, b: i32) -> &'static i32 { loop {} } - | ^^^^^^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:14:28 - | -LL | fn f2_(a: i32, b: i32) -> (&i32, &i32) { loop {} } - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments -help: consider using the `'static` lifetime - | -LL | fn f2_(a: i32, b: i32) -> (&'static i32, &i32) { loop {} } - | ^^^^^^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:14:34 - | -LL | fn f2_(a: i32, b: i32) -> (&i32, &i32) { loop {} } - | ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments -help: consider using the `'static` lifetime - | -LL | fn f2_(a: i32, b: i32) -> (&i32, &'static i32) { loop {} } - | ^^^^^^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:19:17 - | -LL | fn f3(s: &S) -> &i32 { loop {} } - | -- ^ expected named lifetime parameter - | - = help: this function's return type contains a borrowed value, but the signature does not say which one of `s`'s 3 lifetimes it is borrowed from -help: consider introducing a named lifetime parameter - | -LL | fn f3<'a>(s: &'a S) -> &'a i32 { loop {} } - | ^^^^ ^^^^^ ^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:21:26 - | -LL | fn f3_(s: &S, t: &S) -> (&i32, &i32) { loop {} } - | -- -- ^ 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 one of `s`'s 3 lifetimes or one of `t`'s 3 lifetimes -help: consider introducing a named lifetime parameter - | -LL | fn f3_<'a>(s: &'a S, t: &'a S) -> (&'a i32, &i32) { loop {} } - | ^^^^ ^^^^^ ^^^^^ ^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:21:32 - | -LL | fn f3_(s: &S, t: &S) -> (&i32, &i32) { loop {} } - | -- -- ^ 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 one of `s`'s 3 lifetimes or one of `t`'s 3 lifetimes -help: consider introducing a named lifetime parameter - | -LL | fn f3_<'a>(s: &'a S, t: &'a S) -> (&i32, &'a i32) { loop {} } - | ^^^^ ^^^^^ ^^^^^ ^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:25:42 - | -LL | fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &i32 { loop {} } - | ------- ------- ^ 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 `a` or `b` -note: these named lifetimes are available to use - --> $DIR/return-elided-lifetime.rs:25:7 - | -LL | fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &i32 { loop {} } - | ^^ ^^ -help: consider using one of the available lifetimes here - | -LL | fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &'lifetime i32 { loop {} } - | ^^^^^^^^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:27:44 - | -LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } - | ------- ------- ^ 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 `a` or `b` -note: these named lifetimes are available to use - --> $DIR/return-elided-lifetime.rs:27:8 - | -LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } - | ^^ ^^ -help: consider using one of the available lifetimes here - | -LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&'lifetime i32, &i32) { loop {} } - | ^^^^^^^^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:27:50 - | -LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } - | ------- ------- ^ 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 `a` or `b` -note: these named lifetimes are available to use - --> $DIR/return-elided-lifetime.rs:27:8 - | -LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } - | ^^ ^^ -help: consider using one of the available lifetimes here - | -LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &'lifetime i32) { loop {} } - | ^^^^^^^^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:31:35 - | -LL | fn f5<'a>(a: &'a i32, b: &i32) -> &i32 { loop {} } - | ------- ---- ^ 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 `a` or `b` -help: consider using the `'a` lifetime - | -LL | fn f5<'a>(a: &'a i32, b: &i32) -> &'a i32 { loop {} } - | ^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:33:37 - | -LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &i32) { loop {} } - | ------- ---- ^ 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 `a` or `b` -help: consider using the `'a` lifetime - | -LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&'a i32, &i32) { loop {} } - | ^^^ - -error[E0106]: missing lifetime specifier - --> $DIR/return-elided-lifetime.rs:33:43 - | -LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &i32) { loop {} } - | ------- ---- ^ 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 `a` or `b` -help: consider using the `'a` lifetime - | -LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &'a i32) { loop {} } - | ^^^ - -error: aborting due to 15 previous errors - -For more information about this error, try `rustc --explain E0106`. diff --git a/src/test/ui/suggestions/return-elided-lifetime.rs b/src/test/ui/suggestions/return-elided-lifetime.rs new file mode 100644 index 00000000000..ca336bbb056 --- /dev/null +++ b/src/test/ui/suggestions/return-elided-lifetime.rs @@ -0,0 +1,37 @@ +/* Checks all four scenarios possible in report_elision_failure() of + * rustc_resolve::late::lifetimes::LifetimeContext related to returning + * borrowed values, in various configurations. + */ + +fn f1() -> &i32 { loop {} } +//~^ ERROR missing lifetime specifier [E0106] +fn f1_() -> (&i32, &i32) { loop {} } +//~^ ERROR missing lifetime specifier [E0106] +//~^^ ERROR missing lifetime specifier [E0106] + +fn f2(a: i32, b: i32) -> &i32 { loop {} } +//~^ ERROR missing lifetime specifier [E0106] +fn f2_(a: i32, b: i32) -> (&i32, &i32) { loop {} } +//~^ ERROR missing lifetime specifier [E0106] +//~^^ ERROR missing lifetime specifier [E0106] + +struct S<'a, 'b> { a: &'a i32, b: &'b i32 } +fn f3(s: &S) -> &i32 { loop {} } +//~^ ERROR missing lifetime specifier [E0106] +fn f3_(s: &S, t: &S) -> (&i32, &i32) { loop {} } +//~^ ERROR missing lifetime specifier [E0106] +//~^^ ERROR missing lifetime specifier [E0106] + +fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &i32 { loop {} } +//~^ ERROR missing lifetime specifier [E0106] +fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } +//~^ ERROR missing lifetime specifier [E0106] +//~^^ ERROR missing lifetime specifier [E0106] + +fn f5<'a>(a: &'a i32, b: &i32) -> &i32 { loop {} } +//~^ ERROR missing lifetime specifier [E0106] +fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &i32) { loop {} } +//~^ ERROR missing lifetime specifier [E0106] +//~^^ ERROR missing lifetime specifier [E0106] + +fn main() {} diff --git a/src/test/ui/suggestions/return-elided-lifetime.stderr b/src/test/ui/suggestions/return-elided-lifetime.stderr new file mode 100644 index 00000000000..888cd5e58ab --- /dev/null +++ b/src/test/ui/suggestions/return-elided-lifetime.stderr @@ -0,0 +1,198 @@ +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:6:12 + | +LL | fn f1() -> &i32 { loop {} } + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | fn f1() -> &'static i32 { loop {} } + | ^^^^^^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:8:14 + | +LL | fn f1_() -> (&i32, &i32) { loop {} } + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | fn f1_() -> (&'static i32, &i32) { loop {} } + | ^^^^^^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:8:20 + | +LL | fn f1_() -> (&i32, &i32) { loop {} } + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from +help: consider using the `'static` lifetime + | +LL | fn f1_() -> (&i32, &'static i32) { loop {} } + | ^^^^^^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:12:26 + | +LL | fn f2(a: i32, b: i32) -> &i32 { loop {} } + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments +help: consider using the `'static` lifetime + | +LL | fn f2(a: i32, b: i32) -> &'static i32 { loop {} } + | ^^^^^^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:14:28 + | +LL | fn f2_(a: i32, b: i32) -> (&i32, &i32) { loop {} } + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments +help: consider using the `'static` lifetime + | +LL | fn f2_(a: i32, b: i32) -> (&'static i32, &i32) { loop {} } + | ^^^^^^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:14:34 + | +LL | fn f2_(a: i32, b: i32) -> (&i32, &i32) { loop {} } + | ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value with an elided lifetime, but the lifetime cannot be derived from the arguments +help: consider using the `'static` lifetime + | +LL | fn f2_(a: i32, b: i32) -> (&i32, &'static i32) { loop {} } + | ^^^^^^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:19:17 + | +LL | fn f3(s: &S) -> &i32 { loop {} } + | -- ^ expected named lifetime parameter + | + = help: this function's return type contains a borrowed value, but the signature does not say which one of `s`'s 3 lifetimes it is borrowed from +help: consider introducing a named lifetime parameter + | +LL | fn f3<'a>(s: &'a S) -> &'a i32 { loop {} } + | ^^^^ ^^^^^ ^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:21:26 + | +LL | fn f3_(s: &S, t: &S) -> (&i32, &i32) { loop {} } + | -- -- ^ 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 one of `s`'s 3 lifetimes or one of `t`'s 3 lifetimes +help: consider introducing a named lifetime parameter + | +LL | fn f3_<'a>(s: &'a S, t: &'a S) -> (&'a i32, &i32) { loop {} } + | ^^^^ ^^^^^ ^^^^^ ^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:21:32 + | +LL | fn f3_(s: &S, t: &S) -> (&i32, &i32) { loop {} } + | -- -- ^ 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 one of `s`'s 3 lifetimes or one of `t`'s 3 lifetimes +help: consider introducing a named lifetime parameter + | +LL | fn f3_<'a>(s: &'a S, t: &'a S) -> (&i32, &'a i32) { loop {} } + | ^^^^ ^^^^^ ^^^^^ ^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:25:42 + | +LL | fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &i32 { loop {} } + | ------- ------- ^ 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 `a` or `b` +note: these named lifetimes are available to use + --> $DIR/return-elided-lifetime.rs:25:7 + | +LL | fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &i32 { loop {} } + | ^^ ^^ +help: consider using one of the available lifetimes here + | +LL | fn f4<'a, 'b>(a: &'a i32, b: &'b i32) -> &'lifetime i32 { loop {} } + | ^^^^^^^^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:27:44 + | +LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } + | ------- ------- ^ 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 `a` or `b` +note: these named lifetimes are available to use + --> $DIR/return-elided-lifetime.rs:27:8 + | +LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } + | ^^ ^^ +help: consider using one of the available lifetimes here + | +LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&'lifetime i32, &i32) { loop {} } + | ^^^^^^^^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:27:50 + | +LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } + | ------- ------- ^ 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 `a` or `b` +note: these named lifetimes are available to use + --> $DIR/return-elided-lifetime.rs:27:8 + | +LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &i32) { loop {} } + | ^^ ^^ +help: consider using one of the available lifetimes here + | +LL | fn f4_<'a, 'b>(a: &'a i32, b: &'b i32) -> (&i32, &'lifetime i32) { loop {} } + | ^^^^^^^^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:31:35 + | +LL | fn f5<'a>(a: &'a i32, b: &i32) -> &i32 { loop {} } + | ------- ---- ^ 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 `a` or `b` +help: consider using the `'a` lifetime + | +LL | fn f5<'a>(a: &'a i32, b: &i32) -> &'a i32 { loop {} } + | ^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:33:37 + | +LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &i32) { loop {} } + | ------- ---- ^ 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 `a` or `b` +help: consider using the `'a` lifetime + | +LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&'a i32, &i32) { loop {} } + | ^^^ + +error[E0106]: missing lifetime specifier + --> $DIR/return-elided-lifetime.rs:33:43 + | +LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &i32) { loop {} } + | ------- ---- ^ 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 `a` or `b` +help: consider using the `'a` lifetime + | +LL | fn f5_<'a>(a: &'a i32, b: &i32) -> (&i32, &'a i32) { loop {} } + | ^^^ + +error: aborting due to 15 previous errors + +For more information about this error, try `rustc --explain E0106`. -- cgit 1.4.1-3-g733a5