+++ /dev/null
-// ignore-tidy-linelength
-// ignore-compare-mode-nll
-#![feature(const_in_array_repeat_expressions, nll)]
-#![allow(warnings)]
-
-// Some type that is not copyable.
-struct Bar;
-
-const fn type_no_copy() -> Option<Bar> {
- None
-}
-
-const fn type_copy() -> u32 {
- 3
-}
-
-fn no_copy() {
- const ARR: [Option<Bar>; 2] = [type_no_copy(); 2];
- //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied [E0277]
-}
-
-fn copy() {
- const ARR: [u32; 2] = [type_copy(); 2];
-}
-
-fn main() {}
+++ /dev/null
-error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
- --> $DIR/const-fns.rs:18:35
- |
-LL | const ARR: [Option<Bar>; 2] = [type_no_copy(); 2];
- | ^^^^^^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
- |
- = help: the following implementations were found:
- <std::option::Option<T> as std::marker::Copy>
- = note: the `Copy` trait is required because the repeated element will be copied
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
--- /dev/null
+// run-pass
+
+#![allow(unused)]
+#![feature(const_in_array_repeat_expressions)]
+
+// Some type that is not copyable.
+struct Bar;
+
+const fn type_no_copy() -> Option<Bar> {
+ None
+}
+
+const fn type_copy() -> u32 {
+ 3
+}
+
+const _: [u32; 2] = [type_copy(); 2];
+
+// This is allowed because all promotion contexts use the explicit rules for promotability when
+// inside an explicit const context.
+const _: [Option<Bar>; 2] = [type_no_copy(); 2];
+
+fn main() {}
--- /dev/null
+#![feature(const_in_array_repeat_expressions)]
+
+// Some type that is not copyable.
+struct Bar;
+
+const fn no_copy() -> Option<Bar> {
+ None
+}
+
+const fn copy() -> u32 {
+ 3
+}
+
+fn main() {
+ let _: [u32; 2] = [copy(); 2];
+ let _: [Option<Bar>; 2] = [no_copy(); 2];
+ //~^ ERROR the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
+}
--- /dev/null
+error[E0277]: the trait bound `std::option::Option<Bar>: std::marker::Copy` is not satisfied
+ --> $DIR/fn-call-in-non-const.rs:16:31
+ |
+LL | let _: [Option<Bar>; 2] = [no_copy(); 2];
+ | ^^^^^^^^^^^^^^ the trait `std::marker::Copy` is not implemented for `std::option::Option<Bar>`
+ |
+ = help: the following implementations were found:
+ <std::option::Option<T> as std::marker::Copy>
+ = note: the `Copy` trait is required because the repeated element will be copied
+
+error: aborting due to previous error
+
+For more information about this error, try `rustc --explain E0277`.