diff options
| author | bors <bors@rust-lang.org> | 2022-12-02 12:03:59 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-12-02 12:03:59 +0000 |
| commit | cef44f53034eac46be3a0e3eec7b2b3d4ef5140b (patch) | |
| tree | 2354b0ac401b6a477bb76396f5832bf6199ae56d /compiler/rustc_const_eval/src | |
| parent | 11663b1b4857ffeafbd85a9a36c234d117373b76 (diff) | |
| parent | 8e059d5968c8f695fe53835c78f60fff6759b438 (diff) | |
| download | rust-cef44f53034eac46be3a0e3eec7b2b3d4ef5140b.tar.gz rust-cef44f53034eac46be3a0e3eec7b2b3d4ef5140b.zip | |
Auto merge of #105166 - matthiaskrgr:rollup-s9l6vt2, r=matthiaskrgr
Rollup of 6 pull requests Successful merges: - #104614 (Add `type_ascribe!` macro as placeholder syntax for type ascription) - #105126 (Make `VecDeque::new_in` unstably const) - #105132 (Migrate summary toggle filter to CSS variable) - #105136 (clarify comment on Deref promotion) - #105137 (Add tracking issue number for `file_create_new` feature) - #105143 (rustdoc: use simpler CSS for setting the font on scraped examples) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/transform/promote_consts.rs | 8 |
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 |
