Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

ices/67830.rs: fixed with errors #1191

Closed
wants to merge 1 commit into from
Closed

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#67830

trait MyFn<Arg> {
    type Output;
    fn call(&self, arg: Arg) -> Self::Output;
}

struct Wrap<F>(F);

impl<A, B, F> MyFn<A> for Wrap<F>
where
    F: Fn(A) -> B
{
    type Output = B;

    fn call(&self, arg: A) -> Self::Output {
        (self.0)(arg)
    }
}


struct A;
fn test() -> impl for<'a> MyFn<&'a A, Output=impl Iterator + 'a> {
    Wrap(|a| Some(a).into_iter())
}

fn main() {}
=== stdout ===
=== stderr ===
error: implementation of `FnOnce` is not general enough
  --> /home/runner/work/glacier/glacier/ices/67830.rs:21:66
   |
21 |   fn test() -> impl for<'a> MyFn<&'a A, Output=impl Iterator + 'a> {
   |  __________________________________________________________________^
22 | |     Wrap(|a| Some(a).into_iter())
23 | | }
   | |_^ implementation of `FnOnce` is not general enough
   |
   = note: closure with signature `fn(&'2 A) -> std::option::IntoIter<&A>` must implement `FnOnce<(&'1 A,)>`, for any lifetime `'1`...
   = note: ...but it actually implements `FnOnce<(&'2 A,)>`, for some specific lifetime `'2`

error: aborting due to previous error

==============

=== stdout ===
=== stderr ===
error: implementation of `FnOnce` is not general enough
  --> /home/runner/work/glacier/glacier/ices/67830.rs:21:66
   |
21 |   fn test() -> impl for<'a> MyFn<&'a A, Output=impl Iterator + 'a> {
   |  __________________________________________________________________^
22 | |     Wrap(|a| Some(a).into_iter())
23 | | }
   | |_^ implementation of `FnOnce` is not general enough
   |
   = note: closure with signature `fn(&'2 A) -> std::option::IntoIter<&A>` must implement `FnOnce<(&'1 A,)>`, for any lifetime `'1`...
   = note: ...but it actually implements `FnOnce<(&'2 A,)>`, for some specific lifetime `'2`

error: aborting due to previous error

==============
@Alexendoo Alexendoo closed this in 1714f42 Mar 31, 2022
@Alexendoo Alexendoo deleted the autofix/ices/67830.rs branch March 31, 2022 21:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant