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

Implement IsOpaque for CompInfo #823

Merged

Conversation

fitzgen
Copy link
Member

@fitzgen fitzgen commented Jul 18, 2017

This allows us to properly detect structs that should be treated as opaque due to their non-type template paramaters, which in turn lets us correctly codegen template aliases to such things.

Fixes #820

r? @emilio

@highfive
Copy link

warning Warning warning

  • These commits modify unsafe code. Please review it carefully!

@upsuper
Copy link
Contributor

upsuper commented Jul 18, 2017

Why is Debug removed from many of the cases? I'm a bit concerned this could potentially break some code.

Also, it seems those Default and Clone impls are redundant. They should be derivable.

@fitzgen
Copy link
Member Author

fitzgen commented Jul 18, 2017

I had to change our defaults from true to false for when we don't have a layout because we were mistakenly putting derive(Debug) on arrays of 33 elements when 32 is the max. I'll look into loosening it again and see if I can fix the root cause.

We can still derive(Copy) even when we can't derive(Clone) because it is just a marker trait and has no fixed number of elements limit.

@fitzgen fitzgen force-pushed the issue-820-unused-template-param-in-alias branch from 370ebee to e425971 Compare July 18, 2017 23:24
@fitzgen
Copy link
Member Author

fitzgen commented Jul 18, 2017

Ok, it turns out that the CanDeriveDebug implementation for templates needed to look through type refs and aliases when checking for if its definition used non-type template parameters. Fixing that and we can go back to being optimistic when we don't have a layout.

@emilio
Copy link
Contributor

emilio commented Jul 19, 2017

@fitzgen does this conflict with #824? Should we wait for that to land?

@fitzgen
Copy link
Member Author

fitzgen commented Jul 19, 2017

@fitzgen does this conflict with #824? Should we wait for that to land?

#824 should actually make the seeing-through-type-refs Just Work automatically. There may be conflicts in git but it shouldn't be too bad.

Since this fixes a stylo bug, I think we shouldn't wait around and should land this now.

@emilio
Copy link
Contributor

emilio commented Jul 19, 2017

Well, stylo isn't updating at least until #826 is fixed I think, but sure, will review this now.

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(And of course forgot about it). LGTM

src/ir/comp.rs Outdated
.opaque()
.can_derive_default(ctx, ());
return layout.map_or(true, |l| l.opaque().can_derive_default(ctx, ()));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Spurious newline.

This allows us to properly detect structs that should be treated as opaque due
to their non-type template paramaters, which in turn lets us correctly codegen
template aliases to such things.

Fixes rust-lang#820
@fitzgen fitzgen force-pushed the issue-820-unused-template-param-in-alias branch from e425971 to 20253fc Compare July 20, 2017 16:43
@fitzgen
Copy link
Member Author

fitzgen commented Jul 20, 2017

@bors-servo r=emilio

@bors-servo
Copy link

📌 Commit 20253fc has been approved by emilio

@bors-servo
Copy link

⌛ Testing commit 20253fc with merge 781385f...

bors-servo pushed a commit that referenced this pull request Jul 20, 2017
…, r=emilio

Implement `IsOpaque` for `CompInfo`

This allows us to properly detect structs that should be treated as opaque due to their non-type template paramaters, which in turn lets us correctly codegen template aliases to such things.

Fixes #820

r? @emilio
@bors-servo
Copy link

☀️ Test successful - status-travis
Approved by: emilio
Pushing 781385f to master...

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.

None yet

5 participants