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

(#102929) Implement String:leak #102941

Closed
wants to merge 5 commits into from

Conversation

finnbear
Copy link
Contributor

@finnbear finnbear commented Oct 12, 2022

Implementation of String::leak (#102929)

ACP: rust-lang/libs-team#109

Superseded by: #103280

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

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @m-ou-se (or someone else) soon.

Please see the contribution instructions for more information.

@rustbot
Copy link
Collaborator

rustbot commented Oct 12, 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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 12, 2022
@finnbear finnbear mentioned this pull request Oct 12, 2022
4 tasks
@finnbear
Copy link
Contributor Author

@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 Oct 12, 2022
#[cfg(not(no_global_oom_handling))]
#[unstable(feature = "string_leak", issue = "102929")]
#[inline]
pub fn leak<'a>(self) -> &'a mut str {
Copy link
Member

Choose a reason for hiding this comment

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

Is there any reason to use a generic <'a> instead of just 'static here? I believe the only reason we use <'a> for Vec<T> is for situations where T: !'static.

Suggested change
pub fn leak<'a>(self) -> &'a mut str {
pub fn leak(self) -> &'static mut str {

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good idea; as I understand it, variance will still allow the 'static to be used for any 'a

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I think there is another reason. Vec is generic over A: Allocator and this may apply to String in the future. At that point, the generic lifetime would be bounded by that of the allocator. I don't know if adding the generic lifetime later would be a breaking change. Thoughts?

image
image

@m-ou-se m-ou-se 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 Oct 18, 2022
@finnbear finnbear requested a review from m-ou-se October 18, 2022 17:37
@finnbear

This comment was marked as resolved.

@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 Oct 18, 2022
@rust-log-analyzer

This comment has been minimized.

@klensy
Copy link
Contributor

klensy commented Oct 19, 2022

https://rustc-dev-guide.rust-lang.org/git.html#no-merge-policy you can squash commits.

finnbear added a commit to finnbear/rust that referenced this pull request Oct 20, 2022
@finnbear
Copy link
Contributor Author

In an attempt to undo the merge commit, I messed up git beyond my ability to repair it, so this PR is superseded by #103280

@finnbear finnbear closed this Oct 20, 2022
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-llvm-13 failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
error: make failed
status: exit status: 2
command: "make"
--- stdout -------------------------------
LD_LIBRARY_PATH="/checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make-fulldeps/alloc-no-oom-handling/alloc-no-oom-handling:/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-bootstrap-tools/x86_64-unknown-linux-gnu/release/deps:/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/lib" '/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc' --out-dir /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make-fulldeps/alloc-no-oom-handling/alloc-no-oom-handling -L /checkout/obj/build/x86_64-unknown-linux-gnu/test/run-make-fulldeps/alloc-no-oom-handling/alloc-no-oom-handling  --edition=2021 -Dwarnings --crate-type=rlib ../../../../library/alloc/src/lib.rs --cfg no_global_oom_handling
--- stderr -------------------------------
error[E0425]: cannot find function `from_utf8_unchecked_mut` in this scope
    --> ../../../../library/alloc/src/string.rs:1879:18
     |
     |
1879 |         unsafe { from_utf8_unchecked_mut(slice) }
     |
help: consider importing one of these items
     |
47   | use core::str::from_utf8_unchecked_mut;

Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Oct 22, 2022
…htriplett

(rust-lang#102929) Implement `String::leak` (attempt 2)

Implementation of `String::leak` (rust-lang#102929)

ACP: rust-lang/libs-team#109

Supersedes rust-lang#102941 (see previous reviews there)

`@rustbot` label +T-libs-api -T-libs
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Oct 22, 2022
…htriplett

(rust-lang#102929) Implement `String::leak` (attempt 2)

Implementation of `String::leak` (rust-lang#102929)

ACP: rust-lang/libs-team#109

Supersedes rust-lang#102941 (see previous reviews there)

``@rustbot`` label +T-libs-api -T-libs
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Oct 22, 2022
…htriplett

(rust-lang#102929) Implement `String::leak` (attempt 2)

Implementation of `String::leak` (rust-lang#102929)

ACP: rust-lang/libs-team#109

Supersedes rust-lang#102941 (see previous reviews there)

```@rustbot``` label +T-libs-api -T-libs
@est31 est31 mentioned this pull request Mar 31, 2023
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. 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.

8 participants