diff options
| author | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-07-29 02:28:36 +0400 |
|---|---|---|
| committer | Maybe Waffle <waffle.lapkin@gmail.com> | 2022-10-25 13:25:52 +0000 |
| commit | 690e0370081d39c2a4c459e5fd74a6e3728b73a9 (patch) | |
| tree | 0adb8eadeb83d90a1313f155577a32d74c0d573c | |
| parent | d116859ad78efa743726acd91d05d5a0bc64c0fe (diff) | |
| download | rust-690e0370081d39c2a4c459e5fd74a6e3728b73a9.tar.gz rust-690e0370081d39c2a4c459e5fd74a6e3728b73a9.zip | |
add a test for gate `impl_trait_in_fn_trait_return`
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs | 6 | ||||
| -rw-r--r-- | src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr | 15 |
2 files changed, 21 insertions, 0 deletions
diff --git a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs new file mode 100644 index 00000000000..0db8088f7ee --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.rs @@ -0,0 +1,6 @@ +fn f() -> impl Fn() -> impl Sized { || () } +//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return +fn g() -> &'static dyn Fn() -> impl Sized { &|| () } +//~^ ERROR `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + +fn main() {} diff --git a/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr new file mode 100644 index 00000000000..c485bc5c3ab --- /dev/null +++ b/src/test/ui/feature-gates/feature-gate-impl_trait_in_fn_trait_return.stderr @@ -0,0 +1,15 @@ +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:1:24 + | +LL | fn f() -> impl Fn() -> impl Sized { || () } + | ^^^^^^^^^^ + +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return + --> $DIR/feature-gate-impl_trait_in_fn_trait_return.rs:3:32 + | +LL | fn g() -> &'static dyn Fn() -> impl Sized { &|| () } + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0562`. |
