Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
kemurphy opened this issue Jan 8, 2015 · 3 comments
Closed

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

kemurphy opened this issue Jan 8, 2015 · 3 comments
Labels
A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@kemurphy
Copy link
Contributor

kemurphy commented Jan 8, 2015

#![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

@kemurphy kemurphy changed the title Coherence fails to find ambiguity with manual impl of Fn Coherence fails to find ambiguity with manual impl of Fn for fn Jan 8, 2015
@jdm jdm added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Jan 8, 2015
@Gankra Gankra added the A-type-system Area: Type system label Jan 21, 2015
@ghost ghost added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label Apr 3, 2015
@frewsxcv
Copy link
Member

This doesn't cause an ICE on 1.0.0 (though it doesn't compile either). So this either needs a regression test or the original example needs to be updated to reexpose the ICE.

@arielb1
Copy link
Contributor

arielb1 commented Jun 25, 2015

This impl fails orphan-checking now - never gets to coherence checking.

@steveklabnik
Copy link
Member

Given that this fails in a different way now, I'm going to just give it a close.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

6 participants