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

Fix two unboxed closure ICEs #18688

Merged
merged 3 commits into from
Nov 7, 2014

Conversation

bkoropoff
Copy link
Contributor

This resolves some issues that remained after adding support for monomorphizing unboxed closures in trans.

There were a few places where a set of substitutions for an unboxed closure type were dropped on the floor and later recalculated from scratch based on the def ID, but this failed spectacularly when the closure originated from a different param environment. The substitutions are now plumbed through end-to-end. Closes #18661

There was also a conflict in the meaning of the self param space within the body of the unboxed closure. Trans attempted to insert the unboxed closure type as the self type, but this could conflict with the self type from the param environment when an unboxed closure was used within a default method on a trait. Since the body of an unboxed closure cannot refer to its own self type or value, there's no need for it to actually use the self space. The downstream consumers of the substitutions in trans do not seem to need it either since they look up the type of the closure some other way, so I just stopped setting it. Closes #18685.

r? @pcwalton @nikomatsakis

@nikomatsakis
Copy link
Contributor

@bkoropoff so this looks good, surprised I missed this when looking before, but I'm wondering why we don't unconditionally supply substitutions...?

@bkoropoff
Copy link
Contributor Author

@nikomatsakis taking an Option was the path of least resistance, but I can make it take the substitutions unconditionally and just pass the current param env explicitly in trans_unboxed_closure

- When selecting an implicit trait impl for an unboxed closure, plumb
  through and use the substitutions from impl selection instead of
  using those from the current param environment in trans, which may
  be incorrect.
- When generating a function declaration for an unboxed closure, plumb
  through the substitutions from the param environment of the closure
  as above.  Also normalize the type to avoid generating duplicate
  declarations due to regions being inconsistently replaced with
  ReStatic elsewhere.
- Do not place the closure type in the self param space when
  translating the unboxed closure callee, etc.  It is not actually
  used, and doing so conflicts with the self substitution from
  default trait methods.

Closes rust-lang#18661
Closes rust-lang#18685
@bkoropoff
Copy link
Contributor Author

Updated to always pass the substs explicitly

bors added a commit that referenced this pull request Nov 7, 2014
…nikomatsakis

This resolves some issues that remained after adding support for monomorphizing unboxed closures in trans.

There were a few places where a set of substitutions for an unboxed closure type were dropped on the floor and later recalculated from scratch based on the def ID, but this failed spectacularly when the closure originated from a different param environment.  The substitutions are now plumbed through end-to-end.  Closes #18661

There was also a conflict in the meaning of the self param space within the body of the unboxed closure.  Trans attempted to insert the unboxed closure type as the self type, but this could conflict with the self type from the param environment when an unboxed closure was used within a default method on a trait.  Since the body of an unboxed closure cannot refer to its own self type or value, there's no need for it to actually use the self space.  The downstream consumers of the substitutions in trans do not seem to need it either since they look up the type of the closure some other way, so I just stopped setting it.  Closes #18685.

r? @pcwalton @nikomatsakis
@bors bors closed this Nov 7, 2014
@bors bors merged commit ddb17b2 into rust-lang:master Nov 7, 2014
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 this pull request may close these issues.

Unboxed closure ICE due to conflicting use of self param space ICE: LLVM Assertion with Unboxed Closures
4 participants