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

Add doc alias memset to write_bytes #97565

Merged
merged 2 commits into from
May 31, 2022
Merged

Add doc alias memset to write_bytes #97565

merged 2 commits into from
May 31, 2022

Conversation

lukas-code
Copy link
Member

I were looking for memset in rust, but the docs only pointed me to slice::fill.

With only the old aliases, one might write code like this, which is incorrect if the memory is uninitialized.

core::slice::from_raw_parts(ptr, len).fill(0)

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label May 30, 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

@rust-highfive
Copy link
Collaborator

r? @thomcc

(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 30, 2022
@thomcc
Copy link
Member

thomcc commented May 30, 2022

Hmm, I'm inclined to allow this, but we do say that we don't want to do this in the alias policy: https://std-dev-guide.rust-lang.org/documentation/doc-alias-policy.html

There must be an obvious single target for the alias that is an exact analogue of the aliased name. We will not add the same alias to multiple declarations. (const and non-const versions of the same function are fine.) We will also not add an alias for a function that's only somewhat similar or related.

Hmm... I'll bring it up on zulip.

@lukas-code
Copy link
Member Author

We already have memcpy aliased to slice::copy_from_slice and ptr::copy_nonoverlapping.

@thomcc
Copy link
Member

thomcc commented May 30, 2022

I brought it up here: https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Unsafe.20and.20Safe.20versions.20of.20APIs.20both.20getting.20the.20same.20alias. I think it might be worth changing our policy to allow this, possibly.

@thomcc
Copy link
Member

thomcc commented May 30, 2022

I think there's enough precedent here and it's uncontroversial enough that we'll take it, regardless of whether or not we change the guidelines.

@bors r+ rollup

@bors
Copy link
Contributor

bors commented May 30, 2022

📌 Commit e565bb0 has been approved by thomcc

@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-review Status: Awaiting review from the assignee but also interested parties. labels May 30, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request May 31, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#97089 (Improve settings theme display)
 - rust-lang#97229 (Document the current aliasing rules for `Box<T>`.)
 - rust-lang#97371 (Suggest adding a semicolon to a closure without block)
 - rust-lang#97455 (Stabilize `toowned_clone_into`)
 - rust-lang#97565 (Add doc alias `memset` to `write_bytes`)
 - rust-lang#97569 (Remove `memset` alias from `fill_with`.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5885e6d into rust-lang:master May 31, 2022
@rustbot rustbot added this to the 1.63.0 milestone May 31, 2022
@lukas-code lukas-code deleted the patch-1 branch May 31, 2022 17:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants