Skip to content

Commit 690e037

Browse files
committed
add a test for gate impl_trait_in_fn_trait_return
1 parent d116859 commit 690e037

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn f() -> impl Fn() -> impl Sized { || () }
2+
//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
3+
fn g() -> &'static dyn Fn() -> impl Sized { &|| () }
4+
//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
5+
6+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
2+
--> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:1:24
3+
|
4+
LL | fn f() -> impl Fn() -> impl Sized { || () }
5+
| ^^^^^^^^^^
6+
7+
error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return
8+
--> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:3:32
9+
|
10+
LL | fn g() -> &'static dyn Fn() -> impl Sized { &|| () }
11+
| ^^^^^^^^^^
12+
13+
error: aborting due to 2 previous errors
14+
15+
For more information about this error, try `rustc --explain E0562`.

0 commit comments

Comments
 (0)