-
Notifications
You must be signed in to change notification settings - Fork 13.3k
error: internal compiler error: src/librustc/ty/subst.rs:611: type parameter B/#2
(B/2) out of range when substituting (root type=Some((B,))) substs=[ReEarlyBound(0, 'a)]
#67844
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
Minimized: type Curried<A> = impl std::ops::Deref<Target = impl FnOnce(A)>;
fn curry() -> Curried<()> {
Box::new(drop)
}
fn main() {} |
Ah, neat, so it has nothing to do with closures or Fn traits. //#![feature(type_alias_impl_trait)]
trait WithAssoc { type AssocType; }
trait WithParam<A> {}
type Return<A> = impl WithAssoc<AssocType = impl WithParam<A>>;
fn my_fun() -> Return<()> {}
fn main() {} |
T-compiler triage: I'm going to assume from @matthewjasper 's self-assignment that this does not require discussion at T-compiler meeting. Removing I-nominated label. |
Are nested type-alias-impl-traits even allowed by the RFC? If not, we should check and emit an error we we construct the type. |
They are |
…atthewjasper Properly use parent generics for opaque types Fixes rust-lang#67844 Previously, opaque types would only get parent generics if they a return-position-impl-trait (e.g. `fn foo<A>() -> impl MyTrait<A>`). However, it's possible for opaque types to be nested inside one another: ```rust trait WithAssoc { type AssocType; } trait WithParam<A> {} type Return<A> = impl WithAssoc<AssocType = impl WithParam<A>>; ``` When this occurs, we need to ensure that the nested opaque types properly inherit generic parameters from their parent opaque type. This commit fixes the `generics_of` query to take the parent item into account when determining the generics for an opaque type.
@Aaron1011 any ideas how I can get my original example running though? fn curry<'a, A: 'a, B, C, F: Fn(A, B) -> C> (f: &'a F)
-> impl Fn<(A,), Output = impl FnOnce(B) -> C + 'a> + 'a
{
move |a| move |b| f(a,b)
} and wanted to give a name to its return type. type Curried<'a, A: 'a, B, C, F: Fn(A, B) -> C>
= impl Fn<(A,), Output = impl FnOnce(B) -> C + 'a> + 'a;
fn curry<'a, A: 'a, B, C, F: Fn(A, B) -> C> (f: &'a F)
-> Curried<'a, A, B, C, F>
{
move |a| move |b| f(a,b)
} But the compiler is still unhappy with lifetimes currently, after your fix. I'm getting the following.
At least it works without the lifetimes (i.e. after removing parametrization over 'a and replacing all occurrences of 'a with 'static). |
@Aaron1011 #![feature(type_alias_impl_trait)]
trait SomeTrait where {}
trait WithAssoc<A> where {
type AssocType;
}
type Return<A> // 'a is not in scope
= impl WithAssoc<A, AssocType = impl SomeTrait + 'a>;
fn my_fun() -> Return<()> {}
fn main() {} which didn't panic on the latest nightly (2020-02-13). Message is:
|
@steffahn: Can you open separate issues for each of those problems? |
@Aaron1011 Okay, done ^^ (#69136, #69137) |
Uncommenting the features and running in Nightly makes the complaints about unstable features go away while the panick stays.
I’m not sure yet how to make a smaller example out of this.smaller examples in comments belowThis code was a step of me trying out if I could turn this working code (link) into a trait to get method syntax.
(Playground)
Errors:
The text was updated successfully, but these errors were encountered: