File tree 1 file changed +14
-1
lines changed
1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -203,11 +203,15 @@ fn report_elision_failure(
203
203
{
204
204
let mut m = String :: new ( ) ;
205
205
let len = params. len ( ) ;
206
+ let mut any_lifetimes = false ;
207
+
206
208
for ( i, info) in params. into_iter ( ) . enumerate ( ) {
207
209
let ElisionFailureInfo {
208
210
name, lifetime_count : n, have_bound_regions
209
211
} = info;
210
212
213
+ any_lifetimes = any_lifetimes || ( n > 0 ) ;
214
+
211
215
let help_name = if name. is_empty ( ) {
212
216
format ! ( "argument {}" , i + 1 )
213
217
} else {
@@ -229,7 +233,16 @@ fn report_elision_failure(
229
233
m. push_str ( ", " ) ;
230
234
}
231
235
}
232
- if len == 1 {
236
+
237
+ if !any_lifetimes {
238
+ fileline_help ! ( tcx. sess, default_span,
239
+ "this function's return type contains a borrowed value with \
240
+ an elided lifetime, but the lifetime cannot be derived from \
241
+ the arguments") ;
242
+ fileline_help ! ( tcx. sess, default_span,
243
+ "consider giving it an explicit bounded or 'static \
244
+ lifetime") ;
245
+ } else if len == 1 {
233
246
fileline_help ! ( tcx. sess, default_span,
234
247
"this function's return type contains a borrowed value, but \
235
248
the signature does not say which {} it is borrowed from",
You can’t perform that action at this time.
0 commit comments