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

Closure in repeat expression causes cyclic dependency error #50688

Closed
leoyvens opened this issue May 12, 2018 · 0 comments · Fixed by #50851
Closed

Closure in repeat expression causes cyclic dependency error #50688

leoyvens opened this issue May 12, 2018 · 0 comments · Fixed by #50851

Comments

@leoyvens
Copy link
Contributor

The following code:

fn main() { 
    [1;  || {} ];
}

Will give a cyclic query dependency error between checking main and const-evaluating the closure, but if you use [1; { || {} } ] then you get a proper type checking error.

bors added a commit that referenced this issue May 20, 2018
rustc: introduce {ast,hir}::AnonConst to consolidate so-called "embedded constants".

Previously, constants in array lengths and enum variant discriminants were "merely an expression", and had no separate ID for, e.g. type-checking or const-eval, instead reusing the expression's.

That complicated code working with bodies, because such constants were the only special case where the "owner" of the body wasn't the HIR parent, but rather the same node as the body itself.
Also, if the body happened to be a closure, we had no way to allocate a `DefId` for both the constant *and* the closure, leading to *several* bugs (mostly ICEs where type errors were expected).

This PR rectifies the situation by adding another (`{ast,hir}::AnonConst`) node around every such constant. Also, const generics are expected to rely on the new `AnonConst` nodes, as well (cc @varkor).
* fixes #48838
* fixes #50600
* fixes #50688
* fixes #50689
* obsoletes #50623

r? @nikomatsakis
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant