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: unresolved type in dtorck #47022

Closed
jedisct1 opened this issue Dec 26, 2017 · 10 comments
Closed

NLL ICE: unresolved type in dtorck #47022

jedisct1 opened this issue Dec 26, 2017 · 10 comments
Labels
A-NLL Area: Non-lexical lifetimes (NLL) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️

Comments

@jedisct1
Copy link
Contributor

rustc version:

rustc 1.24.0-nightly (4a7c072fa 2017-12-25)

This is on macOS.

Enabling NLL triggers an ICE when trying to compile EdgeDNS (nll branch from https://github.com/jedisct1/edgedns):

error: internal compiler error: unresolved type in dtorck

This happens at link time.

@estebank estebank added A-NLL Area: Non-lexical lifetimes (NLL) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ WG-compiler-nll labels Dec 26, 2017
@estebank
Copy link
Contributor

@tbelaire
Copy link
Contributor

I also get the same error with this code
https://gist.github.com/tbelaire/670ab192589311ba114b4b63d2cc681d

@tbelaire
Copy link
Contributor

In particular, this line caused the ICE:

let m = Array::from_iter(input.lines().flat_map(|l| l.as_bytes().iter().cloned()));

@vorner
Copy link
Contributor

vorner commented Dec 31, 2017

I get the same error, with a different snippet ‒ maybe it can help to cross-compare them and close on the cause.

I didn't manage to get a backtrace from rustc :-(

        fn convert(objects: Vec<LoadedObject>) -> (Vec<Body>, Vec<Graphic>) {
            objects
                .into_iter()
                .flat_map(|LoadedObject { bodies, color, .. }| {
                    bodies.into_iter()
                        .map(move |body| (body, Graphic { color: color.clone() }))
                })
                .unzip()
        }

Replacing the flat_map with map(...).flatten() helps (flatten from itertools).

@nikomatsakis
Copy link
Contributor

I've also observed this error =)

This is a self-contained example (based on @vorner's snippet) the seems to reproduce the problem:

#![feature(nll)]

struct LoadedObject {
    bodies: Vec<Body>,
    color: Color,
}

struct Body;

#[derive(Clone)]
struct Color;

struct Graphic {
    color: Color,
}

fn convert(objects: Vec<LoadedObject>) -> (Vec<Body>, Vec<Graphic>) {
    objects
        .into_iter()
        .flat_map(|LoadedObject { bodies, color, .. }| {
            bodies.into_iter().map(move |body| {
                (
                    body,
                    Graphic {
                        color: color.clone(),
                    },
                )
            })
        })
        .unzip()
}

fn main() {}

@nikomatsakis nikomatsakis changed the title ICE when NLL is enabled NLL ICE: unresolved type in dtorck Jan 3, 2018
@tbelaire
Copy link
Contributor

tbelaire commented Jan 4, 2018

Dang, I'm getting some non-local effects with this, or something.

I had two branches which added different files and only really overlapped in main.rs and Cargo.toml (for adding deps). Both compiled fine, but merging them caused this error to appear.

Getting rid of flat_maps seems to solve the problem though :/

@jedisct1
Copy link
Contributor Author

jedisct1 commented Jan 4, 2018

@tbelaire I think this is due to incremental compilation. If you compile a project without NLL, and then add the NLL feature flag, it will compile just fine. It you cargo clean and rebuild it, it will fail.

@tbelaire
Copy link
Contributor

tbelaire commented Jan 4, 2018 via email

@nikomatsakis nikomatsakis added this to the NLL Future Compat Warnings milestone Jan 4, 2018
@nikomatsakis
Copy link
Contributor

I'm digging in. I'll leave some notes here as I go.

Relevant part of the backtrace:

  11: rustc::ty::util::<impl rustc::ty::context::TyCtxt<'a, 'gcx, 'tcx>>::dtorck_constraint_for_ty
             at src/librustc/ty/util.rs:609
  12: rustc_mir::borrow_check::nll::type_check::liveness::generate
             at src/librustc_mir/borrow_check/nll/type_check/liveness.rs:192
             at src/librustc_mir/borrow_check/nll/type_check/liveness.rs:126
             at src/librustc_mir/borrow_check/nll/type_check/liveness.rs:51
  13: rustc_mir::borrow_check::nll::type_check::type_check::{{closure}}
             at src/librustc_mir/borrow_check/nll/type_check/mod.rs:116
  14: rustc_mir::borrow_check::nll::type_check::type_check_internal
             at src/librustc_mir/borrow_check/nll/type_check/mod.rs:150
  15: rustc_mir::borrow_check::nll::type_check::type_check
             at src/librustc_mir/borrow_check/nll/type_check/mod.rs:108

This is occurring in the liveness code.

@nikomatsakis
Copy link
Contributor

Fix pending in #47322

kennytm added a commit to kennytm/rust that referenced this issue Jan 11, 2018
resolve type and region variables in "NLL dropck"

Fixes rust-lang#47022.

r? @pnkfelix
kennytm added a commit to kennytm/rust that referenced this issue Jan 11, 2018
resolve type and region variables in "NLL dropck"

Fixes rust-lang#47022.

r? @pnkfelix
bors added a commit that referenced this issue Jan 14, 2018
resolve type and region variables in "NLL dropck"

Fixes #47022.

r? @pnkfelix
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) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️
Projects
None yet
Development

No branches or pull requests

5 participants