-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Closed
Labels
A-trait-systemArea: Trait systemArea: Trait systemA-type-systemArea: Type systemArea: Type systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
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.
Metadata
Metadata
Assignees
Labels
A-trait-systemArea: Trait systemArea: Trait systemA-type-systemArea: Type systemArea: Type systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.