Skip to content

Commit 8d2506c

Browse files
committed
tweak enclosing scope discussion
1 parent 4854f41 commit 8d2506c

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

promotion.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ the only difference.
7878

7979
## Promotion in const contexts
8080

81-
When promoting inside a const context (`const` and `static` items and `const fn`), we relax almost all promotion restrictions, except for basic constness restrictions (such as interior mutability or `Drop`).
81+
When promoting inside a const context (`const` and `static` items and `const fn`), we relax almost all promotion restrictions, except for basic constness restrictions listed below.
8282
We do this for all kinds of promotion.
8383

8484
For `const fn`, [this is a bug](https://github.com/rust-lang/rust/issues/75586).
@@ -101,7 +101,13 @@ the "enclosing scope", similar to how `let x = &mut x;` creates a reference
101101
whose lifetime lasts for the enclosing scope. This is decided during MIR
102102
building already, and does not involve lifetime extension.
103103

104-
This is also sometimes called "outermost scope" rule.
104+
In contrast, this does not compile:
105+
106+
```rust
107+
const OPT_EMPTY_BYTES: Option<&Vec<u8>> = Some(&Vec::new());
108+
```
109+
110+
The "enclosing scope" rule only fires for outermost `&`, just like in `fn` bodies.
105111

106112
## Promotability
107113

0 commit comments

Comments
 (0)