Skip to content

illegal recursive type check is excessively strict on associated types #17744

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sp3d opened this issue Oct 3, 2014 · 1 comment
Closed

illegal recursive type check is excessively strict on associated types #17744

sp3d opened this issue Oct 3, 2014 · 1 comment
Labels
A-type-system Area: Type system

Comments

@sp3d
Copy link
Contributor

sp3d commented Oct 3, 2014

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).

@kmcallister kmcallister added the A-type-system Area: Type system label Oct 4, 2014
@sp3d
Copy link
Contributor Author

sp3d commented Jan 9, 2015

This works now.

@sp3d sp3d closed this as completed Jan 9, 2015
RalfJung pushed a commit to RalfJung/rust that referenced this issue Aug 1, 2024
minor: Set tracing level to debug when `cargo config get env` fails

fixes rust-lang#17739
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-type-system Area: Type system
Projects
None yet
Development

No branches or pull requests

2 participants