From bb1639769ec2ef5ff297986f63b2954091c9c95c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Christopher=20K=C3=B6hl?= Date: Wed, 31 Aug 2022 00:56:39 +0200 Subject: [PATCH] Clarify registration and tracking of references --- compiler/rustc_mir_dataflow/src/value_analysis.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_mir_dataflow/src/value_analysis.rs b/compiler/rustc_mir_dataflow/src/value_analysis.rs index 15aa605021c8..662ab0bdfa52 100644 --- a/compiler/rustc_mir_dataflow/src/value_analysis.rs +++ b/compiler/rustc_mir_dataflow/src/value_analysis.rs @@ -7,8 +7,14 @@ //! override some of the `handle_` methods. For an example, see `ConstAnalysis`. //! //! An implementation must also provide a [`Map`]. Before the anaylsis begins, all places that -//! should be tracked during the analysis must be registered. The set of tracked places cannot be -//! changed during the analysis. +//! should be tracked during the analysis must be registered. Currently, the projections of these +//! places may only contain derefs, fields and downcasts (otherwise registration fails). During the +//! analysis, no new places can be registered. +//! +//! Note that if you want to track values behind references, you have to register the dereferenced +//! place. For example: Assume `let x = (0, 0)` and that we want to propagate values from `x.0` and +//! `x.1` also through the assignment `let y = &x`. In this case, we should register `x.0`, `x.1`, +//! `(*y).0` and `(*y).1`. use std::fmt::{Debug, Formatter};