Skip to content

Commit 9a9a232

Browse files
authored
Rollup merge of rust-lang#95276 - FoseFx:clippy_trim_split_whitespace, r=flip1995
add diagnostic items for clippy's `trim_split_whitespace` Adding the following diagnostic items: * str_split_whitespace, * str_trim, * str_trim_start, * str_trim_end They are needed for rust-lang/rust-clippy#8575 r? `@flip1995`
2 parents be3ce2f + 71f4a75 commit 9a9a232

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
@@ -904,6 +904,7 @@ impl str {
904904
#[must_use = "this returns the split string as an iterator, \
905905
without modifying the original"]
906906
#[stable(feature = "split_whitespace", since = "1.1.0")]
907+
#[cfg_attr(not(test), rustc_diagnostic_item = "str_split_whitespace")]
907908
#[inline]
908909
pub fn split_whitespace(&self) -> SplitWhitespace<'_> {
909910
SplitWhitespace { inner: self.split(IsWhitespace).filter(IsNotEmpty) }
@@ -1846,6 +1847,7 @@ impl str {
18461847
#[must_use = "this returns the trimmed string as a slice, \
18471848
without modifying the original"]
18481849
#[stable(feature = "rust1", since = "1.0.0")]
1850+
#[cfg_attr(not(test), rustc_diagnostic_item = "str_trim")]
18491851
pub fn trim(&self) -> &str {
18501852
self.trim_matches(|c: char| c.is_whitespace())
18511853
}
@@ -1884,6 +1886,7 @@ impl str {
18841886
#[must_use = "this returns the trimmed string as a new slice, \
18851887
without modifying the original"]
18861888
#[stable(feature = "trim_direction", since = "1.30.0")]
1889+
#[cfg_attr(not(test), rustc_diagnostic_item = "str_trim_start")]
18871890
pub fn trim_start(&self) -> &str {
18881891
self.trim_start_matches(|c: char| c.is_whitespace())
18891892
}
@@ -1922,6 +1925,7 @@ impl str {
19221925
#[must_use = "this returns the trimmed string as a new slice, \
19231926
without modifying the original"]
19241927
#[stable(feature = "trim_direction", since = "1.30.0")]
1928+
#[cfg_attr(not(test), rustc_diagnostic_item = "str_trim_end")]
19251929
pub fn trim_end(&self) -> &str {
19261930
self.trim_end_matches(|c: char| c.is_whitespace())
19271931
}

0 commit comments

Comments
 (0)