Skip to content

Commit

Permalink
Rollup merge of #95276 - FoseFx:clippy_trim_split_whitespace, r=flip1995
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
Dylan-DPC authored Mar 25, 2022
2 parents e039dc8 + 64ad96d commit 3716c42
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1347,6 +1347,10 @@ symbols! {
store,
str,
str_alloc,
str_split_whitespace,
str_trim,
str_trim_end,
str_trim_start,
stringify,
stringify_macro,
struct_field_attributes,
Expand Down
4 changes: 4 additions & 0 deletions library/core/src/str/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,7 @@ impl str {
#[must_use = "this returns the split string as an iterator, \
without modifying the original"]
#[stable(feature = "split_whitespace", since = "1.1.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "str_split_whitespace")]
#[inline]
pub fn split_whitespace(&self) -> SplitWhitespace<'_> {
SplitWhitespace { inner: self.split(IsWhitespace).filter(IsNotEmpty) }
Expand Down Expand Up @@ -1846,6 +1847,7 @@ impl str {
#[must_use = "this returns the trimmed string as a slice, \
without modifying the original"]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "str_trim")]
pub fn trim(&self) -> &str {
self.trim_matches(|c: char| c.is_whitespace())
}
Expand Down Expand Up @@ -1884,6 +1886,7 @@ impl str {
#[must_use = "this returns the trimmed string as a new slice, \
without modifying the original"]
#[stable(feature = "trim_direction", since = "1.30.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "str_trim_start")]
pub fn trim_start(&self) -> &str {
self.trim_start_matches(|c: char| c.is_whitespace())
}
Expand Down Expand Up @@ -1922,6 +1925,7 @@ impl str {
#[must_use = "this returns the trimmed string as a new slice, \
without modifying the original"]
#[stable(feature = "trim_direction", since = "1.30.0")]
#[cfg_attr(not(test), rustc_diagnostic_item = "str_trim_end")]
pub fn trim_end(&self) -> &str {
self.trim_end_matches(|c: char| c.is_whitespace())
}
Expand Down

0 comments on commit 3716c42

Please sign in to comment.