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

Issue #5977 - Generalizing RawNullablePointer to RawForbiddenValue #31215

Closed
wants to merge 2 commits into from

Conversation

Yoric
Copy link
Contributor

@Yoric Yoric commented Jan 26, 2016

This is a WIP first step towards Issue #5977. Could someone (@luqman?) take a first look and tell me whether I'm heading in the right direction?

@rust-highfive
Copy link
Collaborator

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@Yoric Yoric force-pushed the forbidden branch 2 times, most recently from 2a1317c to 33b2674 Compare January 26, 2016 15:05
assert_eq!(ix, 0);
val
RawForbiddenValue { payload_discr, .. } => {
if _discr == payload_discr {
Copy link
Member

Choose a reason for hiding this comment

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

You can remove the _ here since the variable is now used.

@luqmana
Copy link
Member

luqmana commented Jan 26, 2016

\o/ seems good! Paves the way for more cool optimizations.

@Yoric
Copy link
Contributor Author

Yoric commented Jan 27, 2016

I haven't managed to generalize StructWrappedNullablePointer to handle forbidden values yet, but I think that the current patch would be useful already as a step forward.

@brson brson added the relnotes Marks issues that should be documented in the release notes of the next release. label Jan 29, 2016
@brson
Copy link
Contributor

brson commented Jan 29, 2016

@bors r+

@bors
Copy link
Contributor

bors commented Jan 29, 2016

📌 Commit 962221b has been approved by brson

@Yoric Yoric force-pushed the forbidden branch 3 times, most recently from 8ab79b1 to 6dec707 Compare January 29, 2016 13:33
@Yoric
Copy link
Contributor Author

Yoric commented Jan 29, 2016

Fixed style and a test that was accidentally ripped from my next patch on the line.

@bors
Copy link
Contributor

bors commented Jan 30, 2016

☔ The latest upstream changes (presumably #30448) made this pull request unmergeable. Please resolve the merge conflicts.

@Yoric
Copy link
Contributor Author

Yoric commented Jan 30, 2016

Fixed.

},
ty::TyRawPtr(..) | ty::TyInt(..) | ty::TyUint(..) => {
path.push(0);
Some(path)
Some((path, C_null(type_of::sizing_type_of(cx, ty))))
Copy link
Member

Choose a reason for hiding this comment

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

ty here would be the NonZero strict so I don't think that's what you want.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understand your sentence, but I just realized that ty was shadowed and that I should probably use the shadowed version instead. Is this the problem you were mentioning?

Copy link
Member

Choose a reason for hiding this comment

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

s/strict/struct/ :P

So, the forbidden value will be compared against the discriminant field. Say we had Option<NonZero<int>>, we're testing that that nested int is non-zero. Currently, it's returning C_null of NonZero (the passed in ty to the function) as the forbidden value rather than of the int field (field_ty).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks. I obviously misunderstood that block.

@brson
Copy link
Contributor

brson commented Feb 2, 2016

r? @pnkfelix

@rust-highfive rust-highfive assigned pnkfelix and unassigned brson Feb 2, 2016
@Yoric
Copy link
Contributor Author

Yoric commented Feb 2, 2016

@luqmana I can put a i8 instead of whatever I have now, but could you show me code to convince me that I'm doing the right thing? :)

@Yoric
Copy link
Contributor Author

Yoric commented Feb 3, 2016

/me grumbles something about 100-chars limit.

@bors
Copy link
Contributor

bors commented Feb 6, 2016

☔ The latest upstream changes (presumably #31417) made this pull request unmergeable. Please resolve the merge conflicts.

@Yoric
Copy link
Contributor Author

Yoric commented Feb 23, 2016

Well, I'm still waiting for @luqmana to answer one of my questions, plus I haven't seen any review from @pnkfelix .

@@ -438,23 +469,34 @@ struct Case<'tcx> {
/// This represents the (GEP) indices to follow to get to the discriminant field
pub type DiscrField = Vec<usize>;

fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
fn find_discr_field_candidate<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
Copy link
Member

Choose a reason for hiding this comment

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

Please either add a doc comment explaining what the two parts of the returned tuple are and/or switch from using a tuple to using a struct with self-explanatory named fields

@pnkfelix
Copy link
Member

commits lgtm:

@@ -1 +1 @@
Subproject commit 30f70baa6cc1ba3ddebb55b988fafbad0c0cc810
Subproject commit 91ff43c736de664f8d3cd351e148c09cdea6731e
Copy link
Member

Choose a reason for hiding this comment

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

hmm was this an accidental commit?

@pnkfelix
Copy link
Member

@Yoric I'd say this is definitely on the right track! Great stuff, sorry it took me so long to get around to looking seriously at it.

If you rebase I suspect I'll just do a superficial review before r-plussing. (In other words, if another reviewer happens to get to it and wants to do r=pnkfelix, that will probably be fine.)

@alexcrichton
Copy link
Member

Closing due to inactivity, but feel free to resubmit with a rebase!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants