Skip to content

Commit b7f2b1c

Browse files
committed
clarify comment on Deref promotion
1 parent 8a09420 commit b7f2b1c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

compiler/rustc_const_eval/src/transform/promote_consts.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -318,14 +318,14 @@ impl<'tcx> Validator<'_, 'tcx> {
318318
match elem {
319319
ProjectionElem::Deref => {
320320
let mut promotable = false;
321+
// When a static is used by-value, that gets desugared to `*STATIC_ADDR`,
322+
// and we need to be able to promote this. So check if this deref matches
323+
// that specific pattern.
324+
321325
// We need to make sure this is a `Deref` of a local with no further projections.
322326
// Discussion can be found at
323327
// https://github.com/rust-lang/rust/pull/74945#discussion_r463063247
324328
if let Some(local) = place_base.as_local() {
325-
// This is a special treatment for cases like *&STATIC where STATIC is a
326-
// global static variable.
327-
// This pattern is generated only when global static variables are directly
328-
// accessed and is qualified for promotion safely.
329329
if let TempState::Defined { location, .. } = self.temps[local] {
330330
let def_stmt = self.body[location.block]
331331
.statements

0 commit comments

Comments
 (0)