Skip to content

Commit 18157f4

Browse files
committed
Auto merge of rust-lang#122313 - erikdesjardins:cloned, r=<try>
Add #[inline] to Option::copied/cloned In rust-lang#121665 (comment), I noticed that `Option::cloned` stopped being inlined in some backtrace code. Let's see if this helps. r? `@ghost`
2 parents af69f4c + e937802 commit 18157f4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

library/core/src/option.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1857,6 +1857,7 @@ impl<T> Option<&T> {
18571857
/// let copied = opt_x.copied();
18581858
/// assert_eq!(copied, Some(12));
18591859
/// ```
1860+
#[inline]
18601861
#[must_use = "`self` will be dropped if the result is not used"]
18611862
#[stable(feature = "copied", since = "1.35.0")]
18621863
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
@@ -1884,6 +1885,7 @@ impl<T> Option<&T> {
18841885
/// let cloned = opt_x.cloned();
18851886
/// assert_eq!(cloned, Some(12));
18861887
/// ```
1888+
#[inline]
18871889
#[must_use = "`self` will be dropped if the result is not used"]
18881890
#[stable(feature = "rust1", since = "1.0.0")]
18891891
pub fn cloned(self) -> Option<T>
@@ -1910,6 +1912,7 @@ impl<T> Option<&mut T> {
19101912
/// let copied = opt_x.copied();
19111913
/// assert_eq!(copied, Some(12));
19121914
/// ```
1915+
#[inline]
19131916
#[must_use = "`self` will be dropped if the result is not used"]
19141917
#[stable(feature = "copied", since = "1.35.0")]
19151918
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
@@ -1935,6 +1938,7 @@ impl<T> Option<&mut T> {
19351938
/// let cloned = opt_x.cloned();
19361939
/// assert_eq!(cloned, Some(12));
19371940
/// ```
1941+
#[inline]
19381942
#[must_use = "`self` will be dropped if the result is not used"]
19391943
#[stable(since = "1.26.0", feature = "option_ref_mut_cloned")]
19401944
pub fn cloned(self) -> Option<T>

0 commit comments

Comments
 (0)