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

Unexpected region for local data ReStatic #49579

Closed
leonardo-m opened this issue Apr 2, 2018 · 6 comments
Closed

Unexpected region for local data ReStatic #49579

leonardo-m opened this issue Apr 2, 2018 · 6 comments
Labels
A-NLL Area: Non-lexical lifetimes (NLL) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. NLL-complete Working towards the "valid code works" goal T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@leonardo-m
Copy link

#![feature(nll)]

fn fibs(n: u32) -> impl Iterator<Item=u128> {
    (0 .. n)
    .scan((0, 1), |st, _| {
        *st = (st.1, st.0 + st.1);
        Some(*st)
    })
    .map(&|(f, _)| f)
}

fn main() {
    println!("{:?}", fibs(10).collect::<Vec<_>>());
}
error: internal compiler error: unexpected region for local data ReStatic
 --> ...\test.rs:9:11
  |
9 |     .map(&|(f, _)| f)
  |           ^^^^^^^^^^

error: aborting due to previous error
rustc 1.26.0-nightly (06fa27d7c 2018-04-01)
binary: rustc
commit-hash: 06fa27d7c84a21af8449e06f3c50b243c4d5a7ad
commit-date: 2018-04-01
host: x86_64-pc-windows-gnu
release: 1.26.0-nightly
LLVM version: 6.0
@XAMPPRocky XAMPPRocky added I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ T-lang Relevant to the language team, which will review and decide on the PR/issue. A-NLL Area: Non-lexical lifetimes (NLL) C-bug Category: This is a bug. labels Jun 29, 2018
@nikomatsakis nikomatsakis added this to the Rust 2018 Preview 2 milestone Jul 3, 2018
@nikomatsakis
Copy link
Contributor

Still an ICE. Adding as Preview 2 but I'm not sure the cause yet.

@matthewjasper
Copy link
Contributor

Successfully compiles now that we don't run AST borrowck when we don't need to.

This code compiles because the closure is promoted to a static, is this something that we want to be visible to the user?

@matthewjasper matthewjasper added E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. and removed C-bug Category: This is a bug. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jul 8, 2018
@nikomatsakis
Copy link
Contributor

I see, I see. Yes, that is expected to be exposed to the user.

@nikomatsakis
Copy link
Contributor

I guess we can close this then as Working as Expected. Nice job @spastorino, you get the credit for fixing this one :)

@nikomatsakis
Copy link
Contributor

Er, I'll leave open because (as @matthewjasper noted) we still need a test

@pnkfelix pnkfelix added the NLL-complete Working towards the "valid code works" goal label Jul 24, 2018
davidtwco added a commit to davidtwco/rust that referenced this issue Jul 28, 2018
@davidtwco
Copy link
Member

Submitted #52809 with the test that is remaining for this issue.

pietroalbini added a commit to pietroalbini/rust that referenced this issue Aug 1, 2018
Add test for unexpected region for local data ReStatic

Fixes rust-lang#49579.

r? @pnkfelix @nikomatsakis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-NLL Area: Non-lexical lifetimes (NLL) E-needs-test Call for participation: An issue has been fixed and does not reproduce, but no test has been added. NLL-complete Working towards the "valid code works" goal T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

6 participants