From 1765587846ac9bee95f4f293862b0aae9b8ff4ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Christopher=20K=C3=B6hl?= Date: Wed, 5 Oct 2022 21:42:16 +0200 Subject: [PATCH] Only track (trivially) freeze types --- compiler/rustc_middle/src/ty/util.rs | 2 +- compiler/rustc_mir_dataflow/src/value_analysis.rs | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_middle/src/ty/util.rs b/compiler/rustc_middle/src/ty/util.rs index f72e236eda1..6cbdac2a8cb 100644 --- a/compiler/rustc_middle/src/ty/util.rs +++ b/compiler/rustc_middle/src/ty/util.rs @@ -849,7 +849,7 @@ pub fn is_freeze(self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> bool /// /// Returning true means the type is known to be `Freeze`. Returning /// `false` means nothing -- could be `Freeze`, might not be. - fn is_trivially_freeze(self) -> bool { + pub fn is_trivially_freeze(self) -> bool { match self.kind() { ty::Int(_) | ty::Uint(_) diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 510856da92f..766a659adca 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -674,7 +674,11 @@ fn register_with_ty<'tcx>( return Err(()); } - // FIXME: Check that the place is `Freeze`. + if !ty.is_trivially_freeze() { + // Due to the way we deal with shared references, only `Freeze` types may be tracked. + // We are a little bit to restrictive here by only allowing trivially `Freeze` types. + return Err(()); + } let place = self.make_place(local, projection)?;