Skip to content

Commit 438edc3

Browse files
committed
Update the unstable book regarding [e; dyn n].
1 parent c72e87e commit 438edc3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/doc/unstable-book/src/language-features/unsized-locals.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -127,13 +127,13 @@ One of the objectives of this feature is to allow `Box<dyn FnOnce>`, instead of
127127

128128
## Variable length arrays
129129

130-
The RFC also describes an extension to the array literal syntax `[e; n]`: you'll be able to specify non-const `n` to allocate variable length arrays on the stack.
130+
The RFC also describes an extension to the array literal syntax: `[e; dyn n]`. In the syntax, `n` isn't necessarily a constant expression. The array is dynamically allocated on the stack and has the type of `[T]`, instead of `[T; n]`.
131131

132132
```rust,ignore
133133
#![feature(unsized_locals)]
134134
135135
fn mergesort<T: Ord>(a: &mut [T]) {
136-
let mut tmp = [T; a.len()];
136+
let mut tmp = [T; dyn a.len()];
137137
// ...
138138
}
139139
@@ -144,7 +144,7 @@ fn main() {
144144
}
145145
```
146146

147-
VLAs are not implemented yet.
147+
VLAs are not implemented yet. The syntax isn't final, either. We may need an alternative syntax for Rust 2015 because, in Rust 2015, expressions like `[e; dyn(1)]` would be ambiguous. One possible alternative proposed in the RFC is `[e; n]`: if `n` captures one or more local variables, then it is considered as `[e; dyn n]`.
148148

149149
## Advisory on stack usage
150150

0 commit comments

Comments
 (0)