Skip to content

Commit 0b057bb

Browse files
committed
rfc, const_repeat_expr: consistency fixes + resolve UQ
1 parent 3360947 commit 0b057bb

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

text/0000-const-repeat-expr.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,14 @@ But with this RFC, you can now write:
6565

6666
```rust
6767
const X: T = None;
68-
const arr: [u32; 100] = [X; 100];
68+
const arr: [T; 100] = [X; 100];
6969
```
7070

7171
or, if you wish to modify the array later:
7272

7373
```rust
7474
const X: T = None;
75-
let mut arr = [x; 100];
75+
let mut arr = [X; 100];
7676
arr[0] = Some(Box::new(1));
7777
```
7878

@@ -108,7 +108,10 @@ internally as:
108108

109109
```rust
110110
// This is the value to be repeated and typeof(X) the type it has.
111+
// If a `VALUE` panics, it happens during compile time at this point
112+
// and not later.
111113
const X: typeof(X) = VALUE;
114+
112115
// N is the size of the array and how many times to repeat X.
113116
const N: usize = SIZE;
114117

@@ -121,7 +124,7 @@ const N: usize = SIZE;
121124
let mut iter = (&mut data[..]).into_iter();
122125
while let Some(elem) = iter.next() {
123126
// ptr::write does not run destructor of elem already in array.
124-
// Since X is const, it can not panic.
127+
// Since X is const, it can not panic at this point.
125128
ptr::write(elem, X);
126129
}
127130
}
@@ -156,8 +159,4 @@ be `const`.
156159
# Unresolved questions
157160
[unresolved]: #unresolved-questions
158161

159-
[`drop_types_in_const`]: https://github.com/rust-lang/rfcs/blob/master/text/1440-drop-types-in-const.md
160-
161-
The relation to [`drop_types_in_const`] should be resolved during the RFC process.
162-
The soundness of the proposal should be verified.
163-
Other than that, there are no unresolved questions.
162+
There are no unresolved questions.

0 commit comments

Comments
 (0)