cleanup: don't clone types that are Copy

This commit is contained in:
Matthias Krüger 2024-09-29 13:31:30 +02:00
parent 9903b256a2
commit 71cd918dc7
5 changed files with 13 additions and 18 deletions

View file

@ -223,14 +223,14 @@ pub(crate) fn coroutine_by_move_body_def_id<'tcx>(
// Inherited from the by-ref coroutine.
body_def.codegen_fn_attrs(tcx.codegen_fn_attrs(coroutine_def_id).clone());
body_def.constness(tcx.constness(coroutine_def_id).clone());
body_def.coroutine_kind(tcx.coroutine_kind(coroutine_def_id).clone());
body_def.constness(tcx.constness(coroutine_def_id));
body_def.coroutine_kind(tcx.coroutine_kind(coroutine_def_id));
body_def.def_ident_span(tcx.def_ident_span(coroutine_def_id));
body_def.def_span(tcx.def_span(coroutine_def_id));
body_def.explicit_predicates_of(tcx.explicit_predicates_of(coroutine_def_id).clone());
body_def.explicit_predicates_of(tcx.explicit_predicates_of(coroutine_def_id));
body_def.generics_of(tcx.generics_of(coroutine_def_id).clone());
body_def.param_env(tcx.param_env(coroutine_def_id).clone());
body_def.predicates_of(tcx.predicates_of(coroutine_def_id).clone());
body_def.param_env(tcx.param_env(coroutine_def_id));
body_def.predicates_of(tcx.predicates_of(coroutine_def_id));
// The type of the coroutine is the `by_move_coroutine_ty`.
body_def.type_of(ty::EarlyBinder::bind(by_move_coroutine_ty));

View file

@ -185,15 +185,14 @@ impl<'tcx> MutVisitor<'tcx> for LocalReplacer<'tcx> {
&& let Some(local) = place.as_local()
&& local == self.local
{
let const_op = self
let const_op = *self
.operand
.as_ref()
.unwrap_or_else(|| {
bug!("the operand was already stolen");
})
.constant()
.unwrap()
.clone();
.unwrap();
var_debug_info.value = VarDebugInfoContents::Const(const_op);
}
}