Skip to content

Coherence fails to find ambiguity with manual impl of Fn for fn #20767

Closed
@kemurphy

Description

@kemurphy
#![feature(unboxed_closures)]

use std::ops::Fn;

struct Foo(u32);

impl Fn(u32) -> Foo for fn(u32) -> Foo {
    extern "rust-call" fn call(&self, args: (u32,)) -> Foo { let (u,) = args; self(u) }
}

fn main() {
    let x = Foo.call((42,));
    println!("{}", x);
}
<anon>:7:1: 9:2 error: internal compiler error: coherence failed to report ambiguity: cannot locate the impl of the trait `core::ops::Fn(u32) -> Foo` for the type `fn(u32) -> Foo`
<anon>:7 impl Fn(u32) -> Foo for fn(u32) -> Foo {
<anon>:8     extern "rust-call" fn call(&self, args: (u32,)) -> Foo { let (u,) = args; self(u) }
<anon>:9 }
note: the compiler unexpectedly panicked. this is a bug.
note: we would appreciate a bug report: http://doc.rust-lang.org/complement-bugreport.html
note: run with `RUST_BACKTRACE=1` for a backtrace
thread 'rustc' panicked at 'Box<Any>', /build/rust-git/src/rust/src/libsyntax/diagnostic.rs:123

http://is.gd/3cBkbL

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-type-systemArea: Type systemE-needs-testCall for participation: An issue has been fixed and does not reproduce, but no test has been added.I-ICEIssue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions