From a010df9389b4b949da23740100d00658d6a02480 Mon Sep 17 00:00:00 2001 From: Michael Goulet Date: Wed, 5 Oct 2022 03:13:32 +0000 Subject: [PATCH] float and int vars are trivially copy --- .../generator_interior/drop_ranges/record_consumed_borrow.rs | 4 ++++ compiler/rustc_middle/src/ty/sty.rs | 5 ++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_hir_analysis/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs b/compiler/rustc_hir_analysis/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs index e22675e9d5f4..2f68b57a0193 100644 --- a/compiler/rustc_hir_analysis/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs +++ b/compiler/rustc_hir_analysis/src/check/generator_interior/drop_ranges/record_consumed_borrow.rs @@ -198,6 +198,10 @@ impl<'tcx> expr_use_visitor::Delegate<'tcx> for ExprUseDelegate<'tcx> { // If the type being assigned needs dropped, then the mutation counts as a borrow // since it is essentially doing `Drop::drop(&mut x); x = new_value;`. + // + // FIXME(drop-tracking): We need to be more responsible about inference + // variables here, since `needs_drop` is a "raw" type query, i.e. it + // basically requires types to have been fully resolved. if assignee_place.place.base_ty.needs_drop(self.tcx, self.param_env) { self.places .borrowed diff --git a/compiler/rustc_middle/src/ty/sty.rs b/compiler/rustc_middle/src/ty/sty.rs index 646369633133..cf420bafeb12 100644 --- a/compiler/rustc_middle/src/ty/sty.rs +++ b/compiler/rustc_middle/src/ty/sty.rs @@ -2205,7 +2205,10 @@ impl<'tcx> Ty<'tcx> { // These aren't even `Clone` ty::Str | ty::Slice(..) | ty::Foreign(..) | ty::Dynamic(..) => false, - ty::Int(..) | ty::Uint(..) | ty::Float(..) => true, + ty::Infer(ty::InferTy::FloatVar(_) | ty::InferTy::IntVar(_)) + | ty::Int(..) + | ty::Uint(..) + | ty::Float(..) => true, // The voldemort ZSTs are fine. ty::FnDef(..) => true,