about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMara Bos <m-ou.se@m-ou.se>2020-11-01 11:53:29 +0100
committerGitHub <noreply@github.com>2020-11-01 11:53:29 +0100
commit835310e3cce57711ea7c5f0567df46d8a4cfb579 (patch)
treefb40a4a74e05a7e0e4cf39fd30cfe1b01fe88cb1
parent1d5b7c3c96a86c96f1fbf1441475028df94d165a (diff)
parentcc850ecba0641f0ec56507ee656ad9a301705c83 (diff)
downloadrust-835310e3cce57711ea7c5f0567df46d8a4cfb579.tar.gz
rust-835310e3cce57711ea7c5f0567df46d8a4cfb579.zip
Rollup merge of #78073 - fusion-engineering-forks:inline, r=eddyb
Add #[inline] to some functions in core::str.

Almost all str functions already had #[inline].
-rw-r--r--library/core/src/str/error.rs2
-rw-r--r--library/core/src/str/iter.rs1
-rw-r--r--library/core/src/str/mod.rs9
3 files changed, 12 insertions, 0 deletions
diff --git a/library/core/src/str/error.rs b/library/core/src/str/error.rs
index 427f720d68c..ccf7b20285c 100644
--- a/library/core/src/str/error.rs
+++ b/library/core/src/str/error.rs
@@ -72,6 +72,7 @@ impl Utf8Error {
     /// assert_eq!(1, error.valid_up_to());
     /// ```
     #[stable(feature = "utf8_error", since = "1.5.0")]
+    #[inline]
     pub fn valid_up_to(&self) -> usize {
         self.valid_up_to
     }
@@ -92,6 +93,7 @@ impl Utf8Error {
     ///
     /// [U+FFFD]: ../../std/char/constant.REPLACEMENT_CHARACTER.html
     #[stable(feature = "utf8_error_error_len", since = "1.20.0")]
+    #[inline]
     pub fn error_len(&self) -> Option<usize> {
         self.error_len.map(|len| len as usize)
     }
diff --git a/library/core/src/str/iter.rs b/library/core/src/str/iter.rs
index bee86df520c..28cd350019e 100644
--- a/library/core/src/str/iter.rs
+++ b/library/core/src/str/iter.rs
@@ -326,6 +326,7 @@ unsafe impl TrustedLen for Bytes<'_> {}
 #[doc(hidden)]
 #[unstable(feature = "trusted_random_access", issue = "none")]
 unsafe impl TrustedRandomAccess for Bytes<'_> {
+    #[inline]
     fn may_have_side_effect() -> bool {
         false
     }
diff --git a/library/core/src/str/mod.rs b/library/core/src/str/mod.rs
index b36d9f5c388..ab0c8739330 100644
--- a/library/core/src/str/mod.rs
+++ b/library/core/src/str/mod.rs
@@ -1712,6 +1712,7 @@ impl str {
     ///
     /// assert_eq!("Hello\tworld", s.trim());
     /// ```
+    #[inline]
     #[must_use = "this returns the trimmed string as a slice, \
                   without modifying the original"]
     #[stable(feature = "rust1", since = "1.0.0")]
@@ -1749,6 +1750,7 @@ impl str {
     /// let s = "  עברית  ";
     /// assert!(Some('ע') == s.trim_start().chars().next());
     /// ```
+    #[inline]
     #[must_use = "this returns the trimmed string as a new slice, \
                   without modifying the original"]
     #[stable(feature = "trim_direction", since = "1.30.0")]
@@ -1786,6 +1788,7 @@ impl str {
     /// let s = "  עברית  ";
     /// assert!(Some('ת') == s.trim_end().chars().rev().next());
     /// ```
+    #[inline]
     #[must_use = "this returns the trimmed string as a new slice, \
                   without modifying the original"]
     #[stable(feature = "trim_direction", since = "1.30.0")]
@@ -1824,6 +1827,7 @@ impl str {
     /// let s = "  עברית";
     /// assert!(Some('ע') == s.trim_left().chars().next());
     /// ```
+    #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     #[rustc_deprecated(
         since = "1.33.0",
@@ -1865,6 +1869,7 @@ impl str {
     /// let s = "עברית  ";
     /// assert!(Some('ת') == s.trim_right().chars().rev().next());
     /// ```
+    #[inline]
     #[stable(feature = "rust1", since = "1.0.0")]
     #[rustc_deprecated(
         since = "1.33.0",
@@ -2260,6 +2265,7 @@ impl str {
     /// assert_eq!("GRüßE, JüRGEN ❤", s);
     /// ```
     #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
+    #[inline]
     pub fn make_ascii_uppercase(&mut self) {
         // SAFETY: safe because we transmute two types with the same layout.
         let me = unsafe { self.as_bytes_mut() };
@@ -2286,6 +2292,7 @@ impl str {
     /// assert_eq!("grÜße, jÜrgen ❤", s);
     /// ```
     #[stable(feature = "ascii_methods_on_intrinsics", since = "1.23.0")]
+    #[inline]
     pub fn make_ascii_lowercase(&mut self) {
         // SAFETY: safe because we transmute two types with the same layout.
         let me = unsafe { self.as_bytes_mut() };
@@ -2423,6 +2430,7 @@ impl AsRef<[u8]> for str {
 #[stable(feature = "rust1", since = "1.0.0")]
 impl Default for &str {
     /// Creates an empty str
+    #[inline]
     fn default() -> Self {
         ""
     }
@@ -2431,6 +2439,7 @@ impl Default for &str {
 #[stable(feature = "default_mut_str", since = "1.28.0")]
 impl Default for &mut str {
     /// Creates an empty mutable str
+    #[inline]
     fn default() -> Self {
         // SAFETY: The empty string is valid UTF-8.
         unsafe { from_utf8_unchecked_mut(&mut []) }