@@ -11,28 +11,22 @@ LL | | }
1111LL | };
1212 | - value is dropped here
1313
14- error[E0015]: cannot call non-const associated function `Box ::<[ MyOwned; 1]>::new_uninit ` in statics
15- --> $DIR/check-values-constraints.rs:81 :33
14+ error[E0015]: cannot call non-const function `non_const ::<MyOwned> ` in statics
15+ --> $DIR/check-values-constraints.rs:85 :33
1616 |
17- LL | static STATIC11: Vec<MyOwned> = vec![ MyOwned] ;
18- | ^^^^^^^^^^^^^
17+ LL | static STATIC11: Vec<MyOwned> = non_const( MyOwned) ;
18+ | ^^^^^^^^^^^^^^^^^^
1919 |
20- = note: calls in statics are limited to constant functions, tuple structs and tuple variants
21- = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
22-
23- error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::<MyOwned, 1>` in statics
24- --> $DIR/check-values-constraints.rs:81:33
25- |
26- LL | static STATIC11: Vec<MyOwned> = vec![MyOwned];
27- | ^^^^^^^^^^^^^
20+ note: function `non_const` is not const
21+ --> $DIR/check-values-constraints.rs:71:1
2822 |
29- note: function `box_assume_init_into_vec_unsafe` is not const
30- --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
23+ LL | fn non_const<T>(value: T) -> Vec<T> {
24+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3125 = note: calls in statics are limited to constant functions, tuple structs and tuple variants
3226 = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
3327
3428error[E0015]: cannot call non-const method `<str as ToString>::to_string` in statics
35- --> $DIR/check-values-constraints.rs:92 :38
29+ --> $DIR/check-values-constraints.rs:95 :38
3630 |
3731LL | field2: SafeEnum::Variant4("str".to_string()),
3832 | ^^^^^^^^^^^
@@ -47,128 +41,92 @@ note: method `to_string` is not const because trait `ToString` is not const
4741 = note: calls in statics are limited to constant functions, tuple structs and tuple variants
4842 = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
4943
50- error[E0015]: cannot call non-const associated function `Box ::<[ MyOwned; 1]>::new_uninit ` in statics
51- --> $DIR/check-values-constraints.rs:96 :5
44+ error[E0015]: cannot call non-const function `non_const ::<MyOwned> ` in statics
45+ --> $DIR/check-values-constraints.rs:99 :5
5246 |
53- LL | vec![MyOwned],
54- | ^^^^^^^^^^^^^
55- |
56- = note: calls in statics are limited to constant functions, tuple structs and tuple variants
57- = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
58-
59- error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::<MyOwned, 1>` in statics
60- --> $DIR/check-values-constraints.rs:96:5
47+ LL | non_const(MyOwned),
48+ | ^^^^^^^^^^^^^^^^^^
6149 |
62- LL | vec![MyOwned],
63- | ^^^^^^^^^^^^^
50+ note: function `non_const` is not const
51+ --> $DIR/check-values-constraints.rs:71:1
6452 |
65- note: function `box_assume_init_into_vec_unsafe` is not const
66- --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
53+ LL | fn non_const<T>(value: T) -> Vec<T> {
54+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
6755 = note: calls in statics are limited to constant functions, tuple structs and tuple variants
6856 = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
6957
70- error[E0015]: cannot call non-const associated function `Box ::<[ MyOwned; 1]>::new_uninit ` in statics
71- --> $DIR/check-values-constraints.rs:98 :5
58+ error[E0015]: cannot call non-const function `non_const ::<MyOwned> ` in statics
59+ --> $DIR/check-values-constraints.rs:100 :5
7260 |
73- LL | vec![ MyOwned] ,
74- | ^^^^^^^^^^^^^
61+ LL | non_const( MyOwned) ,
62+ | ^^^^^^^^^^^^^^^^^^
7563 |
76- = note: calls in statics are limited to constant functions, tuple structs and tuple variants
77- = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
78-
79- error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::<MyOwned, 1>` in statics
80- --> $DIR/check-values-constraints.rs:98:5
81- |
82- LL | vec![MyOwned],
83- | ^^^^^^^^^^^^^
64+ note: function `non_const` is not const
65+ --> $DIR/check-values-constraints.rs:71:1
8466 |
85- note: function `box_assume_init_into_vec_unsafe` is not const
86- --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
67+ LL | fn non_const<T>(value: T) -> Vec<T> {
68+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8769 = note: calls in statics are limited to constant functions, tuple structs and tuple variants
8870 = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
8971
90- error[E0015]: cannot call non-const associated function `Box ::<[ MyOwned; 1]>::new_uninit ` in statics
91- --> $DIR/check-values-constraints.rs:103 :6
72+ error[E0015]: cannot call non-const function `non_const ::<MyOwned> ` in statics
73+ --> $DIR/check-values-constraints.rs:104 :6
9274 |
93- LL | &vec![ MyOwned] ,
94- | ^^^^^^^^^^^^^
75+ LL | &non_const( MyOwned) ,
76+ | ^^^^^^^^^^^^^^^^^^
9577 |
96- = note: calls in statics are limited to constant functions, tuple structs and tuple variants
97- = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
98-
99- error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::<MyOwned, 1>` in statics
100- --> $DIR/check-values-constraints.rs:103:6
78+ note: function `non_const` is not const
79+ --> $DIR/check-values-constraints.rs:71:1
10180 |
102- LL | &vec![MyOwned],
103- | ^^^^^^^^^^^^^
104- |
105- note: function `box_assume_init_into_vec_unsafe` is not const
106- --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
81+ LL | fn non_const<T>(value: T) -> Vec<T> {
82+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
10783 = note: calls in statics are limited to constant functions, tuple structs and tuple variants
10884 = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
10985
110- error[E0015]: cannot call non-const associated function `Box ::<[ MyOwned; 1]>::new_uninit ` in statics
86+ error[E0015]: cannot call non-const function `non_const ::<MyOwned> ` in statics
11187 --> $DIR/check-values-constraints.rs:105:6
11288 |
113- LL | &vec![ MyOwned] ,
114- | ^^^^^^^^^^^^^
89+ LL | &non_const( MyOwned) ,
90+ | ^^^^^^^^^^^^^^^^^^
11591 |
116- = note: calls in statics are limited to constant functions, tuple structs and tuple variants
117- = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
118-
119- error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::<MyOwned, 1>` in statics
120- --> $DIR/check-values-constraints.rs:105:6
121- |
122- LL | &vec![MyOwned],
123- | ^^^^^^^^^^^^^
92+ note: function `non_const` is not const
93+ --> $DIR/check-values-constraints.rs:71:1
12494 |
125- note: function `box_assume_init_into_vec_unsafe` is not const
126- --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
95+ LL | fn non_const<T>(value: T) -> Vec<T> {
96+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12797 = note: calls in statics are limited to constant functions, tuple structs and tuple variants
12898 = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
12999
130- error[E0015]: cannot call non-const associated function `Box::<[isize; 1]>::new_uninit` in statics
131- --> $DIR/check-values-constraints.rs:111:31
132- |
133- LL | static STATIC19: Vec<isize> = vec![3];
134- | ^^^^^^^
100+ error[E0015]: cannot call non-const function `non_const::<isize>` in statics
101+ --> $DIR/check-values-constraints.rs:110:31
135102 |
136- = note: calls in statics are limited to constant functions, tuple structs and tuple variants
137- = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
138-
139- error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::<isize, 1>` in statics
140- --> $DIR/check-values-constraints.rs:111:31
103+ LL | static STATIC19: Vec<isize> = non_const(3);
104+ | ^^^^^^^^^^^^
141105 |
142- LL | static STATIC19: Vec<isize> = vec![3];
143- | ^^^^^^^
106+ note: function `non_const` is not const
107+ --> $DIR/check-values-constraints.rs:71:1
144108 |
145- note: function `box_assume_init_into_vec_unsafe` is not const
146- --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
109+ LL | fn non_const<T>(value: T) -> Vec<T> {
110+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
147111 = note: calls in statics are limited to constant functions, tuple structs and tuple variants
148112 = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
149113
150- error[E0015]: cannot call non-const associated function `Box::<[isize; 1]>::new_uninit` in statics
151- --> $DIR/check-values-constraints.rs:117:32
152- |
153- LL | static x: Vec<isize> = vec![3];
154- | ^^^^^^^
114+ error[E0015]: cannot call non-const function `non_const::<isize>` in statics
115+ --> $DIR/check-values-constraints.rs:115:32
155116 |
156- = note: calls in statics are limited to constant functions, tuple structs and tuple variants
157- = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
158-
159- error[E0015]: cannot call non-const function `std::boxed::box_assume_init_into_vec_unsafe::<isize, 1>` in statics
160- --> $DIR/check-values-constraints.rs:117:32
117+ LL | static x: Vec<isize> = non_const(3);
118+ | ^^^^^^^^^^^^
161119 |
162- LL | static x: Vec<isize> = vec![3];
163- | ^^^^^^^
120+ note: function `non_const` is not const
121+ --> $DIR/check-values-constraints.rs:71:1
164122 |
165- note: function `box_assume_init_into_vec_unsafe` is not const
166- --> $SRC_DIR/alloc/src/boxed.rs:LL:COL
123+ LL | fn non_const<T>(value: T) -> Vec<T> {
124+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
167125 = note: calls in statics are limited to constant functions, tuple structs and tuple variants
168126 = note: consider wrapping this expression in `std::sync::LazyLock::new(|| ...)`
169127
170128error[E0507]: cannot move out of static item `x`
171- --> $DIR/check-values-constraints.rs:119 :9
129+ --> $DIR/check-values-constraints.rs:116 :9
172130 |
173131LL | x
174132 | ^ move occurs because `x` has type `Vec<isize>`, which does not implement the `Copy` trait
@@ -182,7 +140,7 @@ help: consider cloning the value if the performance cost is acceptable
182140LL | x.clone()
183141 | ++++++++
184142
185- error: aborting due to 17 previous errors
143+ error: aborting due to 10 previous errors
186144
187145Some errors have detailed explanations: E0015, E0493, E0507.
188146For more information about an error, try `rustc --explain E0015`.
0 commit comments