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 ReFree #50467

Closed
simonvandel opened this Issue May 5, 2018 · 7 comments

Comments

Projects
None yet
5 participants
@simonvandel
Copy link

simonvandel commented May 5, 2018

The code in https://github.com/simonvandel/fcbf/tree/nll-ice produces the following ICE:

error: internal compiler error: unexpected region for local data ReFree(DefId(0/0:13 ~ fcbf[25b8]::x[0]), BrNamed(crate0:DefIndex(1:12), 'x))
  --> src/main.rs:23:8
   |
23 |     f(&f_y);
   |        ^^^

When compiled with:

cargo +nightly check

NLL is enabled in the top of main.rs with #![feature(nll)]. Without NLL, a normal borrow check error is presented.

Meta

rustc --version --verbose:
rustc 1.27.0-nightly (91db9dc 2018-05-04)
binary: rustc
commit-hash: 91db9dc
commit-date: 2018-05-04
host: x86_64-unknown-linux-gnu
release: 1.27.0-nightly
LLVM version: 6.0

@sanxiyn sanxiyn added the A-NLL label May 6, 2018

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented May 8, 2018

triage: it would be good to reduce this down to a standalone example. (In part, that may help us identify if this is a duplicate bug or not.)

Assigning to self to do reduction.

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Jul 3, 2018

I'm "nominating" this issue as something to fix for Edition Preview 2 -- specifically, we should first try and reduce it to a standalone example. I would do this by checking out the project above and then removing the ndarray and trying to "stub out" the dependencies locally, making dummy structs etc as needed.

@shepmaster

This comment has been minimized.

Copy link
Member

shepmaster commented Jul 3, 2018

I will attempt to reduce the problem, we'll see if I can go any further than that!

@nikomatsakis nikomatsakis assigned shepmaster and unassigned pnkfelix Jul 3, 2018

@shepmaster

This comment has been minimized.

Copy link
Member

shepmaster commented Jul 3, 2018

With rustc 1.28.0-nightly (ae46aefd5 2018-06-16) I do not see an ICE, but I do see these errors:

warning: unused variable: `cacher`
  --> src/main.rs:31:37
   |
31 | fn symmetric_uncertainty_cached<'a>(cacher: &mut MyCacher, x: &'a Col<'a>, y: &'a Col<'a>) -> ValueType {
   |                                     ^^^^^^ help: consider using `_cacher` instead
   |
   = note: #[warn(unused_variables)] on by default

error[E0597]: `x` does not live long enough
   --> src/main.rs:106:26
    |
106 |     let cols: Vec<Col> = x.gencolumns()
    |                          ^ borrowed value does not live long enough
...
172 | }
    | - borrowed value only lives until here
    |
note: borrowed value must be valid for the lifetime 'x as defined on the function body at 91:1...
   --> src/main.rs:91:1
    |
91  | / pub fn fcbf<'x>(
92  | |     x: ArrayView<'x, ValueType, Ix2>,
93  | |     y: ArrayView<'x, ValueType, Ix1>,
94  | |     threshold: f64,
...   |
171 | |     x.select(Axis(1), &feature_views)
172 | | }
    | |_^

error[E0597]: `s_list` does not live long enough
   --> src/main.rs:130:27
    |
130 |     while let Some(f_p) = s_list.get(cur_feature_idx) {
    |                           ^^^^^^ borrowed value does not live long enough
...
172 | }
    | - borrowed value only lives until here
    |
note: borrowed value must be valid for the lifetime 'x as defined on the function body at 91:1...
   --> src/main.rs:91:1
    |
91  | / pub fn fcbf<'x>(
92  | |     x: ArrayView<'x, ValueType, Ix2>,
93  | |     y: ArrayView<'x, ValueType, Ix1>,
94  | |     threshold: f64,
...   |
171 | |     x.select(Axis(1), &feature_views)
172 | | }
    | |_^

error[E0597]: `s_list` does not live long enough
   --> src/main.rs:132:26
    |
132 |         let unexplored = s_list.iter().skip(cur_feature_idx + 1).filter(|f_q| {
    |                          ^^^^^^ borrowed value does not live long enough
...
172 | }
    | - borrowed value only lives until here
    |
note: borrowed value must be valid for the lifetime 'x as defined on the function body at 91:1...
   --> src/main.rs:91:1
    |
91  | / pub fn fcbf<'x>(
92  | |     x: ArrayView<'x, ValueType, Ix2>,
93  | |     y: ArrayView<'x, ValueType, Ix1>,
94  | |     threshold: f64,
...   |
171 | |     x.select(Axis(1), &feature_views)
172 | | }
    | |_^

error[E0597]: `f_y` does not live long enough
   --> src/main.rs:132:73
    |
132 |           let unexplored = s_list.iter().skip(cur_feature_idx + 1).filter(|f_q| {
    |  _________________________________________________________________________^
133 | |             assert_ne!(f_p.col.idx, f_q.col.idx);
134 | |             let su_p_q = symmetric_uncertainty_cached(&mut cacher,
135 | |                     &f_q.col,
...   |
141 | |             f_q_su_target > su_p_q
142 | |         });
    | |_________^ borrowed value does not live long enough
...
172 |   }
    |   - borrowed value only lives until here
    |
note: borrowed value must be valid for the lifetime 'x as defined on the function body at 91:1...
   --> src/main.rs:91:1
    |
91  | / pub fn fcbf<'x>(
92  | |     x: ArrayView<'x, ValueType, Ix2>,
93  | |     y: ArrayView<'x, ValueType, Ix1>,
94  | |     threshold: f64,
...   |
171 | |     x.select(Axis(1), &feature_views)
172 | | }
    | |_^

error[E0597]: `c` does not live long enough
   --> src/main.rs:118:64
    |
118 |         let su_i_c = symmetric_uncertainty_cached(&mut cacher, &c, &f_y);
    |                                                                ^^ borrowed value does not live long enough
...
172 | }
    | - borrowed value only lives until here
    |
note: borrowed value must be valid for the lifetime 'x as defined on the function body at 91:1...
   --> src/main.rs:91:1
    |
91  | / pub fn fcbf<'x>(
92  | |     x: ArrayView<'x, ValueType, Ix2>,
93  | |     y: ArrayView<'x, ValueType, Ix1>,
94  | |     threshold: f64,
...   |
171 | |     x.select(Axis(1), &feature_views)
172 | | }
    | |_^

error[E0597]: `f_y` does not live long enough
   --> src/main.rs:118:68
    |
118 |         let su_i_c = symmetric_uncertainty_cached(&mut cacher, &c, &f_y);
    |                                                                    ^^^^ borrowed value does not live long enough
...
172 | }
    | - borrowed value only lives until here
    |
note: borrowed value must be valid for the lifetime 'x as defined on the function body at 91:1...
   --> src/main.rs:91:1
    |
91  | / pub fn fcbf<'x>(
92  | |     x: ArrayView<'x, ValueType, Ix2>,
93  | |     y: ArrayView<'x, ValueType, Ix1>,
94  | |     threshold: f64,
...   |
171 | |     x.select(Axis(1), &feature_views)
172 | | }
    | |_^

error[E0505]: cannot move out of `c` because it is borrowed
   --> src/main.rs:120:38
    |
118 |         let su_i_c = symmetric_uncertainty_cached(&mut cacher, &c, &f_y);
    |                                                                -- borrow of `c` occurs here
119 |         if su_i_c >= threshold {
120 |             s_list.push(Feature{col: c, su_target: su_i_c});
    |                                      ^
    |                                      |
    |                                      move out of `c` occurs here
    |                                      borrow later used here

error[E0502]: cannot borrow `s_list` as mutable because it is also borrowed as immutable
   --> src/main.rs:159:5
    |
130 |     while let Some(f_p) = s_list.get(cur_feature_idx) {
    |                           ------ immutable borrow occurs here
...
159 |     s_list.sort_by(|a, b| {
    |     ^^^^^^
    |     |
    |     mutable borrow occurs here
    |     borrow later used here

error[E0506]: cannot assign to `s_list` because it is borrowed
   --> src/main.rs:153:9
    |
130 |     while let Some(f_p) = s_list.get(cur_feature_idx) {
    |                           ------
    |                           |
    |                           borrow of `s_list` occurs here
    |                           borrow later used here
...
153 |         s_list = new_s_list.clone();
    |         ^^^^^^ assignment to borrowed `s_list` occurs here
@shepmaster

This comment has been minimized.

Copy link
Member

shepmaster commented Jul 3, 2018

I see the same behavior with rustc 1.28.0-nightly (e3bf634e0 2018-06-28)

@nikomatsakis

This comment has been minimized.

Copy link
Contributor

nikomatsakis commented Jul 3, 2018

OK, I'm going to close this issue for now then.

@simonvandel

This comment has been minimized.

Copy link
Author

simonvandel commented Jul 3, 2018

The ICE might have been fixed in the meantime; I reported this some time ago. Note that the specific branch is probably not compilable. I just took a snapshot as I saw the ICE.

@pnkfelix pnkfelix self-assigned this Aug 28, 2018

@pnkfelix pnkfelix removed the I-nominated label Sep 4, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.