Skip to content

Commit 0c82a13

Browse files
committed
Remove #[rustc_box] usage in the vec![] macro
1 parent ab78384 commit 0c82a13

File tree

11 files changed

+67
-56
lines changed

11 files changed

+67
-56
lines changed

library/alloc/src/macros.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,7 @@ macro_rules! vec {
4848
);
4949
($($x:expr),+ $(,)?) => (
5050
<[_]>::into_vec(
51-
// Using the intrinsic produces a dramatic improvement in compile
52-
// time when constructing arrays with many elements.
53-
$crate::boxed::box_new([$($x),+])
51+
$crate::boxed::Box::new([$($x),+])
5452
)
5553
);
5654
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
const fn foo(a: i32) -> Vec<i32> {
22
vec![1, 2, 3]
3-
//~^ ERROR allocations are not allowed
4-
//~| ERROR cannot call non-const method
3+
//~^ ERROR cannot call non-const
4+
//~| ERROR cannot call non-const
55
}
66

77
fn main() {}

tests/ui/consts/min_const_fn/bad_const_fn_body_ice.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
error[E0010]: allocations are not allowed in constant functions
1+
error[E0015]: cannot call non-const associated function `Box::<[i32; 3]>::new` in constant functions
22
--> $DIR/bad_const_fn_body_ice.rs:2:5
33
|
44
LL | vec![1, 2, 3]
5-
| ^^^^^^^^^^^^^ allocation not allowed in constant functions
5+
| ^^^^^^^^^^^^^
66
|
7+
= note: calls in constant functions are limited to constant functions, tuple structs and tuple variants
78
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
89

910
error[E0015]: cannot call non-const method `slice::<impl [i32]>::into_vec::<std::alloc::Global>` in constant functions
@@ -17,5 +18,4 @@ LL | vec![1, 2, 3]
1718

1819
error: aborting due to 2 previous errors
1920

20-
Some errors have detailed explanations: E0010, E0015.
21-
For more information about an error, try `rustc --explain E0010`.
21+
For more information about this error, try `rustc --explain E0015`.

tests/ui/error-codes/E0010-teach.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22

33
#![allow(warnings)]
44

5-
const CON: Vec<i32> = vec![1, 2, 3]; //~ ERROR E0010
6-
//~| ERROR cannot call non-const method
5+
const CON: Vec<i32> = vec![1, 2, 3]; //~ ERROR cannot call non-const
6+
//~| ERROR cannot call non-const
77
fn main() {}

tests/ui/error-codes/E0010-teach.stderr

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error[E0010]: allocations are not allowed in constants
1+
error[E0015]: cannot call non-const associated function `Box::<[i32; 3]>::new` in constants
22
--> $DIR/E0010-teach.rs:5:23
33
|
44
LL | const CON: Vec<i32> = vec![1, 2, 3];
5-
| ^^^^^^^^^^^^^ allocation not allowed in constants
5+
| ^^^^^^^^^^^^^
66
|
7-
= note: The runtime heap is not yet available at compile-time, so no runtime heap allocations can be created.
7+
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
88
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
99

1010
error[E0015]: cannot call non-const method `slice::<impl [i32]>::into_vec::<std::alloc::Global>` in constants
@@ -18,5 +18,4 @@ LL | const CON: Vec<i32> = vec![1, 2, 3];
1818

1919
error: aborting due to 2 previous errors
2020

21-
Some errors have detailed explanations: E0010, E0015.
22-
For more information about an error, try `rustc --explain E0010`.
21+
For more information about this error, try `rustc --explain E0015`.

tests/ui/error-codes/E0010.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#![allow(warnings)]
22

3-
const CON: Vec<i32> = vec![1, 2, 3]; //~ ERROR E0010
4-
//~| ERROR cannot call non-const method
3+
const CON: Vec<i32> = vec![1, 2, 3]; //~ ERROR cannot call non-const
4+
//~| ERROR cannot call non-const
55
fn main() {}

tests/ui/error-codes/E0010.stderr

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
error[E0010]: allocations are not allowed in constants
1+
error[E0015]: cannot call non-const associated function `Box::<[i32; 3]>::new` in constants
22
--> $DIR/E0010.rs:3:23
33
|
44
LL | const CON: Vec<i32> = vec![1, 2, 3];
5-
| ^^^^^^^^^^^^^ allocation not allowed in constants
5+
| ^^^^^^^^^^^^^
66
|
7+
= note: calls in constants are limited to constant functions, tuple structs and tuple variants
78
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
89

910
error[E0015]: cannot call non-const method `slice::<impl [i32]>::into_vec::<std::alloc::Global>` in constants
@@ -17,5 +18,4 @@ LL | const CON: Vec<i32> = vec![1, 2, 3];
1718

1819
error: aborting due to 2 previous errors
1920

20-
Some errors have detailed explanations: E0010, E0015.
21-
For more information about an error, try `rustc --explain E0010`.
21+
For more information about this error, try `rustc --explain E0015`.

tests/ui/macros/vec-macro-in-pattern.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
fn main() {
66
match Some(vec![42]) {
7-
Some(vec![43]) => {} //~ ERROR expected a pattern, found a function call
7+
Some(vec![43]) => {} //~ ERROR expected tuple struct or tuple variant, found associated function
88
//~| ERROR found associated function
99
//~| ERROR usage of qualified paths in this context is experimental
1010
_ => {}

tests/ui/macros/vec-macro-in-pattern.stderr

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
error[E0532]: expected a pattern, found a function call
2-
--> $DIR/vec-macro-in-pattern.rs:7:14
3-
|
4-
LL | Some(vec![43]) => {}
5-
| ^^^^^^^^ not a tuple struct or tuple variant
6-
|
7-
= note: function calls are not allowed in patterns: <https://doc.rust-lang.org/book/ch19-00-patterns.html>
8-
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
9-
101
error[E0658]: usage of qualified paths in this context is experimental
112
--> $DIR/vec-macro-in-pattern.rs:7:14
123
|
@@ -27,7 +18,16 @@ LL | Some(vec![43]) => {}
2718
= help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html
2819
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
2920

21+
error[E0164]: expected tuple struct or tuple variant, found associated function `::alloc::boxed::Box::new`
22+
--> $DIR/vec-macro-in-pattern.rs:7:14
23+
|
24+
LL | Some(vec![43]) => {}
25+
| ^^^^^^^^ `fn` calls are not allowed in patterns
26+
|
27+
= help: for more information, visit https://doc.rust-lang.org/book/ch19-00-patterns.html
28+
= note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info)
29+
3030
error: aborting due to 3 previous errors
3131

32-
Some errors have detailed explanations: E0164, E0532, E0658.
32+
Some errors have detailed explanations: E0164, E0658.
3333
For more information about an error, try `rustc --explain E0164`.

tests/ui/statics/check-values-constraints.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static STATIC10: UnsafeStruct = UnsafeStruct;
7979
struct MyOwned;
8080

8181
static STATIC11: Vec<MyOwned> = vec![MyOwned];
82-
//~^ ERROR allocations are not allowed in statics
82+
//~^ ERROR cannot call non-const
8383
//~^^ ERROR cannot call non-const
8484

8585
static mut STATIC12: UnsafeStruct = UnsafeStruct;
@@ -93,28 +93,28 @@ static mut STATIC14: SafeStruct = SafeStruct {
9393
};
9494

9595
static STATIC15: &'static [Vec<MyOwned>] = &[
96-
vec![MyOwned], //~ ERROR allocations are not allowed in statics
96+
vec![MyOwned], //~ ERROR cannot call non-const
9797
//~^ ERROR cannot call non-const
98-
vec![MyOwned], //~ ERROR allocations are not allowed in statics
98+
vec![MyOwned], //~ ERROR cannot call non-const
9999
//~^ ERROR cannot call non-const
100100
];
101101

102102
static STATIC16: (&'static Vec<MyOwned>, &'static Vec<MyOwned>) = (
103-
&vec![MyOwned], //~ ERROR allocations are not allowed in statics
103+
&vec![MyOwned], //~ ERROR cannot call non-const
104104
//~^ ERROR cannot call non-const
105-
&vec![MyOwned], //~ ERROR allocations are not allowed in statics
105+
&vec![MyOwned], //~ ERROR cannot call non-const
106106
//~^ ERROR cannot call non-const
107107
);
108108

109109
static mut STATIC17: SafeEnum = SafeEnum::Variant1;
110110

111111
static STATIC19: Vec<isize> = vec![3];
112-
//~^ ERROR allocations are not allowed in statics
112+
//~^ ERROR cannot call non-const
113113
//~^^ ERROR cannot call non-const
114114

115115
pub fn main() {
116116
let y = {
117-
static x: Vec<isize> = vec![3]; //~ ERROR allocations are not allowed in statics
117+
static x: Vec<isize> = vec![3]; //~ ERROR cannot call non-const
118118
//~^ ERROR cannot call non-const
119119
x
120120
//~^ ERROR cannot move out of static

0 commit comments

Comments
 (0)