-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Support builtin bounds on associated types and make them Sized by default #17921
Comments
Nominating. Associated types are planned to be un-feature-gated by 1.0, and this change is not backwards-compatible. Assuming that we keep our current rules/syntax for generics and unsized types, I think we need to take both of the suggestions in this issue to ensure consistency with the rest of the language. |
Agreed on both suggestions. |
Assigning P-backcompat-lang, 1.0. |
I'm sort of working on this |
I updated the title to reflect the full work involved in this issue. I am targeting this as supporting builtin bounds like |
fix: Panic when a TAIT exists in a RPIT Fixes rust-lang#17921 When there is a TAIT inside of a RPIT like; ```rust trait Foo {} type Bar = impl Foo; fn foo<A>() -> impl Future<Output = Bar> { .. } ``` while inferencing `fn foo`, `insert_inference_vars_for_impl_trait` tries to substitute impl trait bounds of `Bar`, i.e. `Implemented(Foo)` with RPITs `placeholders`, and this causes panic https://github.com/rust-lang/rust-analyzer/blob/fa003262474185fd62168379500fe906b331824b/crates/hir-ty/src/infer.rs#L903-L905
(Moved from http://discuss.rust-lang.org/t/make-associated-types-sized-by-default/615)
Currently this program:
Fails to compile as:
According to RFC 59 we should be able to fix it by (currently unimplemented)
But,
Shouldn't associated types be Sized by default? As associated types are to be used to replace "output" type parameters, it is more convenient to be Sized.
If associated types are Sized by default, what should be the syntax then if we want to allow unsized associated types? The generic spelling currently suggests something like
The text was updated successfully, but these errors were encountered: