Skip to content

Commit a152820

Browse files
authored
Rollup merge of rust-lang#128170 - saethlin:clone-fn, r=compiler-errors
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
2 parents cb8f69b + 8488ae6 commit a152820

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

core/src/clone.rs

+3
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,9 @@ pub trait Clone: Sized {
160160
/// ```
161161
#[stable(feature = "rust1", since = "1.0.0")]
162162
#[must_use = "cloning is often expensive and is not expected to have side effects"]
163+
// Clone::clone is special because the compiler generates MIR to implement it for some types.
164+
// See InstanceKind::CloneShim.
165+
#[cfg_attr(not(bootstrap), lang = "clone_fn")]
163166
fn clone(&self) -> Self;
164167

165168
/// Performs copy-assignment from `source`.

0 commit comments

Comments
 (0)