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

More align_offset things #44537

Merged
merged 1 commit into from
Sep 18, 2017
Merged

More align_offset things #44537

merged 1 commit into from
Sep 18, 2017

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Sep 13, 2017

cc #44488

@rust-highfive
Copy link
Collaborator

r? @alexcrichton

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

let mut offset;
if align > 0 {
offset = cmp::min(usize_bytes - align, len);
let mut offset = unsafe { align_offset(ptr as *const _, usize_bytes) };
Copy link
Member

Choose a reason for hiding this comment

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

Should this be using the inherent methods added in this PR?

Copy link
Contributor Author

@oli-obk oli-obk Sep 13, 2017

Choose a reason for hiding this comment

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

The compiler complained that it doesn't know the unstable feature (on stage0). This would become a mess of cfgs, so I opted to not do this here.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds like a stage0 inherent method on pointers which does the old method via casts and not(stage0) uses the intrinsic?

/// remove me after the next release
pub fn align_offset(self, align: usize) -> usize {
unsafe {
intrinsics::align_offset(self as *const _, align)
Copy link
Member

Choose a reason for hiding this comment

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

This looks the same as the above function? I think the #[cfg] in the intrinsics module should be enough?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It differs in the stability. I couldn't use the function within core without giving core the corresponding feature, which then complained about an unknown feature.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure I understand this? Can't the stage0 shim in the intrinsics module be just as unstable as the real intrinsic in non-stage0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I must have misread the error messages I got. It works now without duplicating the inherent methods. The intrinsics are still duplicated.

@aidanhs aidanhs added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 13, 2017
@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Sep 14, 2017

📌 Commit 1462cab has been approved by alexcrichton

@alexcrichton
Copy link
Member

@bors: rollup

frewsxcv added a commit to frewsxcv/rust that referenced this pull request Sep 16, 2017
@bors
Copy link
Contributor

bors commented Sep 16, 2017

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

bors added a commit that referenced this pull request Sep 17, 2017
@oli-obk
Copy link
Contributor Author

oli-obk commented Sep 17, 2017

Rebased

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Sep 17, 2017

📌 Commit 2787a28 has been approved by alexcrichton

alexcrichton added a commit to alexcrichton/rust that referenced this pull request Sep 18, 2017
bors added a commit that referenced this pull request Sep 18, 2017
Rollup of 10 pull requests

- Successful merges: #44364, #44466, #44537, #44640, #44651, #44657, #44661, #44668, #44671, #44675
- Failed merges:
alexcrichton added a commit to alexcrichton/rust that referenced this pull request Sep 18, 2017
bors added a commit that referenced this pull request Sep 18, 2017
Rollup of 11 pull requests

- Successful merges: #44364, #44466, #44537, #44548, #44640, #44651, #44657, #44661, #44668, #44671, #44675
- Failed merges:
@bors bors merged commit 2787a28 into rust-lang:master Sep 18, 2017
@oli-obk oli-obk deleted the memchr branch April 11, 2018 13:53
Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this pull request Jul 27, 2018
make memrchr use align_offset

I hope I did not screw that up...

Cc @oli-obk who authored the original rust-lang#44537
bors added a commit that referenced this pull request Jul 28, 2018
make memrchr use align_offset

I hope I did not screw that up...

Cc @oli-obk who authored the original #44537

Fixes #50567 (thanks @bjorn3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants