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

[NLL] ICE: unexpected region for local data with reference to closure #48697

Closed
matthewjasper opened this issue Mar 3, 2018 · 5 comments
Closed
Assignees
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-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@matthewjasper
Copy link
Contributor

The following code gives an internal compiler error. It is a normal compiler error without NLL.

#![feature(nll)]

fn foo(x: &i32) -> &i32 {
    let z = 4;
    let f = &|y| { y };
    let k = f(&z);
    f(x)
}

fn main() {}
error: internal compiler error: unexpected region for local data ReFree(DefId(0/0:3 ~ example[8787]::foo[0]), BrAnon(0))
 --> <source>:9:17
  |
6 |     let k = f(&z);
  |                ^
error: aborting due to previous error
Compiler returned: 101
@matthewjasper matthewjasper changed the title [NLL] ICE: unexpected region for local data [NLL] ICE: unexpected region for local data with reference to closure Mar 3, 2018
@ishitatsuyuki ishitatsuyuki added A-NLL Area: Non-lexical lifetimes (NLL) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ WG-compiler-nll labels Mar 4, 2018
@nikomatsakis nikomatsakis added this to the NLL: Valid code works milestone Mar 14, 2018
@nikomatsakis nikomatsakis added the NLL-complete Working towards the "valid code works" goal label Mar 14, 2018
@nikomatsakis
Copy link
Contributor

This is a side-effect, I believe, of the hacky-ish way that we are enabling NLL while still running the old borrow check. In particular, this ICE originates from the old borrow check, I believe caused because we suppressed an error from the old region check (in favor of the new NLL check). We ought to be skipping the old borrow checker as well when NLL is enabled; but we can't do that until the unused_mut work that @KiChjang is working on is complete, I believe, since the borrow checker is still used to track which mut declarations are used. Maybe I can make it swallow the ICE though.

@KiChjang
Copy link
Member

Work is tracked on this PR: #48605.

@nikomatsakis
Copy link
Contributor

I have a simple fix for the ICE in the meantime.

nikomatsakis added a commit to nikomatsakis/rust that referenced this issue Mar 22, 2018
@nikomatsakis nikomatsakis self-assigned this Apr 3, 2018
@jkordish jkordish added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels May 10, 2018
@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-enhancement Category: An issue proposing an enhancement or a PR with one. I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jul 8, 2018
@matthewjasper
Copy link
Contributor Author

This compiles on the latest nightly.

@nikomatsakis nikomatsakis removed this from the NLL: Valid code works milestone Jul 24, 2018
@pnkfelix pnkfelix added this to the Rust 2018 Release Candidate milestone Jul 24, 2018
@Mark-Simulacrum Mark-Simulacrum removed this from the Rust 2018 RC milestone Jul 31, 2018
memoryruins added a commit to memoryruins/rust that referenced this issue Aug 14, 2018
frewsxcv added a commit to frewsxcv/rust that referenced this issue Aug 17, 2018
[nll] add tests for rust-lang#48697 and rust-lang#30104

Adds tests for the following issues:
- rust-lang#48697 ``[NLL] ICE: unexpected region for local data with reference to closure``
- rust-lang#30104 ``Destructuring boxes into multiple mutable references seems broken``

r? @nikomatsakis
bors added a commit that referenced this issue Aug 17, 2018
Rollup of 11 pull requests

Successful merges:

 - #52858 (Implement Iterator::size_hint for Elaborator.)
 - #53321 (Fix usage of `wasm_target_feature`)
 - #53326 ([nll] add regression test for issue #27868)
 - #53347 (rustc_resolve: don't allow paths starting with `::crate`.)
 - #53349 ([nll] add tests for #48697 and #30104)
 - #53357 (Pretty print btreemap for GDB)
 - #53358 (`{to,from}_{ne,le,be}_bytes` for unsigned integer types)
 - #53406 (Do not suggest conversion method that is already there)
 - #53407 (make more ported compile fail tests more robust w.r.t. NLL)
 - #53413 (Warn that `#![feature(rust_2018_preview)]` is implied when the edition is set to Rust 2018.)
 - #53434 (wasm: Remove --strip-debug argument to LLD)

Failed merges:

r? @ghost
@nikomatsakis
Copy link
Contributor

Looks like #53349 was merged, closing

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-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants