Skip to content
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

ICE with lifetime-generic type alias impl trait #70121

Closed
jonas-schievink opened this issue Mar 18, 2020 · 2 comments · Fixed by #72572
Closed

ICE with lifetime-generic type alias impl trait #70121

jonas-schievink opened this issue Mar 18, 2020 · 2 comments · Fixed by #72572
Labels
A-associated-items Area: Associated items (types, constants & functions) A-lifetimes Area: Lifetimes / regions A-traits Area: Trait system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jonas-schievink
Copy link
Contributor

#![feature(type_alias_impl_trait)]

pub type Successors<'a> = impl Iterator<Item = &'a ()>;

pub fn f<'a>() -> Successors<'a> {
    None.into_iter()
}

trait Tr {
    type Item;
}

impl<'a> Tr for &'a () {
    type Item = Successors<'a>;
}

fn ohno<'a>() -> <&'a () as Tr>::Item {
    None.into_iter()
}

gives:

error: internal compiler error: free_scope: DefId(0:3 ~ playground[ad24]::Successors[0]) not recognized by the region scope tree for None / Some(DefId(0:13 ~ playground[ad24]::ohno[0]))

My guess is that this has the same underlying cause as #56445, but this one doesn't involve associated consts or arrays at all, so it might be different still.

@jonas-schievink jonas-schievink added A-lifetimes Area: Lifetimes / regions I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` requires-nightly This issue requires a nightly compiler in some way. labels Mar 18, 2020
@Centril Centril added A-associated-items Area: Associated items (types, constants & functions) A-traits Area: Trait system P-medium Medium priority labels Mar 19, 2020
@Aaron1011
Copy link
Member

This appears to be due to a bad interaction between #66178 and associated type projections involving lifetimes.

When we normalize the function signature during type-checking, we project <&'a () as Tr>::Item to Successors<'_#0r>. We then convert '_#0r back to the 'generic' region for Successors, which is 'a.

However, this 'a is a distinct early bound region, different from the 'a in fn ohno<'a>() (changing the regions to not all be called 'a in the example makes this clearer). This causes issues during lexical_region_resolve, since we've essentially pulled a region out of thin air.

This issue doesn't seem to come up for type parameters (playground with lifetimes replaced with types). I'm not sure if this is because our handling of type parameters is correct for this kind of projection, or if we need a more complicated example to break things.

@JohnTitor
Copy link
Member

The ICE no longer happens with the latest nightly (note that the playground's nightly isn't the latest). That delay_span_bug was removed by #72362. Marked as E-needs-test.

@JohnTitor JohnTitor added the E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. label May 25, 2020
JohnTitor added a commit to JohnTitor/rust that referenced this issue May 26, 2020
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this issue May 29, 2020
@bors bors closed this as completed in 89cb4d7 May 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-associated-items Area: Associated items (types, constants & functions) A-lifetimes Area: Lifetimes / regions A-traits Area: Trait system C-bug Category: This is a bug. E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. F-type_alias_impl_trait `#[feature(type_alias_impl_trait)]` glacier ICE tracked in rust-lang/glacier. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ P-medium Medium priority requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Development

Successfully merging a pull request may close this issue.

5 participants