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

ices/81403.sh: fixed with errors #931

Closed
wants to merge 1 commit into from

Conversation

github-actions[bot]
Copy link
Contributor

Issue: rust-lang/rust#81403

#!/bin/bash

rustc --emit=mir -Zmir-opt-level=3 - <<'EOF'
// build-pass
pub trait Foo<'a> {
    type Bar;
    fn foo(&'a self) -> Self::Bar;
}

impl<'a, 'b, T: 'a> Foo<'a> for &'b T {
    type Bar = &'a T;
    fn foo(&'a self) -> &'a T {
        self
    }
}

pub fn uncallable<T, F>(x: T, f: F)
    where T: for<'a> Foo<'a>,
          F: for<'a> Fn(<T as Foo<'a>>::Bar)
{
    f(x.foo());
}

pub fn broken<F: Fn(&i32)>(x: &i32, f: F) {
    uncallable(x, |y| f(y));
}

fn main() { }
EOF
=== stdout ===
=== stderr ===
error[E0631]: type mismatch in closure arguments
  --> <anon>:22:5
   |
22 |     uncallable(x, |y| f(y));
   |     ^^^^^^^^^^    -------- found signature of `for<'r> fn(&'r i32) -> _`
   |     |
   |     expected signature of `for<'a> fn(<&i32 as Foo<'a>>::Bar) -> _`
   |
note: required by a bound in `uncallable`
  --> <anon>:16:14
   |
14 | pub fn uncallable<T, F>(x: T, f: F)
   |        ---------- required by a bound in this
15 |     where T: for<'a> Foo<'a>,
16 |           F: for<'a> Fn(<T as Foo<'a>>::Bar)
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `uncallable`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0631`.
==============

=== stdout ===
=== stderr ===
error[E0631]: type mismatch in closure arguments
  --> <anon>:22:5
   |
22 |     uncallable(x, |y| f(y));
   |     ^^^^^^^^^^    -------- found signature of `for<'r> fn(&'r i32) -> _`
   |     |
   |     expected signature of `for<'a> fn(<&i32 as Foo<'a>>::Bar) -> _`
   |
note: required by a bound in `uncallable`
  --> <anon>:16:14
   |
14 | pub fn uncallable<T, F>(x: T, f: F)
   |        ---------- required by a bound in this
15 |     where T: for<'a> Foo<'a>,
16 |           F: for<'a> Fn(<T as Foo<'a>>::Bar)
   |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `uncallable`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0631`.
==============
@Alexendoo
Copy link
Member

c74d29e

@Alexendoo Alexendoo closed this Aug 26, 2021
@Alexendoo Alexendoo deleted the autofix/ices/81403.sh branch August 29, 2021 12:49
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.

2 participants