Skip to content

Commit 005aa45

Browse files
Mini optimization in restrict_precision_for_drop_types
Avoid calling `type_is_copy_modulo_regions` if not necessary.
1 parent 923c95c commit 005aa45

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

‎compiler/rustc_hir_typeck/src/upvar.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2318,9 +2318,9 @@ fn restrict_precision_for_drop_types<'a, 'tcx>(
23182318
mut place: Place<'tcx>,
23192319
mut curr_mode: ty::UpvarCapture,
23202320
) -> (Place<'tcx>, ty::UpvarCapture) {
2321-
let is_copy_type = fcx.infcx.type_is_copy_modulo_regions(fcx.param_env, place.ty());
2322-
2323-
if let (false, UpvarCapture::ByValue) = (is_copy_type, curr_mode) {
2321+
if curr_mode == UpvarCapture::ByValue
2322+
&& !fcx.infcx.type_is_copy_modulo_regions(fcx.param_env, place.ty())
2323+
{
23242324
for i in 0..place.projections.len() {
23252325
match place.ty_before_projection(i).kind() {
23262326
ty::Adt(def, _) if def.destructor(fcx.tcx).is_some() => {

0 commit comments

Comments
 (0)