float and int vars are trivially copy

This commit is contained in:
Michael Goulet 2022-10-05 03:13:32 +00:00
parent edabf59ca4
commit a010df9389
2 changed files with 8 additions and 1 deletions

View file

@ -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 // 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;`. // 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) { if assignee_place.place.base_ty.needs_drop(self.tcx, self.param_env) {
self.places self.places
.borrowed .borrowed

View file

@ -2205,7 +2205,10 @@ impl<'tcx> Ty<'tcx> {
// These aren't even `Clone` // These aren't even `Clone`
ty::Str | ty::Slice(..) | ty::Foreign(..) | ty::Dynamic(..) => false, 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. // The voldemort ZSTs are fine.
ty::FnDef(..) => true, ty::FnDef(..) => true,