- 
                Notifications
    
You must be signed in to change notification settings  - Fork 13.9k
 
Closed
Labels
I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
Description
The TypeID of Box<Fn() -> ()> seems to be inconsistent across crates in both nightly and stable, I found a similar closed issue from a couple years ago and wasn't sure whether I should comment on that or file a new bug. I can recreate it consistently as follows:
typeid_issue/lib.rs:
pub fn check() {
    println!("{:?}", std::any::TypeId::of::<Box<Fn() -> ()>>());
}typeid_issue/examples/example.rs:
extern crate typeid_issue;
fn main() {
    println!("{:?}", std::any::TypeId::of::<Box<Fn() -> ()>>());
    typeid_issue::check();
}On my machine, cargo run --example example with the above project outputs two different TypeIds. The same thing doesn't happen for all types, e.g. Box<i32>s seem to work fine, and Box<Fn() -> ()> wrapped in a struct seems to work fine giving me a nice work around for now.
Metadata
Metadata
Assignees
Labels
I-unsoundIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/SoundnessIssue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness