Skip to content

Commit e0e4765

Browse files
committed
address comments
1 parent 5f6b012 commit e0e4765

File tree

6 files changed

+5
-39
lines changed

6 files changed

+5
-39
lines changed

compiler/rustc_feature/src/unstable.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,8 +527,6 @@ declare_features! (
527527
(unstable, import_trait_associated_functions, "CURRENT_RUSTC_VERSION", Some(134691)),
528528
/// Allows associated types in inherent impls.
529529
(incomplete, inherent_associated_types, "1.52.0", Some(8995)),
530-
/// Adds `from_utf8*` functions as inherent methods on the `str` type.
531-
(unstable, inherent_str_constructors, "1.82.0", Some(131114)),
532530
/// Allow anonymous constants from an inline `const` block in pattern position
533531
(unstable, inline_const_pat, "1.58.0", Some(76001)),
534532
/// Allows using `pointer` and `reference` in intra-doc links

compiler/rustc_span/src/symbol.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1110,7 +1110,6 @@ symbols! {
11101110
infer_outlives_requirements,
11111111
infer_static_outlives_requirements,
11121112
inherent_associated_types,
1113-
inherent_str_constructors,
11141113
inherit,
11151114
inlateout,
11161115
inline,

library/core/src/str/converts.rs

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ use crate::ptr;
8282
/// ```
8383
#[stable(feature = "rust1", since = "1.0.0")]
8484
#[rustc_const_stable(feature = "const_str_from_utf8_shared", since = "1.63.0")]
85+
#[rustc_diagnostic_item = "str_from_utf8"]
8586
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
8687
str::from_utf8(v)
8788
}
@@ -118,15 +119,9 @@ pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
118119
/// errors that can be returned.
119120
#[stable(feature = "str_mut_extras", since = "1.20.0")]
120121
#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")]
122+
#[rustc_diagnostic_item = "str_from_utf8_mut"]
121123
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
122-
// FIXME(const-hack): This should use `?` again, once it's `const`
123-
match super::run_utf8_validation(v) {
124-
Ok(_) => {
125-
// SAFETY: validation succeeded.
126-
Ok(unsafe { str::from_utf8_unchecked_mut(v) })
127-
}
128-
Err(err) => Err(err),
129-
}
124+
str::from_utf8_mut(v)
130125
}
131126

132127
/// Converts a slice of bytes to a string slice without checking
@@ -158,6 +153,7 @@ pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
158153
#[must_use]
159154
#[stable(feature = "rust1", since = "1.0.0")]
160155
#[rustc_const_stable(feature = "const_str_from_utf8_unchecked", since = "1.55.0")]
156+
#[rustc_diagnostic_item = "from_utf8_unchecked"]
161157
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
162158
// SAFETY: same requirements
163159
unsafe { str::from_utf8_unchecked(v) }
@@ -184,6 +180,7 @@ pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
184180
#[must_use]
185181
#[stable(feature = "str_mut_extras", since = "1.20.0")]
186182
#[rustc_const_stable(feature = "const_str_from_utf8_unchecked_mut", since = "1.83.0")]
183+
#[rustc_diagnostic_item = "from_utf8_unchecked_mut"]
187184
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {
188185
// SAFETY: same requirements
189186
unsafe { str::from_utf8_unchecked_mut(v) }

library/core/src/str/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,7 @@ impl str {
233233
/// assert_eq!("💖", sparkle_heart);
234234
/// ```
235235
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
236-
#[rustc_const_unstable(feature = "inherent_str_constructors", issue = "131114")]
237236
#[rustc_allow_const_fn_unstable(str_internals)]
238-
#[rustc_diagnostic_item = "str_from_utf8"]
239237
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
240238
// FIXME(const-hack): This should use `?` again, once it's `const`
241239
match run_utf8_validation(v) {
@@ -278,8 +276,6 @@ impl str {
278276
/// See the docs for [`Utf8Error`] for more details on the kinds of
279277
/// errors that can be returned.
280278
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
281-
#[rustc_const_unstable(feature = "inherent_str_constructors", issue = "131114")]
282-
#[rustc_diagnostic_item = "str_from_utf8_mut"]
283279
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
284280
// FIXME(const-hack): This should use `?` again, once it's `const`
285281
match run_utf8_validation(v) {
@@ -319,8 +315,6 @@ impl str {
319315
#[inline]
320316
#[must_use]
321317
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
322-
#[rustc_const_unstable(feature = "inherent_str_constructors", issue = "131114")]
323-
#[rustc_diagnostic_item = "str_from_utf8_unchecked"]
324318
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
325319
// SAFETY: the caller must guarantee that the bytes `v` are valid UTF-8.
326320
// Also relies on `&str` and `&[u8]` having the same layout.
@@ -347,8 +341,6 @@ impl str {
347341
#[inline]
348342
#[must_use]
349343
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
350-
#[rustc_const_unstable(feature = "inherent_str_constructors", issue = "131114")]
351-
#[rustc_diagnostic_item = "str_from_utf8_unchecked_mut"]
352344
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {
353345
// SAFETY: the caller must guarantee that the bytes `v`
354346
// are valid UTF-8, thus the cast to `*mut str` is safe.

tests/ui/feature-gates/feature-gate-inherent-str-constructors.rs

Lines changed: 0 additions & 6 deletions
This file was deleted.

tests/ui/feature-gates/feature-gate-inherent-str-constructors.stderr

Lines changed: 0 additions & 14 deletions
This file was deleted.

0 commit comments

Comments
 (0)