reem / rust-typemap

A typesafe store keyed by types and containing different types of values.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Unsoundness due to multidispatch

Ryman opened this issue · comments

The test below panics when added to the test suite, I think associated types are required.

I tried patching it up, but I couldn't figure out the syntax to add a static bound for the associated type (can't find any tests for it in rustc either).

#[test] fn test_entry_multi() {
    impl Assoc<u32> for Key {}

    let mut map = TypeMap::new();
    map.insert::<Key, Value>(Value);
    if let Occupied(_) = map.entry::<Key, u32>() {
        panic!("Unsound")
    }
}

Ya I've known this would be an issue for a while, but there's no way to add the 'static bound to an associated type yet, which is pretty frustrating.

Thanks for filing.