Skip to content

Commit

Permalink
Rollup merge of rust-lang#128170 - saethlin:clone-fn, r=compiler-errors
Browse files Browse the repository at this point in the history
Make Clone::clone a lang item

I want to absorb all the logic for picking whether an Instance is LocalCopy or GloballyShared into one place. As part of this, I wanted to identify Clone shims inside `cross_crate_inlinable` and found that rather tricky. `@compiler-errors` suggested that I add a lang item for `Clone::clone` because that would produce other cleanups in the compiler.

That sounds good to me, but I have looked and I've only been able to find one.

r? compiler-errors
  • Loading branch information
tgross35 authored Jul 26, 2024
2 parents cb8f69b + 8488ae6 commit a152820
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions core/src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ pub trait Clone: Sized {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[must_use = "cloning is often expensive and is not expected to have side effects"]
// Clone::clone is special because the compiler generates MIR to implement it for some types.
// See InstanceKind::CloneShim.
#[cfg_attr(not(bootstrap), lang = "clone_fn")]
fn clone(&self) -> Self;

/// Performs copy-assignment from `source`.
Expand Down

0 comments on commit a152820

Please sign in to comment.