-
Notifications
You must be signed in to change notification settings - Fork 13.3k
"parameter T
is never used" with recursive type
#26283
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
Comments
These are called "non-regular ADT-s" and are not supported (you should get an overflow complaint). We shouldn't stack-overflow through. |
Your second example somehow survived type checking wow (you really shouldn't have gone that far). I guess we stopped using type_contents for pretty much anything. I think we should add an actual check for this somewhere (althrough it won't prevent examples using associated types, which can strike in trans, but we should have a limit for that). |
Triage: no change |
Triage: Examples 2 now compiles, but if you try to use |
Triage: no change from latest check |
Rollup merge of rust-lang#127871 - compiler-errors:recursive, r=estebank Mention that type parameters are used recursively on bivariance error Right now when a type parameter is used recursively, even with indirection (so it has a finite size) we say that the type parameter is unused: ``` struct B<T>(Box<B<T>>); ``` This is confusing, because the type parameter is *used*, it just doesn't have its variance constrained. This PR tweaks that message to mention that it must be used *non-recursively*. Not sure if we should actually mention "variance" here, but also I'd somewhat prefer we don't keep the power users in the dark w.r.t the real underlying issue, which is that the variance isn't constrained. That technical detail is reserved for a note, though. cc `@fee1-dead` Fixes rust-lang#118976 Fixes rust-lang#26283 Fixes rust-lang#53191 Fixes rust-lang#105740 Fixes rust-lang#110466
Testcase:
Gives:
Not sure if this is really something rustc should actually support (I imagine trying to prove recursive properties about it is extremely awkward), but the error message makes no sense.
More related testcases:
The text was updated successfully, but these errors were encountered: