Closed
Description
To me it looks like all the function signatures try to produce Dfs<G::NodeId, G::Map>
, but rustc thinks I produce Dfs<G::Map, G::Map>
and throws a type error. (The associated types are part of different traits, that inherit.)
rustc version: rustc 1.0.0-nightly (4db0b3246 2015-02-25) (built 2015-02-26)
Testcase, derived from this repo.
pub trait Graphlike {
type NodeId;
}
pub trait Visitable : Graphlike {
type Map;
}
pub struct Dfs<N, VM> {
pub stack: Vec<N>,
pub discovered: VM,
}
impl<G> Dfs<G::NodeId, G::Map> where G: Visitable
{
pub fn new(graph: &G, _start: G::NodeId) -> Self
{
panic!()
}
}
pub fn new<G>(graph: &G, start: G::NodeId) where G: Visitable
{
let dfs: Dfs<G::NodeId, G::Map> = Dfs::new(graph, start);
// ^ERROR:
// error: mismatched types:
// expected `Dfs<<G as Graphlike>::NodeId, <G as Visitable>::Map>`,
// found `Dfs<<G as Visitable>::Map, <G as Visitable>::Map>`
}