Skip to content

Commit 5c77f0d

Browse files
author
Nick Hamann
committed
Remove extended explanation of lifetime elision from E0106.
I've just added a link instead to the lifetime elision section of the book.
1 parent 33a30f2 commit 5c77f0d

File tree

1 file changed

+3
-25
lines changed

1 file changed

+3
-25
lines changed

src/librustc_typeck/diagnostics.rs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -230,31 +230,7 @@ type MyStr<'a> = &'a str; //correct
230230
231231
Lifetime elision is a special, limited kind of inference for lifetimes in
232232
function signatures which allows you to leave out lifetimes in certain cases.
233-
For example, the lifetimes on parameter in the following function signatures
234-
have been left out, but they still compile successfully:
235-
236-
```
237-
fn foo(x: &str) { }
238-
239-
fn bar(x: &str, y: &str) { }
240-
241-
fn baz(x: &str) -> &str { x }
242-
```
243-
244-
To explain the lifetime elision rules, we need to first discuss some background.
245-
The lifetime elision rules consider each lifetime in a function signature,
246-
whether it's elided or not, to be in a certain position, either *input
247-
position*, for function parameters, or *output position*, for the return type.
248-
For example, the function:
249-
250-
```
251-
fn hello<'a>(name: &'a str) -> (&'static str, &str) {
252-
("hello", name)
253-
}
254-
```
255-
256-
has a signature with one lifetime in input position and two lifetimes in output
257-
position.
233+
For more background on lifetime elision see [the book][book-le].
258234
259235
The lifetime elision rules require that any function signature with an elided
260236
output lifetime must either have
@@ -279,6 +255,8 @@ fn bar(x: &str, y: &str) -> &str { ... }
279255
// error, `y`'s lifetime is inferred to be distinct from `x`'s
280256
fn baz<'a>(x: &'a str, y: &str) -> &str { ... }
281257
```
258+
259+
[book-le]: http://doc.rust-lang.org/nightly/book/lifetimes.html#lifetime-elision
282260
"##,
283261

284262
E0107: r##"

0 commit comments

Comments
 (0)