mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-24 15:54:15 +00:00
Add even more tests for impl Fn() -> impl Trait
This commit is contained in:
parent
7a4ba2ffde
commit
00f22771f6
@ -10,4 +10,14 @@ fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
|
||||
|x| x
|
||||
}
|
||||
|
||||
fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
|
||||
//~^ ERROR higher kinded lifetime bounds on nested opaque types are not supported yet
|
||||
|x| x
|
||||
}
|
||||
|
||||
fn d() -> impl Fn() -> (impl Debug + '_) {
|
||||
//~^ ERROR missing lifetime specifier
|
||||
|| ()
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -22,5 +22,35 @@ note: lifetime declared here
|
||||
LL | fn b() -> impl for<'a> Fn(&'a u8) -> (impl Debug + 'a) {
|
||||
| ^^
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
error: higher kinded lifetime bounds on nested opaque types are not supported yet
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:13:52
|
||||
|
|
||||
LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
|
||||
| ^^
|
||||
|
|
||||
note: lifetime declared here
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:13:20
|
||||
|
|
||||
LL | fn c() -> impl for<'a> Fn(&'a u8) -> (impl Debug + '_) {
|
||||
| ^^
|
||||
|
||||
error[E0106]: missing lifetime specifier
|
||||
--> $DIR/impl-fn-hrtb-bounds.rs:18:38
|
||||
|
|
||||
LL | fn d() -> impl Fn() -> (impl Debug + '_) {
|
||||
| ^^ expected named lifetime parameter
|
||||
|
|
||||
= help: this function's return type contains a borrowed value, but there is no value for it to be borrowed from
|
||||
= note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html
|
||||
help: consider making the bound lifetime-generic with a new `'a` lifetime
|
||||
|
|
||||
LL | fn d() -> impl for<'a> Fn() -> (impl Debug + 'a) {
|
||||
| +++++++ ~~
|
||||
help: consider using the `'static` lifetime
|
||||
|
|
||||
LL | fn d() -> impl Fn() -> (impl Debug + 'static) {
|
||||
| ~~~~~~~
|
||||
|
||||
error: aborting due to 4 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0106`.
|
||||
|
12
src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs
Normal file
12
src/test/ui/impl-trait/impl-fn-predefined-lifetimes.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// check-pass
|
||||
use std::fmt::Debug;
|
||||
|
||||
fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) {
|
||||
|x| x
|
||||
}
|
||||
|
||||
fn _b<'a>() -> impl Fn(&'a u8) -> (impl Debug + 'a) {
|
||||
a()
|
||||
}
|
||||
|
||||
fn main() {}
|
Loading…
Reference in New Issue
Block a user