-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Tracking Issue for inherent_str_constructors
#131114
Comments
…rs, r=jhpratt implement inherent str constructors implement rust-lang#131114 this implements - str::from_utf8 - str::from_utf8_mut - str::from_utf8_unchecked - str::from_utf8_unchecked_mut i left `std::str::from_raw_parts` and `std::str::from_raw_parts_mut` out of this as those are unstable and were not mentioned by the tracking issue or the original pull request, but i can add those here as well. i was also unsure of what to do with the `rustc_const_(un)stable` attributes: i removed the `#[rustc_const_stable]` attribute from `str::from_utf8`, `str::from_utf8_unchecked` and `str::from_utf8_unchecked_mut`, and left the`#[rust_const_unstable]` in `str::from_utf8_mut` (btw why is that one not const stable yet with rust-lang#57349 merged?). is there a way to redirect users to the stable `std::str::from_utf8` instead of only saying "hey this is unstable"? for now i just removed the check for `str::from_utf8` in the test in `tests/ui/suggestions/suggest-std-when-using-type.rs`.
Rollup merge of rust-lang#136517 - m4rch3n1ng:inherent-str-constructors, r=jhpratt implement inherent str constructors implement rust-lang#131114 this implements - str::from_utf8 - str::from_utf8_mut - str::from_utf8_unchecked - str::from_utf8_unchecked_mut i left `std::str::from_raw_parts` and `std::str::from_raw_parts_mut` out of this as those are unstable and were not mentioned by the tracking issue or the original pull request, but i can add those here as well. i was also unsure of what to do with the `rustc_const_(un)stable` attributes: i removed the `#[rustc_const_stable]` attribute from `str::from_utf8`, `str::from_utf8_unchecked` and `str::from_utf8_unchecked_mut`, and left the`#[rust_const_unstable]` in `str::from_utf8_mut` (btw why is that one not const stable yet with rust-lang#57349 merged?). is there a way to redirect users to the stable `std::str::from_utf8` instead of only saying "hey this is unstable"? for now i just removed the check for `str::from_utf8` in the test in `tests/ui/suggestions/suggest-std-when-using-type.rs`.
I would like to request stabilization of these constructors. Yes, they only landed in nightly a few days ago, but there shouldn't be any need to gather more experience with them since they're identical in every way to existing APIs that have been stable forever, except not requiring an import of the Implementation history
API summaryimpl str {
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error>;
pub fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error>;
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str;
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str;
}
Experience reportAs @joshtriplett wrote on the ACP:
I just tried it on a personal project, removing four imports of |
@rfcbot merge |
Team member @joshtriplett 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. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
One concern: these new methods bypass the deny-by-default There are also a few clippy lints that use the same diagnostic items, somebody should at least open an issue there so they can update. Edit: Thanks GrigorenkoPV for handling rustc, opened rust-lang/rust-clippy#14254 for clippy. |
…Urgau `invalid_from_utf8[_unchecked]`: also lint inherent methods Addressing rust-lang#131114 (comment) Also corrected a typo: "_an_ invalid literal", not "_a_ invalid literal".
Rollup merge of rust-lang#137101 - GrigorenkoPV:str-inherent-lint, r=Urgau `invalid_from_utf8[_unchecked]`: also lint inherent methods Addressing rust-lang#131114 (comment) Also corrected a typo: "_an_ invalid literal", not "_a_ invalid literal".
`invalid_from_utf8[_unchecked]`: also lint inherent methods Addressing rust-lang/rust#131114 (comment) Also corrected a typo: "_an_ invalid literal", not "_a_ invalid literal".
…r=Amanieu fix docs for inherent str constructors related to rust-lang#131114 when implementing inherent str constructors in rust-lang#136517, i forgot to change the docs, so the code examples still imported the `std::str` module and used the constructor from there, instead of using "itself" (the inherent constructor).
…r=Amanieu fix docs for inherent str constructors related to rust-lang#131114 when implementing inherent str constructors in rust-lang#136517, i forgot to change the docs, so the code examples still imported the `std::str` module and used the constructor from there, instead of using "itself" (the inherent constructor).
…r=Amanieu fix docs for inherent str constructors related to rust-lang#131114 when implementing inherent str constructors in rust-lang#136517, i forgot to change the docs, so the code examples still imported the `std::str` module and used the constructor from there, instead of using "itself" (the inherent constructor).
Rollup merge of rust-lang#137126 - m4rch3n1ng:fix-inherent-str-docs, r=Amanieu fix docs for inherent str constructors related to rust-lang#131114 when implementing inherent str constructors in rust-lang#136517, i forgot to change the docs, so the code examples still imported the `std::str` module and used the constructor from there, instead of using "itself" (the inherent constructor).
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. |
inherent_str_constructors
inherent_str_constructors
Rollup merge of rust-lang#137277 - m4rch3n1ng:stabilize-inherent-str-constructors, r=tgross35 stabilize `inherent_str_constructors` fcp done in rust-lang#131114 (comment). tracking issue: rust-lang#131114 closes: rust-lang#131114
`invalid_from_utf8[_unchecked]`: also lint inherent methods Addressing rust-lang/rust#131114 (comment) Also corrected a typo: "_an_ invalid literal", not "_a_ invalid literal".
…ors, r=tgross35 stabilize `inherent_str_constructors` fcp done in rust-lang/rust#131114 (comment). tracking issue: #131114 closes: #131114
`invalid_from_utf8[_unchecked]`: also lint inherent methods Addressing rust-lang/rust#131114 (comment) Also corrected a typo: "_an_ invalid literal", not "_a_ invalid literal".
Feature gate:
#![feature(inherent_str_constructors)]
This is a tracking issue for inherent
str
constructors.Public API
str::from_utf8
str::from_utf8_mut
str::from_utf8_unchecked
str::from_utf8_unchecked_mut
Steps / History
core::str::from_utf8*
methods available on thestr
type libs-team#398Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: