File tree Expand file tree Collapse file tree 1 file changed +4
-4
lines changed
compiler/rustc_const_eval/src/transform Expand file tree Collapse file tree 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> {
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
You can’t perform that action at this time.
0 commit comments