Skip to content

Commit d116859

Browse files
committed
--bless
1 parent cc752f5 commit d116859

13 files changed

+106
-89
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
#![feature(impl_trait_in_fn_trait_return)]
12
use std::fmt::Debug;
23

34
fn a() -> impl Fn(&u8) -> impl Debug {
4-
|x| x //~ ERROR lifetime may not live long enough
5+
|x| x //~ ERROR hidden type for `impl Debug` captures lifetime that does not appear in bounds
56
}
67

78
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
error: lifetime may not live long enough
2-
--> $DIR/impl-fn-hrtb-bounds-2.rs:4:9
1+
error[E0700]: hidden type for `impl Debug` captures lifetime that does not appear in bounds
2+
--> $DIR/impl-fn-hrtb-bounds-2.rs:5:9
33
|
44
LL | |x| x
5-
| -- ^ returning this value requires that `'1` must outlive `'2`
6-
| ||
7-
| |return type of closure is &'2 u8
8-
| has type `&'1 u8`
5+
| --- ^
6+
| |
7+
| hidden type `&u8` captures the anonymous lifetime #1 defined here
98

109
error: aborting due to previous error
1110

11+
For more information about this error, try `rustc --explain E0700`.

src/test/ui/impl-trait/impl-fn-hrtb-bounds.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(impl_trait_in_fn_trait_return)]
12
use std::fmt::Debug;
23

34
fn a() -> impl Fn(&u8) -> (impl Debug + '_) {
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,51 @@
1+
error[E0106]: missing lifetime specifier
2+
--> $DIR/impl-fn-hrtb-bounds.rs:19:38
3+
|
4+
LL | fn d() -> impl Fn() -> (impl Debug + '_) {
5+
| ^^ expected named lifetime parameter
6+
|
7+
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
8+
help: consider using the `'static` lifetime
9+
|
10+
LL | fn d() -> impl Fn() -> (impl Debug + 'static) {
11+
| ~~~~~~~
12+
113
error: higher kinded lifetime bounds on nested opaque types are not supported yet
2-
--> $DIR/impl-fn-hrtb-bounds.rs:3:41
14+
--> $DIR/impl-fn-hrtb-bounds.rs:4:41
315
|
416
LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) {
517
| ^^
618
|
719
note: lifetime declared here
8-
--> $DIR/impl-fn-hrtb-bounds.rs:3:19
20+
--> $DIR/impl-fn-hrtb-bounds.rs:4:19
921
|
1022
LL | fn a() -> impl Fn(&u8) -> (impl Debug + '_) {
1123
| ^
1224

1325
error: higher kinded lifetime bounds on nested opaque types are not supported yet
14-
--> $DIR/impl-fn-hrtb-bounds.rs:8:52
26+
--> $DIR/impl-fn-hrtb-bounds.rs:9:52
1527
|
1628
LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
1729
| ^^
1830
|
1931
note: lifetime declared here
20-
--> $DIR/impl-fn-hrtb-bounds.rs:8:20
32+
--> $DIR/impl-fn-hrtb-bounds.rs:9:20
2133
|
2234
LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
2335
| ^^
2436

2537
error: higher kinded lifetime bounds on nested opaque types are not supported yet
26-
--> $DIR/impl-fn-hrtb-bounds.rs:13:52
38+
--> $DIR/impl-fn-hrtb-bounds.rs:14:52
2739
|
2840
LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
2941
| ^^
3042
|
3143
note: lifetime declared here
32-
--> $DIR/impl-fn-hrtb-bounds.rs:13:20
44+
--> $DIR/impl-fn-hrtb-bounds.rs:14:20
3345
|
3446
LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
3547
| ^^
3648

37-
error[E0106]: missing lifetime specifier
38-
--> $DIR/impl-fn-hrtb-bounds.rs:18:38
39-
|
40-
LL | fn d() -> impl Fn() -> (impl Debug + '_) {
41-
| ^^ expected named lifetime parameter
42-
|
43-
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
44-
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
45-
help: consider making the bound lifetime-generic with a new `'a` lifetime
46-
|
47-
LL | fn d() -> impl for<'a> Fn() -> (impl Debug + 'a) {
48-
| +++++++ ~~
49-
help: consider using the `'static` lifetime
50-
|
51-
LL | fn d() -> impl Fn() -> (impl Debug + 'static) {
52-
| ~~~~~~~
53-
5449
error: aborting due to 4 previous errors
5550

5651
For more information about this error, try `rustc --explain E0106`.

src/test/ui/impl-trait/impl-fn-parsing-ambiguities.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(impl_trait_in_fn_trait_return)]
12
use std::fmt::Debug;
23

34
fn a() -> impl Fn(&u8) -> impl Debug + '_ {

src/test/ui/impl-trait/impl-fn-parsing-ambiguities.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
error: ambiguous `+` in a type
2-
--> $DIR/impl-fn-parsing-ambiguities.rs:3:27
2+
--> $DIR/impl-fn-parsing-ambiguities.rs:4:27
33
|
44
LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ {
55
| ^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + '_)`
66

77
error: ambiguous `+` in a type
8-
--> $DIR/impl-fn-parsing-ambiguities.rs:9:24
8+
--> $DIR/impl-fn-parsing-ambiguities.rs:10:24
99
|
1010
LL | fn b() -> impl Fn() -> impl Debug + Send {
1111
| ^^^^^^^^^^^^^^^^^ help: use parentheses to disambiguate: `(impl Debug + Send)`
1212

1313
error: higher kinded lifetime bounds on nested opaque types are not supported yet
14-
--> $DIR/impl-fn-parsing-ambiguities.rs:3:40
14+
--> $DIR/impl-fn-parsing-ambiguities.rs:4:40
1515
|
1616
LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ {
1717
| ^^
1818
|
1919
note: lifetime declared here
20-
--> $DIR/impl-fn-parsing-ambiguities.rs:3:19
20+
--> $DIR/impl-fn-parsing-ambiguities.rs:4:19
2121
|
2222
LL | fn a() -> impl Fn(&u8) -> impl Debug + '_ {
2323
| ^

src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
// check-pass
1+
#![feature(impl_trait_in_fn_trait_return)]
22
use std::fmt::Debug;
33

44
fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
5+
//~^ ERROR hidden type for `impl Debug` captures lifetime that does not appear in bounds
56
|x| x
67
}
78

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0700]: hidden type for `impl Debug` captures lifetime that does not appear in bounds
2+
--> $DIR/impl-fn-predefined-lifetimes.rs:4:35
3+
|
4+
LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
5+
| ^^^^^^^^^^^^^^^
6+
|
7+
note: hidden type `&'<empty> u8` captures lifetime smaller than the function body
8+
--> $DIR/impl-fn-predefined-lifetimes.rs:4:35
9+
|
10+
LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
11+
| ^^^^^^^^^^^^^^^
12+
13+
error: aborting due to previous error
14+
15+
For more information about this error, try `rustc --explain E0700`.

src/test/ui/impl-trait/impl_fn_associativity.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// run-pass
2+
#![feature(impl_trait_in_fn_trait_return)]
23
use std::fmt::Debug;
34

45
fn f_debug() -> impl Fn() -> impl Debug {

src/test/ui/impl-trait/nested_impl_trait.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![feature(impl_trait_in_fn_trait_return)]
12
use std::fmt::Debug;
23

34
fn fine(x: impl Into<u32>) -> impl Into<u32> { x }

src/test/ui/impl-trait/nested_impl_trait.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0666]: nested `impl Trait` is not allowed
2-
--> $DIR/nested_impl_trait.rs:5:56
2+
--> $DIR/nested_impl_trait.rs:6:56
33
|
44
LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
55
| ----------^^^^^^^^^^-
@@ -8,7 +8,7 @@ LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
88
| outer `impl Trait`
99

1010
error[E0666]: nested `impl Trait` is not allowed
11-
--> $DIR/nested_impl_trait.rs:9:42
11+
--> $DIR/nested_impl_trait.rs:10:42
1212
|
1313
LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {}
1414
| ----------^^^^^^^^^^-
@@ -17,7 +17,7 @@ LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {}
1717
| outer `impl Trait`
1818

1919
error[E0666]: nested `impl Trait` is not allowed
20-
--> $DIR/nested_impl_trait.rs:13:37
20+
--> $DIR/nested_impl_trait.rs:14:37
2121
|
2222
LL | fn bad_in_arg_position(_: impl Into<impl Debug>) { }
2323
| ----------^^^^^^^^^^-
@@ -26,7 +26,7 @@ LL | fn bad_in_arg_position(_: impl Into<impl Debug>) { }
2626
| outer `impl Trait`
2727

2828
error[E0666]: nested `impl Trait` is not allowed
29-
--> $DIR/nested_impl_trait.rs:18:44
29+
--> $DIR/nested_impl_trait.rs:19:44
3030
|
3131
LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
3232
| ----------^^^^^^^^^^-
@@ -35,13 +35,13 @@ LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
3535
| outer `impl Trait`
3636

3737
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return
38-
--> $DIR/nested_impl_trait.rs:9:32
38+
--> $DIR/nested_impl_trait.rs:10:32
3939
|
4040
LL | fn bad_in_fn_syntax(x: fn() -> impl Into<impl Debug>) {}
4141
| ^^^^^^^^^^^^^^^^^^^^^
4242

4343
error[E0277]: the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied
44-
--> $DIR/nested_impl_trait.rs:5:46
44+
--> $DIR/nested_impl_trait.rs:6:46
4545
|
4646
LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
4747
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Debug`
@@ -50,7 +50,7 @@ LL | fn bad_in_ret_position(x: impl Into<u32>) -> impl Into<impl Debug> { x }
5050
= note: required for `impl Into<u32>` to implement `Into<impl Debug>`
5151

5252
error[E0277]: the trait bound `impl Debug: From<impl Into<u32>>` is not satisfied
53-
--> $DIR/nested_impl_trait.rs:18:34
53+
--> $DIR/nested_impl_trait.rs:19:34
5454
|
5555
LL | fn bad(x: impl Into<u32>) -> impl Into<impl Debug> { x }
5656
| ^^^^^^^^^^^^^^^^^^^^^ the trait `From<impl Into<u32>>` is not implemented for `impl Debug`

src/test/ui/impl-trait/where-allowed.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
//! A simple test for testing many permutations of allowedness of
22
//! impl Trait
3+
#![feature(impl_trait_in_fn_trait_return)]
34
use std::fmt::Debug;
45

56
// Allowed

0 commit comments

Comments
 (0)