File tree Expand file tree Collapse file tree 1 file changed +6
-12
lines changed
src/librustc_error_codes/error_codes Expand file tree Collapse file tree 1 file changed +6
-12
lines changed Original file line number Diff line number Diff line change 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
33Erroneous code examples:
44
55``` compile_fail,E0759
66use 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```
You can’t perform that action at this time.
0 commit comments