Skip to content

Commit ebcf8a3

Browse files
authored
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".
2 parents 319f080 + c9de094 commit ebcf8a3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

core/src/str/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@ impl str {
238238
/// assert_eq!("💖", sparkle_heart);
239239
/// ```
240240
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
241+
#[rustc_diagnostic_item = "str_inherent_from_utf8"]
241242
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
242243
converts::from_utf8(v)
243244
}
@@ -274,6 +275,7 @@ impl str {
274275
/// errors that can be returned.
275276
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
276277
#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")]
278+
#[rustc_diagnostic_item = "str_inherent_from_utf8_mut"]
277279
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
278280
converts::from_utf8_mut(v)
279281
}
@@ -306,6 +308,7 @@ impl str {
306308
#[inline]
307309
#[must_use]
308310
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
311+
#[rustc_diagnostic_item = "str_inherent_from_utf8_unchecked"]
309312
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
310313
// SAFETY: converts::from_utf8_unchecked has the same safety requirements as this function.
311314
unsafe { converts::from_utf8_unchecked(v) }
@@ -331,6 +334,7 @@ impl str {
331334
#[inline]
332335
#[must_use]
333336
#[unstable(feature = "inherent_str_constructors", issue = "131114")]
337+
#[rustc_diagnostic_item = "str_inherent_from_utf8_unchecked_mut"]
334338
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {
335339
// SAFETY: converts::from_utf8_unchecked_mut has the same safety requirements as this function.
336340
unsafe { converts::from_utf8_unchecked_mut(v) }

0 commit comments

Comments
 (0)