about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2022-06-30 10:17:49 -0400
committerRalf Jung <post@ralfj.de>2022-07-13 18:31:29 -0400
commit07fe9882cc6e03682fcfa7b18c8f5b998219bdd2 (patch)
tree5277e7ee1a3d35da9983ab738d8167704db80d4a /src
parente4593ef0f214b7259e5f5706b2952610ae1fb5ef (diff)
downloadrust-07fe9882cc6e03682fcfa7b18c8f5b998219bdd2.tar.gz
rust-07fe9882cc6e03682fcfa7b18c8f5b998219bdd2.zip
add array tests, cleanup, tidy, and bless
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/consts/invalid-union.32bit.stderr6
-rw-r--r--src/test/ui/union/field_checks.rs10
-rw-r--r--src/test/ui/union/field_checks.stderr22
-rw-r--r--src/test/ui/union/union-nonrepresentable.rs1
-rw-r--r--src/test/ui/union/union-nonrepresentable.stderr2
-rw-r--r--src/tools/clippy/tests/ui/derive.rs2
-rw-r--r--src/tools/clippy/tests/ui/no_effect.rs2
7 files changed, 32 insertions, 13 deletions
diff --git a/src/test/ui/consts/invalid-union.32bit.stderr b/src/test/ui/consts/invalid-union.32bit.stderr
index 7e9abc3ffa7..ae5f6b2baee 100644
--- a/src/test/ui/consts/invalid-union.32bit.stderr
+++ b/src/test/ui/consts/invalid-union.32bit.stderr
@@ -1,5 +1,5 @@
 error[E0080]: it is undefined behavior to use this value
-  --> $DIR/invalid-union.rs:40:1
+  --> $DIR/invalid-union.rs:41:1
    |
 LL | fn main() {
    | ^^^^^^^^^ constructing invalid value at .<deref>.y.<enum-variant(B)>.0: encountered `UnsafeCell` in a `const`
@@ -10,7 +10,7 @@ LL | fn main() {
            }
 
 error: erroneous constant used
-  --> $DIR/invalid-union.rs:41:25
+  --> $DIR/invalid-union.rs:42:25
    |
 LL |     let _: &'static _ = &C;
    |                         ^^ referenced constant has errors
@@ -24,7 +24,7 @@ error: aborting due to 2 previous errors
 For more information about this error, try `rustc --explain E0080`.
 Future incompatibility report: Future breakage diagnostic:
 error: erroneous constant used
-  --> $DIR/invalid-union.rs:41:25
+  --> $DIR/invalid-union.rs:42:25
    |
 LL |     let _: &'static _ = &C;
    |                         ^^ referenced constant has errors
diff --git a/src/test/ui/union/field_checks.rs b/src/test/ui/union/field_checks.rs
index 216f7372a1c..d5d1e44ac85 100644
--- a/src/test/ui/union/field_checks.rs
+++ b/src/test/ui/union/field_checks.rs
@@ -1,4 +1,3 @@
-// ignore-tidy-linelength
 use std::mem::ManuallyDrop;
 
 union U1 { // OK
@@ -45,6 +44,10 @@ union U5Nested { // a nested union that drops is NOT OK
     nest: U5, //~ ERROR unions cannot contain fields that may need dropping
 }
 
+union U5Nested2 { // for now we don't special-case empty arrays
+    nest: [U5; 0], //~ ERROR unions cannot contain fields that may need dropping
+}
+
 union U6 { // OK
     s: &'static i32,
     m: &'static mut i32,
@@ -54,4 +57,9 @@ union U7<T> { // OK
     f: (&'static mut i32, ManuallyDrop<T>, i32),
 }
 
+union U8<T> { // OK
+    f1: [(&'static mut i32, i32); 8],
+    f2: [ManuallyDrop<T>; 2],
+}
+
 fn main() {}
diff --git a/src/test/ui/union/field_checks.stderr b/src/test/ui/union/field_checks.stderr
index 0e0e545b01a..1f97e97ac6e 100644
--- a/src/test/ui/union/field_checks.stderr
+++ b/src/test/ui/union/field_checks.stderr
@@ -1,5 +1,5 @@
 error[E0740]: unions cannot contain fields that may need dropping
-  --> $DIR/field_checks.rs:25:5
+  --> $DIR/field_checks.rs:24:5
    |
 LL |     a: String,
    |     ^^^^^^^^^
@@ -11,7 +11,7 @@ LL |     a: std::mem::ManuallyDrop<String>,
    |        +++++++++++++++++++++++      +
 
 error[E0740]: unions cannot contain fields that may need dropping
-  --> $DIR/field_checks.rs:29:5
+  --> $DIR/field_checks.rs:28:5
    |
 LL |     a: std::cell::RefCell<i32>,
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -23,7 +23,7 @@ LL |     a: std::mem::ManuallyDrop<std::cell::RefCell<i32>>,
    |        +++++++++++++++++++++++                       +
 
 error[E0740]: unions cannot contain fields that may need dropping
-  --> $DIR/field_checks.rs:33:5
+  --> $DIR/field_checks.rs:32:5
    |
 LL |     a: T,
    |     ^^^^
@@ -35,7 +35,7 @@ LL |     a: std::mem::ManuallyDrop<T>,
    |        +++++++++++++++++++++++ +
 
 error[E0740]: unions cannot contain fields that may need dropping
-  --> $DIR/field_checks.rs:45:5
+  --> $DIR/field_checks.rs:44:5
    |
 LL |     nest: U5,
    |     ^^^^^^^^
@@ -46,6 +46,18 @@ help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>
 LL |     nest: std::mem::ManuallyDrop<U5>,
    |           +++++++++++++++++++++++  +
 
-error: aborting due to 4 previous errors
+error[E0740]: unions cannot contain fields that may need dropping
+  --> $DIR/field_checks.rs:48:5
+   |
+LL |     nest: [U5; 0],
+   |     ^^^^^^^^^^^^^
+   |
+   = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type
+help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped
+   |
+LL |     nest: std::mem::ManuallyDrop<[U5; 0]>,
+   |           +++++++++++++++++++++++       +
+
+error: aborting due to 5 previous errors
 
 For more information about this error, try `rustc --explain E0740`.
diff --git a/src/test/ui/union/union-nonrepresentable.rs b/src/test/ui/union/union-nonrepresentable.rs
index afa73857ac2..4bdf7c6872f 100644
--- a/src/test/ui/union/union-nonrepresentable.rs
+++ b/src/test/ui/union/union-nonrepresentable.rs
@@ -1,4 +1,3 @@
-
 union U { //~ ERROR recursive type `U` has infinite size
     a: u8,
     b: std::mem::ManuallyDrop<U>,
diff --git a/src/test/ui/union/union-nonrepresentable.stderr b/src/test/ui/union/union-nonrepresentable.stderr
index a2380d8bc0e..9804b1418b2 100644
--- a/src/test/ui/union/union-nonrepresentable.stderr
+++ b/src/test/ui/union/union-nonrepresentable.stderr
@@ -1,5 +1,5 @@
 error[E0072]: recursive type `U` has infinite size
-  --> $DIR/union-nonrepresentable.rs:2:1
+  --> $DIR/union-nonrepresentable.rs:1:1
    |
 LL | union U {
    | ^^^^^^^ recursive type has infinite size
diff --git a/src/tools/clippy/tests/ui/derive.rs b/src/tools/clippy/tests/ui/derive.rs
index 4e46bf13991..b276c384c04 100644
--- a/src/tools/clippy/tests/ui/derive.rs
+++ b/src/tools/clippy/tests/ui/derive.rs
@@ -1,7 +1,7 @@
-#![feature(untagged_unions)]
 #![allow(dead_code)]
 #![warn(clippy::expl_impl_clone_on_copy)]
 
+
 #[derive(Copy)]
 struct Qux;
 
diff --git a/src/tools/clippy/tests/ui/no_effect.rs b/src/tools/clippy/tests/ui/no_effect.rs
index 7ece66a1ccb..f0c59b4080b 100644
--- a/src/tools/clippy/tests/ui/no_effect.rs
+++ b/src/tools/clippy/tests/ui/no_effect.rs
@@ -4,7 +4,7 @@
 #![allow(path_statements)]
 #![allow(clippy::deref_addrof)]
 #![allow(clippy::redundant_field_names)]
-#![feature(untagged_unions)]
+
 
 struct Unit;
 struct Tuple(i32);