Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up E0759 explanation #75702

Merged
merged 2 commits into from
Aug 20, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor

@pickfire pickfire Aug 19, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still needs Debug? I saw that the rest have the use removed. Oh looks like it is not needed below because it was merged.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

;)


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