Skip to content

Commit 9569c63

Browse files
author
Jack Fransham
committed
Avoid showing no-derivable-lifetime error message when there are no arguments
1 parent a1a48c4 commit 9569c63

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/librustc_typeck/astconv.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,13 @@ fn report_elision_failure(
234234
}
235235
}
236236

237-
if !any_lifetimes {
237+
if len == 0 {
238+
fileline_help!(tcx.sess, default_span,
239+
"this function's return type contains a borrowed value, but \
240+
there is no value for it to be borrowed from");
241+
fileline_help!(tcx.sess, default_span,
242+
"consider giving it a 'static lifetime");
243+
} else if !any_lifetimes {
238244
fileline_help!(tcx.sess, default_span,
239245
"this function's return type contains a borrowed value with \
240246
an elided lifetime, but the lifetime cannot be derived from \
@@ -247,12 +253,6 @@ fn report_elision_failure(
247253
"this function's return type contains a borrowed value, but \
248254
the signature does not say which {} it is borrowed from",
249255
m);
250-
} else if len == 0 {
251-
fileline_help!(tcx.sess, default_span,
252-
"this function's return type contains a borrowed value, but \
253-
there is no value for it to be borrowed from");
254-
fileline_help!(tcx.sess, default_span,
255-
"consider giving it a 'static lifetime");
256256
} else {
257257
fileline_help!(tcx.sess, default_span,
258258
"this function's return type contains a borrowed value, but \

0 commit comments

Comments
 (0)