summaryrefslogtreecommitdiffstats
path: root/library/core/src/str
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /library/core/src/str
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'library/core/src/str')
-rw-r--r--library/core/src/str/converts.rs4
-rw-r--r--library/core/src/str/mod.rs40
2 files changed, 4 insertions, 40 deletions
diff --git a/library/core/src/str/converts.rs b/library/core/src/str/converts.rs
index 5f8748206..0f23cf7ae 100644
--- a/library/core/src/str/converts.rs
+++ b/library/core/src/str/converts.rs
@@ -84,6 +84,7 @@ use super::Utf8Error;
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_str_from_utf8_shared", since = "1.63.0")]
#[rustc_allow_const_fn_unstable(str_internals)]
+#[rustc_diagnostic_item = "str_from_utf8"]
pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
// FIXME: This should use `?` again, once it's `const`
match run_utf8_validation(v) {
@@ -127,6 +128,7 @@ pub const fn from_utf8(v: &[u8]) -> Result<&str, Utf8Error> {
/// errors that can be returned.
#[stable(feature = "str_mut_extras", since = "1.20.0")]
#[rustc_const_unstable(feature = "const_str_from_utf8", issue = "91006")]
+#[rustc_diagnostic_item = "str_from_utf8_mut"]
pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
// This should use `?` again, once it's `const`
match run_utf8_validation(v) {
@@ -167,6 +169,7 @@ pub const fn from_utf8_mut(v: &mut [u8]) -> Result<&mut str, Utf8Error> {
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_stable(feature = "const_str_from_utf8_unchecked", since = "1.55.0")]
+#[rustc_diagnostic_item = "str_from_utf8_unchecked"]
pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
// SAFETY: the caller must guarantee that the bytes `v` are valid UTF-8.
// Also relies on `&str` and `&[u8]` having the same layout.
@@ -194,6 +197,7 @@ pub const unsafe fn from_utf8_unchecked(v: &[u8]) -> &str {
#[must_use]
#[stable(feature = "str_mut_extras", since = "1.20.0")]
#[rustc_const_unstable(feature = "const_str_from_utf8_unchecked_mut", issue = "91005")]
+#[rustc_diagnostic_item = "str_from_utf8_unchecked_mut"]
pub const unsafe fn from_utf8_unchecked_mut(v: &mut [u8]) -> &mut str {
// SAFETY: the caller must guarantee that the bytes `v`
// are valid UTF-8, thus the cast to `*mut str` is safe.
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs
index ef05b25fd..9a93bb729 100644
--- a/library/core/src/str/mod.rs
+++ b/library/core/src/str/mod.rs
@@ -144,8 +144,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let len = "foo".len();
/// assert_eq!(3, len);
@@ -165,8 +163,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let s = "";
/// assert!(s.is_empty());
@@ -311,8 +307,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let bytes = "bors".as_bytes();
/// assert_eq!(b"bors", bytes);
@@ -387,8 +381,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let s = "Hello";
/// let ptr = s.as_ptr();
@@ -570,8 +562,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let s = "Löwe 老虎 Léopard";
///
@@ -649,8 +639,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let s = "Per Martin-Löf";
///
@@ -691,8 +679,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let mut s = "Per Martin-Löf".to_string();
/// {
@@ -840,8 +826,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let mut bytes = "bors".bytes();
///
@@ -1020,8 +1004,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let text = "Zażółć gęślą jaźń";
///
@@ -1050,8 +1032,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let bananas = "bananas";
///
@@ -1077,8 +1057,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let bananas = "bananas";
///
@@ -1103,8 +1081,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let bananas = "bananas";
///
@@ -1463,8 +1439,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let v: Vec<&str> = "A.B.".split_terminator('.').collect();
/// assert_eq!(v, ["A", "B"]);
@@ -1696,8 +1670,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let v: Vec<&str> = "abcXXXabcYYYabc".matches("abc").collect();
/// assert_eq!(v, ["abc", "abc", "abc"]);
@@ -1732,8 +1704,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let v: Vec<&str> = "abcXXXabcYYYabc".rmatches("abc").collect();
/// assert_eq!(v, ["abc", "abc", "abc"]);
@@ -1775,8 +1745,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let v: Vec<_> = "abcXXXabcYYYabc".match_indices("abc").collect();
/// assert_eq!(v, [(0, "abc"), (6, "abc"), (12, "abc")]);
@@ -1817,8 +1785,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let v: Vec<_> = "abcXXXabcYYYabc".rmatch_indices("abc").collect();
/// assert_eq!(v, [(12, "abc"), (6, "abc"), (0, "abc")]);
@@ -1845,8 +1811,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// let s = "\n Hello\tworld\t\n";
///
@@ -2085,8 +2049,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// assert_eq!("11foo1bar11".trim_start_matches('1'), "foo1bar11");
/// assert_eq!("123foo1bar123".trim_start_matches(char::is_numeric), "foo1bar123");
@@ -2232,8 +2194,6 @@ impl str {
///
/// # Examples
///
- /// Basic usage:
- ///
/// ```
/// assert_eq!("11foo1bar11".trim_left_matches('1'), "foo1bar11");
/// assert_eq!("123foo1bar123".trim_left_matches(char::is_numeric), "foo1bar123");