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 inference variable in outlives" #52057

Closed
nikomatsakis opened this issue Jul 4, 2018 · 8 comments
Closed

NLL ICE: "unresolved inference variable in outlives" #52057

nikomatsakis opened this issue Jul 4, 2018 · 8 comments
Assignees
Labels
A-NLL Area: Non-lexical lifetimes (NLL) I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ 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

@nikomatsakis
Copy link
Contributor

The crater run turned up a number of crates encountering an ICE with a message like "unresolved inference variable in outlives" (see list in #52054). I'm not sure what is the problem yet but I'm filing this bug to track the issue.

A good representative is combine-language-2.0.0-beta4, which failed with this log.

@nikomatsakis nikomatsakis added 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. A-NLL Area: Non-lexical lifetimes (NLL) WG-compiler-nll labels Jul 4, 2018
@nikomatsakis nikomatsakis added this to the Rust 2018 Preview 2 milestone Jul 4, 2018
@nikomatsakis nikomatsakis added the NLL-complete Working towards the "valid code works" goal label Jul 4, 2018
@matthewjasper
Copy link
Contributor

Self contained example. Related to #51649?

// Delayed ICE:
// error: internal compiler error: unresolved inference variable in outlives: _#0t
#![feature(nll)]

pub trait Parser {
    type Input;

    #[inline(always)]
    fn parse_first(input: &mut Self::Input);
}

impl<'a, I, P: ?Sized> Parser for &'a mut P
where
    P: Parser<Input = I>,
{
    type Input = I;

    fn parse_first(_: &mut Self::Input) {}
}

fn main() {}

@nikomatsakis nikomatsakis self-assigned this Jul 17, 2018
@pnkfelix
Copy link
Member

triage re-assigning to self

@pnkfelix pnkfelix assigned pnkfelix and unassigned nikomatsakis Jul 24, 2018
@nikomatsakis
Copy link
Contributor Author

I think this may have been fixed by #51959. At least @matthewjasper's example no longer reproduces. I'll have to try the original crate.

@nikomatsakis
Copy link
Contributor Author

OK wait. @matthewjasper's example now fails to build, whereas it builds without nll. It no longer ICEs though.

@nikomatsakis
Copy link
Contributor Author

Ah, I see the problem. It arises because we don't normalize types before computing the implied bounds in the universal regions code:

// Add the implied bounds from inputs and outputs.
for ty in inputs_and_output {
debug!("build: input_or_output={:?}", ty);
self.add_implied_bounds(&indices, ty);
}

even though we just "liberated" late-bound regions:

let inputs_and_output = self.infcx.replace_bound_regions_with_nll_infer_vars(
FR,
self.mir_def_id,
&bound_inputs_and_output,
&mut indices,
);

@nikomatsakis
Copy link
Contributor Author

It's a bit tricky -- we don't just want to insert a random call to normalize until we've finished generating all the "free regions". That call could produce outlives obligations we have to propagate to the right place. It's not that big a deal, in fact at this point we have generated all the free regions:

let num_universals = self.infcx.num_region_vars();

but we still need to route the resulting outlives obligations to the right place. This will take a touch of reorganization in the code.

@nikomatsakis
Copy link
Contributor Author

I'm working on this. It's non-trivial.

@nikomatsakis
Copy link
Contributor Author

But I'm getting there =)

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) ❄️ 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

3 participants