diff options
| author | Trevor Gross <t.gross35@gmail.com> | 2024-07-26 02:20:31 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-26 02:20:31 -0400 |
| commit | 97eade42f73f9ba081df3811e0ecfd2510e79aff (patch) | |
| tree | e647d3128f14a7e5179e83104b29f756b522ee44 /compiler/rustc_mir_transform/src | |
| parent | 0f1ea63393a9bde75852633790bd65b6d59943a4 (diff) | |
| parent | f4f57bfccb98522f4aaa2942baaa5a381c7d952d (diff) | |
| download | rust-97eade42f73f9ba081df3811e0ecfd2510e79aff.tar.gz rust-97eade42f73f9ba081df3811e0ecfd2510e79aff.zip | |
Rollup merge of #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
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/instsimplify.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index 8209e5e2711..58fdc2d9e45 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -3,6 +3,7 @@ use crate::simplify::simplify_duplicate_switch_targets; use crate::take_array; use rustc_ast::attr; +use rustc_hir::LangItem; use rustc_middle::bug; use rustc_middle::mir::*; use rustc_middle::ty::layout; @@ -271,8 +272,7 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> { return; } - let trait_def_id = self.tcx.trait_of_item(fn_def_id); - if trait_def_id.is_none() || trait_def_id != self.tcx.lang_items().clone_trait() { + if !self.tcx.is_lang_item(fn_def_id, LangItem::CloneFn) { return; } |
