-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Unification fails when type alias impl trait is used in non-return position #64445
Comments
I'm going to say this is a bug... @cramertj confirm? |
I think the "defining uses" for TAIT are far too restrictive at the moment. I know that @alexreg was intending to look into similar issues. |
This is also becoming increasingly common for people writing their own |
Yes, the current set of defining uses is significantly reduced from what is allowed by the RFC. |
RFC 2071 specified that any unification site inside the module could count as a defining use. |
As long as each use uniquely defines the underlying type, it should be permitted as a defining use. That's as I understand the intention, and the one that makes the most sense (one that albeit might be trickier to implement in some cases). |
@varkor Yeah, it certainly will... I think I'm going to need some advice on how to implement it inside of bodies, in this case! |
We can start with the easier cases, and then slowly address the remaining cases. Let's get consts and statics working first. |
I think that the error I'm dealing with is also this. Example: #![feature(type_alias_impl_trait)]
use core::iter::Map;
trait Thing {
type Iter: Iterator<Item = u32>;
fn do_thing(val: u32) -> u32;
}
type DoThing<T: Thing> = impl FnOnce(u32) -> u32;
struct ThingIter<T: Thing> {
inner: Map<T::Iter, DoThing<T>>,
} |
This should not be permitted under |
This is supported since #94081 and we have tests for it |
The following code fails to compile, but I believe this should be a supported use-case under rust-lang/rfcs#2515 (and #63063):
with
This code on the other hand works just fine with the above
X
:Including both
Foo
andfoo
in the same file still produces the same error, sofoo
does not "help" identifyX
.The text was updated successfully, but these errors were encountered: