Skip to content

Commit 500db24

Browse files
committed
Make Clone::clone a lang item
1 parent 92c6c03 commit 500db24

File tree

4 files changed

+4
-2
lines changed

4 files changed

+4
-2
lines changed

compiler/rustc_hir/src/lang_items.rs

+1
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ language_item_table! {
413413
EffectsIntersectionOutput, sym::EffectsIntersectionOutput, effects_intersection_output, Target::AssocTy, GenericRequirement::None;
414414
EffectsCompat, sym::EffectsCompat, effects_compat, Target::Trait, GenericRequirement::Exact(1);
415415
EffectsTyCompat, sym::EffectsTyCompat, effects_ty_compat, Target::Trait, GenericRequirement::Exact(1);
416+
CloneFn, sym::clone_fn, clone_fn, Target::Method(MethodKind::Trait { body: false }), GenericRequirement::None;
416417
}
417418

418419
pub enum GenericRequirement {

compiler/rustc_mir_transform/src/instsimplify.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
271271
return;
272272
}
273273

274-
let trait_def_id = self.tcx.trait_of_item(fn_def_id);
275-
if trait_def_id.is_none() || trait_def_id != self.tcx.lang_items().clone_trait() {
274+
if Some(fn_def_id) != self.tcx.lang_items().clone_fn() {
276275
return;
277276
}
278277

compiler/rustc_span/src/symbol.rs

+1
Original file line numberDiff line numberDiff line change
@@ -557,6 +557,7 @@ symbols! {
557557
clobber_abi,
558558
clone,
559559
clone_closures,
560+
clone_fn,
560561
clone_from,
561562
closure,
562563
closure_lifetime_binder,

library/core/src/clone.rs

+1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ 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+
#[cfg_attr(not(bootstrap), lang = "clone_fn")]
163164
fn clone(&self) -> Self;
164165

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

0 commit comments

Comments
 (0)