File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -16,14 +16,21 @@ brackets. This produces an array containing each of these values in the
1616order they are written.
1717
1818Alternatively there can be exactly two expressions inside the brackets,
19- separated by a semi-colon . The expression after the ` ; ` must have type
19+ separated by a semicolon . The expression after the ` ; ` must have type
2020` usize ` and be a [ constant expression] ,
2121such as a [ literal] ( ../tokens.md#literals ) or a [ constant
2222item] ( ../items/constant-items.md ) . ` [a; b] ` creates an array containing ` b `
23- copies of the value of ` a ` . If the expression after the semi-colon has a value
23+ copies of the value of ` a ` . If the expression ` b ` after the semicolon has a value
2424greater than 1 then this requires that the type of ` a ` is
2525[ ` Copy ` ] ( ../special-types-and-traits.md#copy ) , or ` a ` must be a path to a
26- constant item.
26+ constant item. When ` b ` evaluates to 0, the expression ` a ` is evaluated once
27+ unless it is a path to a constant item, in which case the constant is not
28+ instantiated.
29+
30+ > ** Note:** In the case where ` b ` is 0, and ` a ` is a non-const expression,
31+ > there is currently a bug in ` rustc ` where the value ` a ` is evaluated but not
32+ > dropped, thus causing a leak. See [ issue
33+ > #74836 ] ( https://github.com/rust-lang/rust/issues/74836 ) .
2734
2835``` rust
2936[1 , 2 , 3 , 4 ];
You can’t perform that action at this time.
0 commit comments