summaryrefslogtreecommitdiffstats
path: root/src/test/ui/consts/const-blocks
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/consts/const-blocks')
-rw-r--r--src/test/ui/consts/const-blocks/const-repeat.rs27
-rw-r--r--src/test/ui/consts/const-blocks/fn-call-in-const.rs23
-rw-r--r--src/test/ui/consts/const-blocks/fn-call-in-non-const.rs16
-rw-r--r--src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr18
-rw-r--r--src/test/ui/consts/const-blocks/migrate-fail.rs22
-rw-r--r--src/test/ui/consts/const-blocks/migrate-fail.stderr29
-rw-r--r--src/test/ui/consts/const-blocks/migrate-pass.rs125
-rw-r--r--src/test/ui/consts/const-blocks/nll-fail.rs22
-rw-r--r--src/test/ui/consts/const-blocks/nll-fail.stderr29
-rw-r--r--src/test/ui/consts/const-blocks/nll-pass.rs125
-rw-r--r--src/test/ui/consts/const-blocks/run-pass.rs11
-rw-r--r--src/test/ui/consts/const-blocks/trait-error.rs7
-rw-r--r--src/test/ui/consts/const-blocks/trait-error.stderr19
13 files changed, 0 insertions, 473 deletions
diff --git a/src/test/ui/consts/const-blocks/const-repeat.rs b/src/test/ui/consts/const-blocks/const-repeat.rs
deleted file mode 100644
index 65d02317d..000000000
--- a/src/test/ui/consts/const-blocks/const-repeat.rs
+++ /dev/null
@@ -1,27 +0,0 @@
-// run-pass
-
-// Repeating a *constant* of non-Copy type (not just a constant expression) is already stable.
-
-const EMPTY: Vec<i32> = Vec::new();
-
-pub fn bar() -> [Vec<i32>; 2] {
- [EMPTY; 2]
-}
-
-struct Bomb;
-
-impl Drop for Bomb {
- fn drop(&mut self) {
- panic!("BOOM!");
- }
-}
-
-const BOOM: Bomb = Bomb;
-
-fn main() {
- let _x = bar();
-
- // Make sure the destructor does not get called for empty arrays. `[CONST; N]` should
- // instantiate (and then later drop) the const exactly `N` times.
- let _x = [BOOM; 0];
-}
diff --git a/src/test/ui/consts/const-blocks/fn-call-in-const.rs b/src/test/ui/consts/const-blocks/fn-call-in-const.rs
deleted file mode 100644
index 20496f627..000000000
--- a/src/test/ui/consts/const-blocks/fn-call-in-const.rs
+++ /dev/null
@@ -1,23 +0,0 @@
-// run-pass
-
-#![feature(inline_const)]
-#![allow(unused)]
-
-// 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] = [const { type_no_copy() }; 2];
-
-fn main() {}
diff --git a/src/test/ui/consts/const-blocks/fn-call-in-non-const.rs b/src/test/ui/consts/const-blocks/fn-call-in-non-const.rs
deleted file mode 100644
index 18b4dc714..000000000
--- a/src/test/ui/consts/const-blocks/fn-call-in-non-const.rs
+++ /dev/null
@@ -1,16 +0,0 @@
-// 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 `Bar: Copy` is not satisfied
-}
diff --git a/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr b/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr
deleted file mode 100644
index ee352700c..000000000
--- a/src/test/ui/consts/const-blocks/fn-call-in-non-const.stderr
+++ /dev/null
@@ -1,18 +0,0 @@
-error[E0277]: the trait bound `Bar: Copy` is not satisfied
- --> $DIR/fn-call-in-non-const.rs:14:32
- |
-LL | let _: [Option<Bar>; 2] = [no_copy(); 2];
- | ^^^^^^^^^ the trait `Copy` is not implemented for `Bar`
- |
- = note: required for `Option<Bar>` to implement `Copy`
- = note: the `Copy` trait is required because this value will be copied for each element of the array
- = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];`
- = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
-help: consider annotating `Bar` with `#[derive(Copy)]`
- |
-LL | #[derive(Copy)]
- |
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/consts/const-blocks/migrate-fail.rs b/src/test/ui/consts/const-blocks/migrate-fail.rs
deleted file mode 100644
index fddbfbb9d..000000000
--- a/src/test/ui/consts/const-blocks/migrate-fail.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-#![allow(warnings)]
-
-// Some type that is not copyable.
-struct Bar;
-
-mod non_constants {
- use Bar;
-
- fn no_impl_copy_empty_value_multiple_elements() {
- let x = None;
- let arr: [Option<Bar>; 2] = [x; 2];
- //~^ ERROR the trait bound `Bar: Copy` is not satisfied [E0277]
- }
-
- fn no_impl_copy_value_multiple_elements() {
- let x = Some(Bar);
- let arr: [Option<Bar>; 2] = [x; 2];
- //~^ ERROR the trait bound `Bar: Copy` is not satisfied [E0277]
- }
-}
-
-fn main() {}
diff --git a/src/test/ui/consts/const-blocks/migrate-fail.stderr b/src/test/ui/consts/const-blocks/migrate-fail.stderr
deleted file mode 100644
index 928ffd083..000000000
--- a/src/test/ui/consts/const-blocks/migrate-fail.stderr
+++ /dev/null
@@ -1,29 +0,0 @@
-error[E0277]: the trait bound `Bar: Copy` is not satisfied
- --> $DIR/migrate-fail.rs:11:38
- |
-LL | let arr: [Option<Bar>; 2] = [x; 2];
- | ^ the trait `Copy` is not implemented for `Bar`
- |
- = note: required for `Option<Bar>` to implement `Copy`
- = note: the `Copy` trait is required because this value will be copied for each element of the array
-help: consider annotating `Bar` with `#[derive(Copy)]`
- |
-LL | #[derive(Copy)]
- |
-
-error[E0277]: the trait bound `Bar: Copy` is not satisfied
- --> $DIR/migrate-fail.rs:17:38
- |
-LL | let arr: [Option<Bar>; 2] = [x; 2];
- | ^ the trait `Copy` is not implemented for `Bar`
- |
- = note: required for `Option<Bar>` to implement `Copy`
- = note: the `Copy` trait is required because this value will be copied for each element of the array
-help: consider annotating `Bar` with `#[derive(Copy)]`
- |
-LL | #[derive(Copy)]
- |
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/consts/const-blocks/migrate-pass.rs b/src/test/ui/consts/const-blocks/migrate-pass.rs
deleted file mode 100644
index fd66f5aa6..000000000
--- a/src/test/ui/consts/const-blocks/migrate-pass.rs
+++ /dev/null
@@ -1,125 +0,0 @@
-// check-pass
-#![allow(warnings)]
-
-// Some type that is not copyable.
-struct Bar;
-
-mod constants {
- use Bar;
-
- fn no_impl_copy_empty_value_no_elements() {
- const FOO: Option<Bar> = None;
- const ARR: [Option<Bar>; 0] = [FOO; 0];
- }
-
- fn no_impl_copy_empty_value_single_element() {
- const FOO: Option<Bar> = None;
- const ARR: [Option<Bar>; 1] = [FOO; 1];
- }
-
- fn no_impl_copy_empty_value_multiple_elements() {
- const FOO: Option<Bar> = None;
- const ARR: [Option<Bar>; 2] = [FOO; 2];
- }
-
- fn no_impl_copy_value_no_elements() {
- const FOO: Option<Bar> = Some(Bar);
- const ARR: [Option<Bar>; 0] = [FOO; 0];
- }
-
- fn no_impl_copy_value_single_element() {
- const FOO: Option<Bar> = Some(Bar);
- const ARR: [Option<Bar>; 1] = [FOO; 1];
- }
-
- fn no_impl_copy_value_multiple_elements() {
- const FOO: Option<Bar> = Some(Bar);
- const ARR: [Option<Bar>; 2] = [FOO; 2];
- }
-
- fn impl_copy_empty_value_no_elements() {
- const FOO: Option<u32> = None;
- const ARR: [Option<u32>; 0] = [FOO; 0];
- }
-
- fn impl_copy_empty_value_one_element() {
- const FOO: Option<u32> = None;
- const ARR: [Option<u32>; 1] = [FOO; 1];
- }
-
- fn impl_copy_empty_value_multiple_elements() {
- const FOO: Option<u32> = None;
- const ARR: [Option<u32>; 2] = [FOO; 2];
- }
-
- fn impl_copy_value_no_elements() {
- const FOO: Option<u32> = Some(4);
- const ARR: [Option<u32>; 0] = [FOO; 0];
- }
-
- fn impl_copy_value_one_element() {
- const FOO: Option<u32> = Some(4);
- const ARR: [Option<u32>; 1] = [FOO; 1];
- }
-
- fn impl_copy_value_multiple_elements() {
- const FOO: Option<u32> = Some(4);
- const ARR: [Option<u32>; 2] = [FOO; 2];
- }
-}
-
-mod non_constants {
- use Bar;
-
- fn no_impl_copy_empty_value_no_elements() {
- let x = None;
- let arr: [Option<Bar>; 0] = [x; 0];
- }
-
- fn no_impl_copy_empty_value_single_element() {
- let x = None;
- let arr: [Option<Bar>; 1] = [x; 1];
- }
-
- fn no_impl_copy_value_no_elements() {
- let x = Some(Bar);
- let arr: [Option<Bar>; 0] = [x; 0];
- }
-
- fn no_impl_copy_value_single_element() {
- let x = Some(Bar);
- let arr: [Option<Bar>; 1] = [x; 1];
- }
-
- fn impl_copy_empty_value_no_elements() {
- let x: Option<u32> = None;
- let arr: [Option<u32>; 0] = [x; 0];
- }
-
- fn impl_copy_empty_value_one_element() {
- let x: Option<u32> = None;
- let arr: [Option<u32>; 1] = [x; 1];
- }
-
- fn impl_copy_empty_value_multiple_elements() {
- let x: Option<u32> = None;
- let arr: [Option<u32>; 2] = [x; 2];
- }
-
- fn impl_copy_value_no_elements() {
- let x: Option<u32> = Some(4);
- let arr: [Option<u32>; 0] = [x; 0];
- }
-
- fn impl_copy_value_one_element() {
- let x: Option<u32> = Some(4);
- let arr: [Option<u32>; 1] = [x; 1];
- }
-
- fn impl_copy_value_multiple_elements() {
- let x: Option<u32> = Some(4);
- let arr: [Option<u32>; 2] = [x; 2];
- }
-}
-
-fn main() {}
diff --git a/src/test/ui/consts/const-blocks/nll-fail.rs b/src/test/ui/consts/const-blocks/nll-fail.rs
deleted file mode 100644
index fddbfbb9d..000000000
--- a/src/test/ui/consts/const-blocks/nll-fail.rs
+++ /dev/null
@@ -1,22 +0,0 @@
-#![allow(warnings)]
-
-// Some type that is not copyable.
-struct Bar;
-
-mod non_constants {
- use Bar;
-
- fn no_impl_copy_empty_value_multiple_elements() {
- let x = None;
- let arr: [Option<Bar>; 2] = [x; 2];
- //~^ ERROR the trait bound `Bar: Copy` is not satisfied [E0277]
- }
-
- fn no_impl_copy_value_multiple_elements() {
- let x = Some(Bar);
- let arr: [Option<Bar>; 2] = [x; 2];
- //~^ ERROR the trait bound `Bar: Copy` is not satisfied [E0277]
- }
-}
-
-fn main() {}
diff --git a/src/test/ui/consts/const-blocks/nll-fail.stderr b/src/test/ui/consts/const-blocks/nll-fail.stderr
deleted file mode 100644
index fede00845..000000000
--- a/src/test/ui/consts/const-blocks/nll-fail.stderr
+++ /dev/null
@@ -1,29 +0,0 @@
-error[E0277]: the trait bound `Bar: Copy` is not satisfied
- --> $DIR/nll-fail.rs:11:38
- |
-LL | let arr: [Option<Bar>; 2] = [x; 2];
- | ^ the trait `Copy` is not implemented for `Bar`
- |
- = note: required for `Option<Bar>` to implement `Copy`
- = note: the `Copy` trait is required because this value will be copied for each element of the array
-help: consider annotating `Bar` with `#[derive(Copy)]`
- |
-LL | #[derive(Copy)]
- |
-
-error[E0277]: the trait bound `Bar: Copy` is not satisfied
- --> $DIR/nll-fail.rs:17:38
- |
-LL | let arr: [Option<Bar>; 2] = [x; 2];
- | ^ the trait `Copy` is not implemented for `Bar`
- |
- = note: required for `Option<Bar>` to implement `Copy`
- = note: the `Copy` trait is required because this value will be copied for each element of the array
-help: consider annotating `Bar` with `#[derive(Copy)]`
- |
-LL | #[derive(Copy)]
- |
-
-error: aborting due to 2 previous errors
-
-For more information about this error, try `rustc --explain E0277`.
diff --git a/src/test/ui/consts/const-blocks/nll-pass.rs b/src/test/ui/consts/const-blocks/nll-pass.rs
deleted file mode 100644
index fd66f5aa6..000000000
--- a/src/test/ui/consts/const-blocks/nll-pass.rs
+++ /dev/null
@@ -1,125 +0,0 @@
-// check-pass
-#![allow(warnings)]
-
-// Some type that is not copyable.
-struct Bar;
-
-mod constants {
- use Bar;
-
- fn no_impl_copy_empty_value_no_elements() {
- const FOO: Option<Bar> = None;
- const ARR: [Option<Bar>; 0] = [FOO; 0];
- }
-
- fn no_impl_copy_empty_value_single_element() {
- const FOO: Option<Bar> = None;
- const ARR: [Option<Bar>; 1] = [FOO; 1];
- }
-
- fn no_impl_copy_empty_value_multiple_elements() {
- const FOO: Option<Bar> = None;
- const ARR: [Option<Bar>; 2] = [FOO; 2];
- }
-
- fn no_impl_copy_value_no_elements() {
- const FOO: Option<Bar> = Some(Bar);
- const ARR: [Option<Bar>; 0] = [FOO; 0];
- }
-
- fn no_impl_copy_value_single_element() {
- const FOO: Option<Bar> = Some(Bar);
- const ARR: [Option<Bar>; 1] = [FOO; 1];
- }
-
- fn no_impl_copy_value_multiple_elements() {
- const FOO: Option<Bar> = Some(Bar);
- const ARR: [Option<Bar>; 2] = [FOO; 2];
- }
-
- fn impl_copy_empty_value_no_elements() {
- const FOO: Option<u32> = None;
- const ARR: [Option<u32>; 0] = [FOO; 0];
- }
-
- fn impl_copy_empty_value_one_element() {
- const FOO: Option<u32> = None;
- const ARR: [Option<u32>; 1] = [FOO; 1];
- }
-
- fn impl_copy_empty_value_multiple_elements() {
- const FOO: Option<u32> = None;
- const ARR: [Option<u32>; 2] = [FOO; 2];
- }
-
- fn impl_copy_value_no_elements() {
- const FOO: Option<u32> = Some(4);
- const ARR: [Option<u32>; 0] = [FOO; 0];
- }
-
- fn impl_copy_value_one_element() {
- const FOO: Option<u32> = Some(4);
- const ARR: [Option<u32>; 1] = [FOO; 1];
- }
-
- fn impl_copy_value_multiple_elements() {
- const FOO: Option<u32> = Some(4);
- const ARR: [Option<u32>; 2] = [FOO; 2];
- }
-}
-
-mod non_constants {
- use Bar;
-
- fn no_impl_copy_empty_value_no_elements() {
- let x = None;
- let arr: [Option<Bar>; 0] = [x; 0];
- }
-
- fn no_impl_copy_empty_value_single_element() {
- let x = None;
- let arr: [Option<Bar>; 1] = [x; 1];
- }
-
- fn no_impl_copy_value_no_elements() {
- let x = Some(Bar);
- let arr: [Option<Bar>; 0] = [x; 0];
- }
-
- fn no_impl_copy_value_single_element() {
- let x = Some(Bar);
- let arr: [Option<Bar>; 1] = [x; 1];
- }
-
- fn impl_copy_empty_value_no_elements() {
- let x: Option<u32> = None;
- let arr: [Option<u32>; 0] = [x; 0];
- }
-
- fn impl_copy_empty_value_one_element() {
- let x: Option<u32> = None;
- let arr: [Option<u32>; 1] = [x; 1];
- }
-
- fn impl_copy_empty_value_multiple_elements() {
- let x: Option<u32> = None;
- let arr: [Option<u32>; 2] = [x; 2];
- }
-
- fn impl_copy_value_no_elements() {
- let x: Option<u32> = Some(4);
- let arr: [Option<u32>; 0] = [x; 0];
- }
-
- fn impl_copy_value_one_element() {
- let x: Option<u32> = Some(4);
- let arr: [Option<u32>; 1] = [x; 1];
- }
-
- fn impl_copy_value_multiple_elements() {
- let x: Option<u32> = Some(4);
- let arr: [Option<u32>; 2] = [x; 2];
- }
-}
-
-fn main() {}
diff --git a/src/test/ui/consts/const-blocks/run-pass.rs b/src/test/ui/consts/const-blocks/run-pass.rs
deleted file mode 100644
index e11f69bab..000000000
--- a/src/test/ui/consts/const-blocks/run-pass.rs
+++ /dev/null
@@ -1,11 +0,0 @@
-// run-pass
-
-#[derive(Debug, Eq, PartialEq)]
-struct Bar;
-
-fn main() {
- const FOO: Option<Bar> = None;
- const ARR: [Option<Bar>; 2] = [FOO; 2];
-
- assert_eq!(ARR, [None::<Bar>, None::<Bar>]);
-}
diff --git a/src/test/ui/consts/const-blocks/trait-error.rs b/src/test/ui/consts/const-blocks/trait-error.rs
deleted file mode 100644
index 49d1e9b94..000000000
--- a/src/test/ui/consts/const-blocks/trait-error.rs
+++ /dev/null
@@ -1,7 +0,0 @@
-#[derive(Copy, Clone)]
-struct Foo<T>(T);
-
-fn main() {
- [Foo(String::new()); 4];
- //~^ ERROR the trait bound `String: Copy` is not satisfied [E0277]
-}
diff --git a/src/test/ui/consts/const-blocks/trait-error.stderr b/src/test/ui/consts/const-blocks/trait-error.stderr
deleted file mode 100644
index b11dd4b80..000000000
--- a/src/test/ui/consts/const-blocks/trait-error.stderr
+++ /dev/null
@@ -1,19 +0,0 @@
-error[E0277]: the trait bound `String: Copy` is not satisfied
- --> $DIR/trait-error.rs:5:6
- |
-LL | [Foo(String::new()); 4];
- | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `String`
- |
-note: required for `Foo<String>` to implement `Copy`
- --> $DIR/trait-error.rs:1:10
- |
-LL | #[derive(Copy, Clone)]
- | ^^^^
- = note: the `Copy` trait is required because this value will be copied for each element of the array
- = help: consider creating a new `const` item and initializing it with the result of the function call to be used in the repeat position, like `const VAL: Type = const_fn();` and `let x = [VAL; 42];`
- = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information
- = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info)
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0277`.