@@ -203,11 +203,15 @@ fn report_elision_failure(
203203{
204204 let mut m = String :: new ( ) ;
205205 let len = params. len ( ) ;
206+ let mut any_lifetimes = false ;
207+
206208 for ( i, info) in params. into_iter ( ) . enumerate ( ) {
207209 let ElisionFailureInfo {
208210 name, lifetime_count : n, have_bound_regions
209211 } = info;
210212
213+ any_lifetimes = any_lifetimes || ( n > 0 ) ;
214+
211215 let help_name = if name. is_empty ( ) {
212216 format ! ( "argument {}" , i + 1 )
213217 } else {
@@ -229,17 +233,26 @@ fn report_elision_failure(
229233 m. push_str ( ", " ) ;
230234 }
231235 }
232- if len == 1 {
233- fileline_help ! ( tcx. sess, default_span,
234- "this function's return type contains a borrowed value, but \
235- the signature does not say which {} it is borrowed from",
236- m) ;
237- } else if len == 0 {
236+
237+ if len == 0 {
238238 fileline_help ! ( tcx. sess, default_span,
239239 "this function's return type contains a borrowed value, but \
240240 there is no value for it to be borrowed from") ;
241241 fileline_help ! ( tcx. sess, default_span,
242242 "consider giving it a 'static lifetime" ) ;
243+ } else if !any_lifetimes {
244+ fileline_help ! ( tcx. sess, default_span,
245+ "this function's return type contains a borrowed value with \
246+ an elided lifetime, but the lifetime cannot be derived from \
247+ the arguments") ;
248+ fileline_help ! ( tcx. sess, default_span,
249+ "consider giving it an explicit bounded or 'static \
250+ lifetime") ;
251+ } else if len == 1 {
252+ fileline_help ! ( tcx. sess, default_span,
253+ "this function's return type contains a borrowed value, but \
254+ the signature does not say which {} it is borrowed from",
255+ m) ;
243256 } else {
244257 fileline_help ! ( tcx. sess, default_span,
245258 "this function's return type contains a borrowed value, but \
0 commit comments