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
Closed

Unique function types are not unique enough #23733

petrochenkov opened this issue Mar 26, 2015 · 2 comments
Labels
A-trait-system Area: Trait system A-type-system Area: Type system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@petrochenkov
Copy link
Contributor

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
Copy link
Contributor Author

Related to #19925

@steveklabnik steveklabnik added A-type-system Area: Type system A-trait-system Area: Trait system labels Mar 27, 2015
@huonw huonw added I-nominated T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jan 8, 2016
@nikomatsakis
Copy link
Contributor

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
Labels
A-trait-system Area: Trait system A-type-system Area: Type system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

4 participants