Closed
Description
RFC 2203 specifically calls out Vec::new
as a motivating example, however this does not work on the current nightly.
fn main() {
let _: [Vec<i32>; 4] = [Vec::new(); 4];
}
There are two reasons for this. First, promotion in array repeat expressions currently uses the "implicit" rules for promotability, which forbids promotion of function calls without #[rustc_promotable]
. Second, the result of Vec::new()
is marked as NeedsDrop
since Vec<T>
is Drop
, which disqualifies it from promotion, even in an explicit context.
cc #49147