Skip to content

ICE when using a generator borrowing data with feature(nll) #47055

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

Closed
daboross opened this issue Dec 29, 2017 · 4 comments
Closed

ICE when using a generator borrowing data with feature(nll) #47055

daboross opened this issue Dec 29, 2017 · 4 comments
Labels
A-coroutines Area: Coroutines A-NLL Area: Non-lexical lifetimes (NLL) C-bug Category: This is a bug. 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.

Comments

@daboross
Copy link
Contributor

Hi! Ran into this earlier today when trying out #![feature(nll)] on a program which already uses generators.

Simplest test case:

#![crate_type = "lib"]
#![feature(conservative_impl_trait, generators, generator_trait, nll)]
use std::ops::Generator;

pub fn render<'a>(input: &'a str) -> impl Generator<Yield = (), Return = ()> + 'a {
    move || {
        let _t = input;
        yield ();
    }
}

Error:

error: internal compiler error: /checkout/src/librustc_mir/borrow_check/nll/universal_regions.rs:805: cannot convert `ReFree(DefId(0/0:252 ~ screeps_rs_ui[35dd]::rendering[0]::map_view[0]::render[0]), BrNamed(crate0:DefIndex(1:69), 'a))` to a region vid

note: the compiler unexpectedly panicked. this is a bug.

note: we would appreciate a bug report: https://github.com/rust-lang/rust/blob/master/CONTRIBUTING.md#bug-reports

note: rustc 1.24.0-nightly (77e189cd7 2017-12-28) running on x86_64-unknown-linux-gnu

Using rustc 1.24.0-nightly (77e189cd7 2017-12-28)

Reproduction on playpen: https://play.rust-lang.org/?gist=8973ce56db9aa1731173889ea012b8d9&version=nightly

@shepmaster shepmaster added A-coroutines Area: Coroutines A-NLL Area: Non-lexical lifetimes (NLL) C-bug Category: This is a bug. 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. WG-compiler-nll labels Jan 1, 2018
@nikomatsakis
Copy link
Contributor

Thanks =) Generators were not really tested, so I'm not too surprised.

@pnkfelix
Copy link
Member

pnkfelix commented Jan 9, 2018

I think we even observe this locally via the src/test/run-pass/generator/smoke.rs test, which for me yields the following under -Z nll:

error: internal compiler error: librustc_mir/borrow_check/nll/universal_regions.rs:805: cannot convert `ReScope(Node(ItemLocalId(16)))` to a region vid

@nikomatsakis
Copy link
Contributor

This works with #47353 I believe

@sapphire-arches
Copy link
Contributor

This is fixed in 2018-01-27 nightly and commit 7d6e5b9:

┌ 0 ─ bob_twinkles@cheesecake ─ ~/Code/rust/rust-issue-47055
└╼ 1 rust-issue-47055 >> rustup toolchain link issue-47055 ./build/x86_64-unknown-linux-gnu/stage2
┌ 0 ─ bob_twinkles@cheesecake ─ ~/Code/rust/rust-issue-47055
└╼ rust-issue-47055 >> rustup override set issue-47055
info: override toolchain for '/home/bob_twinkles/Code/rust/rust-issue-47055' set to 'issue-47055'
┌ 0 ─ bob_twinkles@cheesecake ─ ~/Code/rust/rust-issue-47055
└╼ rust-issue-47055 >> cat << EOF > test-code.rs
> #![crate_type = "lib"]
> #![feature(conservative_impl_trait, generators, generator_trait, nll)]
> use std::ops::Generator;
> 
> pub fn render<'a>(input: &'a str) -> impl Generator<Yield = (), Return = ()> + 'a {
>     move || {
>         let _t = input;
>         yield ();
>     }
> }
> EOF
┌ 0 ─ bob_twinkles@cheesecake ─ ~/Code/rust/rust-issue-47055
└╼ rust-issue-47055 >> rustc ./test-code.rs 
┌ 0 ─ bob_twinkles@cheesecake ─ ~/Code/rust/rust-issue-47055
└╼ rust-issue-47055 >> ls
build  libtest_code.rlib  test-code.rs
┌ 0 ─ bob_twinkles@cheesecake ─ ~/Code/rust/rust-issue-47055
└╼ rust-issue-47055 >> file libtest_code.rlib 
libtest_code.rlib: current ar archive

The smoke test mentioned by @pnkfelix builds and runs as well, so I'm going to close this. Thanks for the report @daboross!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-coroutines Area: Coroutines A-NLL Area: Non-lexical lifetimes (NLL) C-bug Category: This is a bug. 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.
Projects
None yet
Development

No branches or pull requests

5 participants