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

Unique function types are not unique enough #23733

Closed
petrochenkov opened this Issue Mar 26, 2015 · 2 comments

Comments

Projects
None yet
4 participants
@petrochenkov
Copy link
Contributor

petrochenkov commented Mar 26, 2015

In this example

trait Check: std::marker::MarkerTrait {
    fn check();
}
impl Check for u8 {
    fn check() { println!("u8"); }
}
impl Check for u16 {
    fn check() { println!("u16"); }
}

fn f<T: Check>() {
    T::check();
}



fn main() {
    fn same_type<T>(_: T, _: T) {}
    same_type(f::<u8>, f::<u16>);
    println!("{} {}", f::<u8> as usize, f::<u16> as usize);
}

functions f::<u8> and f::<u16> have the same type fn() {f} tied to the id of the generic function item, but different function pointers. So, in general case a function pointer can't be unambiguosly obtained from function item's type.

cc @nikomatsakis

@petrochenkov

This comment has been minimized.

Copy link
Contributor Author

petrochenkov commented Mar 26, 2015

Related to #19925

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Jan 14, 2016

Duplicate of #19925 basically, which is already P-high (but hasn't happened...sadly).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.