Skip to content

Commit 27cfafe

Browse files
committed
Add invalid_from_utf8 analogous to invalid_from_utf8_unchecked
1 parent b5b6607 commit 27cfafe

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

core/src/str/converts.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ use super::Utf8Error;
8484
#[stable(feature = "rust1", since = "1.0.0")]
8585
#[rustc_const_stable(feature = "const_str_from_utf8_shared", since = "1.63.0")]
8686
#[rustc_allow_const_fn_unstable(str_internals)]
87+
#[rustc_diagnostic_item = "str_from_utf8"]
8788
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
8889
// FIXME: This should use `?` again, once it's `const`
8990
match run_utf8_validation(v) {
@@ -127,6 +128,7 @@ pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
127128
/// errors that can be returned.
128129
#[stable(feature = "str_mut_extras", since = "1.20.0")]
129130
#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")]
131+
#[rustc_diagnostic_item = "str_from_utf8_mut"]
130132
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
131133
// This should use `?` again, once it's `const`
132134
match run_utf8_validation(v) {

0 commit comments

Comments
 (0)