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

Rename <*{mut,const} T>::as_{const,mut} to cast_ #98174

Merged
merged 1 commit into from
Jul 22, 2022

Conversation

Kixunil
Copy link
Contributor

@Kixunil Kixunil commented Jun 16, 2022

This renames the methods to use the cast_ prefix instead of as_ to
make it more readable and avoid confusion with <*mut T>::as_mut()
which is unsafe and returns a reference.

Sorry, didn't notice ACP process exists, opened rust-lang/libs-team#51

See #92675

@rustbot rustbot added the T-libs Relevant to the library team, which will review and decide on the PR/issue. label Jun 16, 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 @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. 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? @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 Jun 16, 2022
@Kixunil
Copy link
Contributor Author

Kixunil commented Jun 16, 2022

@rustbot label +T-libs-api -T-libs

@rustbot rustbot added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. and removed T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jun 16, 2022
@scottmcm scottmcm added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 16, 2022
@scottmcm
Copy link
Member

I marked this as blocked because ACP, though I'm new to ACP too so I'm not sure what the process is here. I probably would have been fine with just approving it because nightly, but let's see what the libs-api folks say.

@CryZe
Copy link
Contributor

CryZe commented Jun 16, 2022

cast_mut reads a lot worse to me. When I opened this PR not knowing what it's about, I was expecting cast_mut to be a variant of cast() (which casts from *T to *U) that only applies to mut pointers or something (like lots of other methods that have a _mut suffix). It would read a lot better as cast_to_mut or just to_mut.

@Kixunil
Copy link
Contributor Author

Kixunil commented Jun 17, 2022

@CryZe good point! to_mut/to_const sounds good, I'll change it if others agree.

@josephlr
Copy link
Contributor

@CryZe good point! to_mut/to_const sounds good, I'll change it if others agree.

As someone who liked the cast_mut / cast_const naming, I think the to_mut/to_const naming is better

@scottmcm scottmcm removed S-waiting-on-team Status: Awaiting decision from the relevant subteam (see the T-<team> label). S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. labels Jul 20, 2022
@scottmcm
Copy link
Member

scottmcm commented Jul 20, 2022

With the ACP decided, please update this PR and I'll approve it!

@rustbot author

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jul 20, 2022
@Kixunil Kixunil force-pushed the rename_ptr_as_mut_const_to_cast branch from f1deafa to 5934cab Compare July 21, 2022 12:27
@rustbot
Copy link
Collaborator

rustbot commented Jul 21, 2022

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 @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. 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

@Kixunil Kixunil requested a review from scottmcm July 21, 2022 14:01
@Kixunil
Copy link
Contributor Author

Kixunil commented Jul 21, 2022

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jul 21, 2022
@scottmcm scottmcm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 21, 2022
This renames the methods to use the `cast_` prefix instead of `as_` to
make it more readable and avoid confusion with `<*mut T>::as_mut()`
which is `unsafe` and returns a reference.

See rust-lang#92675
@Kixunil Kixunil force-pushed the rename_ptr_as_mut_const_to_cast branch from 5934cab to eb5acc9 Compare July 21, 2022 16:30
@scottmcm
Copy link
Member

Thanks for the idea & PR!

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 21, 2022

📌 Commit eb5acc9 has been approved by scottmcm

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 21, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Jul 22, 2022
…cast, r=scottmcm

Rename `<*{mut,const} T>::as_{const,mut}` to `cast_`

This renames the methods to use the `cast_` prefix instead of `as_` to
make it more readable and avoid confusion with `<*mut T>::as_mut()`
which is `unsafe` and returns a reference.

Sorry, didn't notice ACP process exists, opened rust-lang/libs-team#51

See rust-lang#92675
This was referenced Jul 22, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 22, 2022
Rollup of 6 pull requests

Successful merges:

 - rust-lang#98174 (Rename `<*{mut,const} T>::as_{const,mut}` to `cast_`)
 - rust-lang#98868 (Fix unreachable coverage generation for inlined functions)
 - rust-lang#99393 (feat: omit suffixes in const generics (e.g. `1_i32`))
 - rust-lang#99423 (Group CSS font rule)
 - rust-lang#99539 (Improve suggestions for returning binding)
 - rust-lang#99579 (Add same warning to Result::expect as Result::unwrap)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit ad31d5c into rust-lang:master Jul 22, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 22, 2022
@Kixunil Kixunil deleted the rename_ptr_as_mut_const_to_cast branch July 22, 2022 09:51
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-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.

7 participants