fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #71365 - Mark-Simulacrum:stable-next, r=Mark-Simulacrum4fb7144ed15

1.43.0
1.0 KiB21 linesraw
1error[E0010]: allocations are not allowed in constants
2  --> $DIR/E0010-teach.rs:6:24
3   |
4LL | const CON : Box<i32> = box 0;
5   |                        ^^^^^ allocation not allowed in constants
6   |
7   = note: The value of statics and constants must be known at compile time, and they live for the entire lifetime of a program. Creating a boxed value allocates memory on the heap at runtime, and therefore cannot be done at compile time.
8
9error[E0019]: constant contains unimplemented expression type
10  --> $DIR/E0010-teach.rs:6:28
11   |
12LL | const CON : Box<i32> = box 0;
13   |                            ^
14   |
15   = note: A function call isn't allowed in the const's initialization expression because the expression's value must be known at compile-time.
16   = note: Remember: you can't use a function call inside a const's initialization expression! However, you can use it anywhere else.
17
18error: aborting due to 2 previous errors
19
20Some errors have detailed explanations: E0010, E0019.
21For more information about an error, try `rustc --explain E0010`.