about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNathaniel Hamovitz <18648574+nhamovitz@users.noreply.github.com>2021-10-18 03:13:48 -0700
committerNathaniel Hamovitz <18648574+nhamovitz@users.noreply.github.com>2021-10-18 03:13:48 -0700
commit6377fb2fe71a8bde91a20fbadc93242e19fd0dee (patch)
treeb1aac6f2cceae59b9d5cf4b2c0349d9bca3731ee
parentcd6862283ee603432f509510c53f35bda12e3a5a (diff)
downloadrust-6377fb2fe71a8bde91a20fbadc93242e19fd0dee.tar.gz
rust-6377fb2fe71a8bde91a20fbadc93242e19fd0dee.zip
Tidy import + update expected stderr
-rw-r--r--clippy_lints/src/trailing_zero_sized_array_without_repr_c.rs3
-rw-r--r--tests/ui/trailing_zero_sized_array_without_repr_c.stderr34
2 files changed, 26 insertions, 11 deletions
diff --git a/clippy_lints/src/trailing_zero_sized_array_without_repr_c.rs b/clippy_lints/src/trailing_zero_sized_array_without_repr_c.rs
index a759fff9cfc..aea2fb208df 100644
--- a/clippy_lints/src/trailing_zero_sized_array_without_repr_c.rs
+++ b/clippy_lints/src/trailing_zero_sized_array_without_repr_c.rs
@@ -1,6 +1,5 @@
 use clippy_utils::diagnostics::span_lint_and_help;
 use rustc_ast::Attribute;
-use rustc_hir::VariantData;
 use rustc_hir::{Item, ItemKind};
 use rustc_lint::{LateContext, LateLintPass};
 use rustc_middle::dep_graph::DepContext;
@@ -90,7 +89,7 @@ fn is_struct_with_trailing_zero_sized_array(cx: &LateContext<'tcx>, item: &'tcx
 
 fn has_repr_attr(cx: &LateContext<'tcx>, attrs: &[Attribute]) -> bool {
     // NOTE: there's at least four other ways to do this but I liked this one the best. (All five agreed
-    // on all testcases.) Happy to use another; they're in the commit history if you want to look (or I
+    // on all testcases (when i wrote this comment. I added a few since then).) Happy to use another; they're in the commit history if you want to look (or I
     // can go find them).
     attrs
         .iter()
diff --git a/tests/ui/trailing_zero_sized_array_without_repr_c.stderr b/tests/ui/trailing_zero_sized_array_without_repr_c.stderr
index ee8182cdc38..5ed91e937d5 100644
--- a/tests/ui/trailing_zero_sized_array_without_repr_c.stderr
+++ b/tests/ui/trailing_zero_sized_array_without_repr_c.stderr
@@ -1,5 +1,5 @@
 error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
-  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:5:1
+  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:6:1
    |
 LL | / struct RarelyUseful {
 LL | |     field: i32,
@@ -11,7 +11,7 @@ LL | | }
    = help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
 
 error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
-  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:10:1
+  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:11:1
    |
 LL | / struct OnlyField {
 LL | |     first_and_last: [usize; 0],
@@ -21,7 +21,7 @@ LL | | }
    = help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
 
 error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
-  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:14:1
+  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:15:1
    |
 LL | / struct GenericArrayType<T> {
 LL | |     field: i32,
@@ -32,7 +32,7 @@ LL | | }
    = help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
 
 error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
-  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:19:1
+  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:20:1
    |
 LL | / #[must_use]
 LL | | struct OnlyAnotherAttributeMustUse {
@@ -44,7 +44,7 @@ LL | | }
    = help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
 
 error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
-  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:28:1
+  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:29:1
    |
 LL | / struct OnlyAnotherAttributeDerive {
 LL | |     field: i32,
@@ -55,7 +55,7 @@ LL | | }
    = help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
 
 error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
-  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:34:1
+  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:35:1
    |
 LL | / struct ZeroSizedWithConst {
 LL | |     field: i32,
@@ -66,7 +66,7 @@ LL | | }
    = help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
 
 error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
-  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:43:1
+  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:44:1
    |
 LL | / struct ZeroSizedWithConstFunction {
 LL | |     field: i32,
@@ -77,7 +77,23 @@ LL | | }
    = help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
 
 error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
-  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:48:1
+  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:49:1
+   |
+LL | struct ZeroSizedArrayWrapper([usize; 0]);
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
+
+error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
+  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:51:1
+   |
+LL | struct TupleStruct(i32, [usize; 0]);
+   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+   = help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
+
+error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
+  --> $DIR/trailing_zero_sized_array_without_repr_c.rs:53:1
    |
 LL | / struct LotsOfFields {
 LL | |     f1: u32,
@@ -90,5 +106,5 @@ LL | | }
    |
    = help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
 
-error: aborting due to 8 previous errors
+error: aborting due to 10 previous errors