File tree 1 file changed +4
-4
lines changed
compiler/rustc_const_eval/src/transform
1 file changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -318,14 +318,14 @@ impl<'tcx> Validator<'_, 'tcx> {
318
318
match elem {
319
319
ProjectionElem :: Deref => {
320
320
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
+
321
325
// We need to make sure this is a `Deref` of a local with no further projections.
322
326
// Discussion can be found at
323
327
// https://github.com/rust-lang/rust/pull/74945#discussion_r463063247
324
328
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.
329
329
if let TempState :: Defined { location, .. } = self . temps [ local] {
330
330
let def_stmt = self . body [ location. block ]
331
331
. statements
You can’t perform that action at this time.
0 commit comments