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

Partially stabilize const_slice_from_raw_parts #97522

Merged

Conversation

KamilaBorowska
Copy link
Contributor

@KamilaBorowska KamilaBorowska commented May 29, 2022

This doesn't stabilize methods working on mutable pointers.

This pull request continues from #94946.

Pinging @rust-lang/wg-const-eval this because I use rustc_allow_const_fn_unstable. I believe this is justifiable as it's already possible to use slice::from_raw_parts in stable by abusing transmute. The stable alternative to this would be to provide a stable const implementation of std::ptr::from_raw_parts (as it can already be implemented in stable).

use std::mem;

#[repr(C)]
struct Slice<T> {
    data: *const T,
    len: usize,
}

fn main() {
    let data: *const i32 = [1, 2, 3, 4].as_ptr();
    let len = 4;
    println!("{:?}", unsafe {
        mem::transmute::<Slice<i32>, &[i32]>(Slice { data, len })
    });
}

@rustbot modify labels: +T-libs-api

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label May 29, 2022
@rust-highfive
Copy link
Collaborator

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with r? rust-lang/libs-api @rustbot label +T-libs-api -T-libs to request review from a libs-api team reviewer. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rustbot rustbot added the T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. label May 29, 2022
@rust-highfive
Copy link
Collaborator

r? @scottmcm

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 29, 2022
@rust-log-analyzer

This comment has been minimized.

@KamilaBorowska KamilaBorowska force-pushed the stabilize-slice-from-raw-parts branch from f0bb103 to 01203df Compare May 29, 2022 16:28
@m-ou-se m-ou-se removed the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jun 22, 2022
@m-ou-se
Copy link
Member

m-ou-se commented Jun 22, 2022

@rfcbot merge

cc @rust-lang/wg-const-eval

@rfcbot
Copy link

rfcbot commented Jun 22, 2022

Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jun 22, 2022
@m-ou-se m-ou-se added S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Jun 22, 2022
@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label Jun 29, 2022
@rfcbot
Copy link

rfcbot commented Jun 29, 2022

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Jun 29, 2022
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Jul 9, 2022
@rfcbot
Copy link

rfcbot commented Jul 9, 2022

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@rfcbot rfcbot added the to-announce Announce this issue on triage meeting label Jul 9, 2022
@rustbot

This comment was marked as resolved.

Copy link
Member

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

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

Thanks!

@dtolnay
Copy link
Member

dtolnay commented Jul 9, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jul 9, 2022

📌 Commit 08819803a89d82543261337786f19897f5761828 has been approved by dtolnay

It is now in the queue for this repository.

@bors bors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Jul 9, 2022
@KamilaBorowska
Copy link
Contributor Author

Rebased.

@dtolnay
Copy link
Member

dtolnay commented Jul 9, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Jul 9, 2022

📌 Commit 96ef66a78dd52dd46ccfa3d58a171e9bf9e62be6 has been approved by dtolnay

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 9, 2022
@rust-log-analyzer

This comment has been minimized.

This doesn't stabilize methods working on mutable pointers.
@KamilaBorowska KamilaBorowska force-pushed the stabilize-slice-from-raw-parts branch from 96ef66a to 0753fd1 Compare July 9, 2022 21:20
@RalfJung
Copy link
Member

RalfJung commented Jul 9, 2022

@bors r=dtolnay

@bors
Copy link
Contributor

bors commented Jul 9, 2022

📌 Commit 0753fd1 has been approved by dtolnay

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jul 10, 2022

⌛ Testing commit 0753fd1 with merge 95e7764...

@bors
Copy link
Contributor

bors commented Jul 10, 2022

☀️ Test successful - checks-actions
Approved by: dtolnay
Pushing 95e7764 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 10, 2022
@bors bors merged commit 95e7764 into rust-lang:master Jul 10, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 10, 2022
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (95e7764): comparison url.

Instruction count

  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regressions found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
1.4% 1.6% 4
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) N/A N/A 0

Max RSS (memory usage)

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
3.1% 3.1% 1
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-3.9% -3.9% 1
All 😿🎉 (primary) N/A N/A 0

Cycles

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: 😿 relevant regression found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
2.9% 2.9% 1
Improvements 🎉
(primary)
-2.3% -2.3% 1
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) -2.3% -2.3% 1

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

yvt added a commit to r3-os/r3 that referenced this pull request Aug 13, 2022
…mut})]`

`from_raw_parts` has been partially stabilized by
[rust-lang/rust#97522][1]. `from_raw_parts_mut` has been split into a
separate feature `const_slice_from_raw_parts_mut`.

[1]: rust-lang/rust#97522
@apiraino apiraino removed the to-announce Announce this issue on triage meeting label Sep 8, 2022
jf2048 added a commit to jf2048/gtk-rs-core that referenced this pull request Nov 26, 2022
For const std::slice::from_raw_parts, stabilized in
rust-lang/rust#97522
jf2048 added a commit to jf2048/gtk-rs-core that referenced this pull request Nov 26, 2022
For const std::slice::from_raw_parts, stabilized in
rust-lang/rust#97522
jf2048 added a commit to jf2048/gtk-rs-core that referenced this pull request Dec 12, 2022
For const std::slice::from_raw_parts, stabilized in
rust-lang/rust#97522
jf2048 added a commit to jf2048/gtk-rs-core that referenced this pull request Dec 13, 2022
For const std::slice::from_raw_parts, stabilized in
rust-lang/rust#97522
sdroege pushed a commit to jf2048/gtk-rs-core that referenced this pull request Dec 24, 2022
For const std::slice::from_raw_parts, stabilized in
rust-lang/rust#97522
sdroege pushed a commit to jf2048/gtk-rs-core that referenced this pull request Dec 24, 2022
For const std::slice::from_raw_parts, stabilized in
rust-lang/rust#97522
@RalfJung RalfJung changed the title Partially stabilize const_slice_from_raw_parts Partially stabilize const_slice_from_raw_parts_mut Sep 24, 2024
@RalfJung RalfJung changed the title Partially stabilize const_slice_from_raw_parts_mut Partially stabilize const_slice_from_raw_parts Sep 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
finished-final-comment-period The final comment period is finished for this PR / Issue. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. S-waiting-on-fcp Status: PR is in FCP and is awaiting for FCP to complete. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.