Closed
Description
As far as I can tell, the purpose of the "illegal recursive type" error (in src/librustc/middle/typeck/astconv.rs) is to prevent types from referring to themselves in their definition, e.g. as done in src/test/compile-fail/infinite-vec-type-recursion.rs (type x = Vec<x>;
).
However, the logic being used to implement this check also disallows the following usage of associated types, which is intended to provide an implementation of the trait R
on Vec<T>
if T
itself implements R
(doing so by passing through T
's associated type assoc
):
trait R
{
type assoc;
}
impl<T: R> R for Vec<T>
{
type assoc=<T as R>::assoc;
//does work: type assoc=uint;
}
It seems like this code should be accepted (though type assoc=<Vec<T> as R>::assoc;
should still fail this check).