Skip to content

Commit ba104d2

Browse files
authored
Rollup merge of #75702 - GuillaumeGomez:cleanup-e0759, r=pickfire
Clean up E0759 explanation r? @Dylan-DPC cc @pickfire
2 parents f29f212 + 7f55c83 commit ba104d2

File tree

1 file changed

+6
-12
lines changed
  • src/librustc_error_codes/error_codes

1 file changed

+6
-12
lines changed

src/librustc_error_codes/error_codes/E0759.md

+6-12
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,28 @@
1-
A `'static` requirement in a return type involving a trait is not fulfilled.
1+
Return type involving a trait did not require `'static` lifetime.
22

33
Erroneous code examples:
44

55
```compile_fail,E0759
66
use std::fmt::Debug;
77
8-
fn foo(x: &i32) -> impl Debug {
8+
fn foo(x: &i32) -> impl Debug { // error!
99
x
1010
}
11-
```
1211
13-
```compile_fail,E0759
14-
# use std::fmt::Debug;
15-
fn bar(x: &i32) -> Box<dyn Debug> {
12+
fn bar(x: &i32) -> Box<dyn Debug> { // error!
1613
Box::new(x)
1714
}
1815
```
1916

20-
These examples have the same semantics as the following:
17+
Add `'static` requirement to fix them:
2118

2219
```compile_fail,E0759
2320
# use std::fmt::Debug;
24-
fn foo(x: &i32) -> impl Debug + 'static {
21+
fn foo(x: &i32) -> impl Debug + 'static { // ok!
2522
x
2623
}
27-
```
2824
29-
```compile_fail,E0759
30-
# use std::fmt::Debug;
31-
fn bar(x: &i32) -> Box<dyn Debug + 'static> {
25+
fn bar(x: &i32) -> Box<dyn Debug + 'static> { // ok!
3226
Box::new(x)
3327
}
3428
```

0 commit comments

Comments
 (0)