clarify comment on Deref promotion
This commit is contained in:
parent
8a09420ac4
commit
b7f2b1cd5c
1 changed files with 4 additions and 4 deletions
|
@ -318,14 +318,14 @@ impl<'tcx> Validator<'_, 'tcx> {
|
||||||
match elem {
|
match elem {
|
||||||
ProjectionElem::Deref => {
|
ProjectionElem::Deref => {
|
||||||
let mut promotable = false;
|
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.
|
// We need to make sure this is a `Deref` of a local with no further projections.
|
||||||
// Discussion can be found at
|
// Discussion can be found at
|
||||||
// https://github.com/rust-lang/rust/pull/74945#discussion_r463063247
|
// https://github.com/rust-lang/rust/pull/74945#discussion_r463063247
|
||||||
if let Some(local) = place_base.as_local() {
|
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] {
|
if let TempState::Defined { location, .. } = self.temps[local] {
|
||||||
let def_stmt = self.body[location.block]
|
let def_stmt = self.body[location.block]
|
||||||
.statements
|
.statements
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue