Skip to content

Commit

Permalink
Rollup merge of #75702 - GuillaumeGomez:cleanup-e0759, r=pickfire
Browse files Browse the repository at this point in the history
Clean up E0759 explanation

r? @Dylan-DPC

cc @pickfire
  • Loading branch information
cuviper committed Aug 20, 2020
2 parents f29f212 + 7f55c83 commit ba104d2
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/librustc_error_codes/error_codes/E0759.md
Original file line number Diff line number Diff line change
@@ -1,34 +1,28 @@
A `'static` requirement in a return type involving a trait is not fulfilled.
Return type involving a trait did not require `'static` lifetime.

Erroneous code examples:

```compile_fail,E0759
use std::fmt::Debug;
fn foo(x: &i32) -> impl Debug {
fn foo(x: &i32) -> impl Debug { // error!
x
}
```
```compile_fail,E0759
# use std::fmt::Debug;
fn bar(x: &i32) -> Box<dyn Debug> {
fn bar(x: &i32) -> Box<dyn Debug> { // error!
Box::new(x)
}
```

These examples have the same semantics as the following:
Add `'static` requirement to fix them:

```compile_fail,E0759
# use std::fmt::Debug;
fn foo(x: &i32) -> impl Debug + 'static {
fn foo(x: &i32) -> impl Debug + 'static { // ok!
x
}
```
```compile_fail,E0759
# use std::fmt::Debug;
fn bar(x: &i32) -> Box<dyn Debug + 'static> {
fn bar(x: &i32) -> Box<dyn Debug + 'static> { // ok!
Box::new(x)
}
```
Expand Down

0 comments on commit ba104d2

Please sign in to comment.