Skip to content

Commit

Permalink
Auto merge of rust-lang#122313 - erikdesjardins:cloned, r=<try>
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
bors committed Mar 10, 2024
2 parents af69f4c + e937802 commit 18157f4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions library/core/src/option.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1857,6 +1857,7 @@ impl<T> Option<&T> {
/// let copied = opt_x.copied();
/// assert_eq!(copied, Some(12));
/// ```
#[inline]
#[must_use = "`self` will be dropped if the result is not used"]
#[stable(feature = "copied", since = "1.35.0")]
#[rustc_const_unstable(feature = "const_option", issue = "67441")]
Expand Down Expand Up @@ -1884,6 +1885,7 @@ impl<T> Option<&T> {
/// let cloned = opt_x.cloned();
/// assert_eq!(cloned, Some(12));
/// ```
#[inline]
#[must_use = "`self` will be dropped if the result is not used"]
#[stable(feature = "rust1", since = "1.0.0")]
pub fn cloned(self) -> Option<T>
Expand All @@ -1910,6 +1912,7 @@ impl<T> Option<&mut T> {
/// let copied = opt_x.copied();
/// assert_eq!(copied, Some(12));
/// ```
#[inline]
#[must_use = "`self` will be dropped if the result is not used"]
#[stable(feature = "copied", since = "1.35.0")]
#[rustc_const_unstable(feature = "const_option_ext", issue = "91930")]
Expand All @@ -1935,6 +1938,7 @@ impl<T> Option<&mut T> {
/// let cloned = opt_x.cloned();
/// assert_eq!(cloned, Some(12));
/// ```
#[inline]
#[must_use = "`self` will be dropped if the result is not used"]
#[stable(since = "1.26.0", feature = "option_ref_mut_cloned")]
pub fn cloned(self) -> Option<T>
Expand Down

0 comments on commit 18157f4

Please sign in to comment.