about summary refs log tree commit diff
path: root/compiler/rustc_const_eval/src/transform
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2022-12-01 16:41:49 +0100
committerRalf Jung <post@ralfj.de>2022-12-01 16:42:33 +0100
commitb7f2b1cd5cd08e4805bb3df0e8153445acfb04c7 (patch)
tree7f06c7e22caed6f21c8f6b8615c4d5b190acf8aa /compiler/rustc_const_eval/src/transform
parent8a09420ac48658cad726e0a6997687ceac4151e3 (diff)
downloadrust-b7f2b1cd5cd08e4805bb3df0e8153445acfb04c7.tar.gz
rust-b7f2b1cd5cd08e4805bb3df0e8153445acfb04c7.zip
clarify comment on Deref promotion
Diffstat (limited to 'compiler/rustc_const_eval/src/transform')
-rw-r--r--compiler/rustc_const_eval/src/transform/promote_consts.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/compiler/rustc_const_eval/src/transform/promote_consts.rs b/compiler/rustc_const_eval/src/transform/promote_consts.rs
index f48bcd90809..6777fae74f1 100644
--- a/compiler/rustc_const_eval/src/transform/promote_consts.rs
+++ b/compiler/rustc_const_eval/src/transform/promote_consts.rs
@@ -318,14 +318,14 @@ impl<'tcx> Validator<'_, 'tcx> {
                 match elem {
                     ProjectionElem::Deref => {
                         let mut promotable = false;
+                        // When a static is used by-value, that gets desugared to `*STATIC_ADDR`,
+                        // and we need to be able to promote this. So check if this deref matches
+                        // that specific pattern.
+
                         // We need to make sure this is a `Deref` of a local with no further projections.
                         // Discussion can be found at
                         // https://github.com/rust-lang/rust/pull/74945#discussion_r463063247
                         if let Some(local) = place_base.as_local() {
-                            // This is a special treatment for cases like *&STATIC where STATIC is a
-                            // global static variable.
-                            // This pattern is generated only when global static variables are directly
-                            // accessed and is qualified for promotion safely.
                             if let TempState::Defined { location, .. } = self.temps[local] {
                                 let def_stmt = self.body[location.block]
                                     .statements