Skip to content

Commit 6377fb2

Browse files
committed
Tidy import + update expected stderr
1 parent cd68622 commit 6377fb2

File tree

2 files changed

+26
-11
lines changed

2 files changed

+26
-11
lines changed

clippy_lints/src/trailing_zero_sized_array_without_repr_c.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
use clippy_utils::diagnostics::span_lint_and_help;
22
use rustc_ast::Attribute;
3-
use rustc_hir::VariantData;
43
use rustc_hir::{Item, ItemKind};
54
use rustc_lint::{LateContext, LateLintPass};
65
use rustc_middle::dep_graph::DepContext;
@@ -90,7 +89,7 @@ fn is_struct_with_trailing_zero_sized_array(cx: &LateContext<'tcx>, item: &'tcx
9089

9190
fn has_repr_attr(cx: &LateContext<'tcx>, attrs: &[Attribute]) -> bool {
9291
// NOTE: there's at least four other ways to do this but I liked this one the best. (All five agreed
93-
// on all testcases.) Happy to use another; they're in the commit history if you want to look (or I
92+
// 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
9493
// can go find them).
9594
attrs
9695
.iter()

tests/ui/trailing_zero_sized_array_without_repr_c.stderr

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
2-
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:5:1
2+
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:6:1
33
|
44
LL | / struct RarelyUseful {
55
LL | | field: i32,
@@ -11,7 +11,7 @@ LL | | }
1111
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
1212

1313
error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
14-
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:10:1
14+
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:11:1
1515
|
1616
LL | / struct OnlyField {
1717
LL | | first_and_last: [usize; 0],
@@ -21,7 +21,7 @@ LL | | }
2121
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
2222

2323
error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
24-
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:14:1
24+
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:15:1
2525
|
2626
LL | / struct GenericArrayType<T> {
2727
LL | | field: i32,
@@ -32,7 +32,7 @@ LL | | }
3232
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
3333

3434
error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
35-
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:19:1
35+
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:20:1
3636
|
3737
LL | / #[must_use]
3838
LL | | struct OnlyAnotherAttributeMustUse {
@@ -44,7 +44,7 @@ LL | | }
4444
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
4545

4646
error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
47-
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:28:1
47+
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:29:1
4848
|
4949
LL | / struct OnlyAnotherAttributeDerive {
5050
LL | | field: i32,
@@ -55,7 +55,7 @@ LL | | }
5555
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
5656

5757
error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
58-
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:34:1
58+
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:35:1
5959
|
6060
LL | / struct ZeroSizedWithConst {
6161
LL | | field: i32,
@@ -66,7 +66,7 @@ LL | | }
6666
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
6767

6868
error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
69-
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:43:1
69+
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:44:1
7070
|
7171
LL | / struct ZeroSizedWithConstFunction {
7272
LL | | field: i32,
@@ -77,7 +77,23 @@ LL | | }
7777
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
7878

7979
error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
80-
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:48:1
80+
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:49:1
81+
|
82+
LL | struct ZeroSizedArrayWrapper([usize; 0]);
83+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
84+
|
85+
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
86+
87+
error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
88+
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:51:1
89+
|
90+
LL | struct TupleStruct(i32, [usize; 0]);
91+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
92+
|
93+
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
94+
95+
error: trailing zero-sized array in a struct which is not marked `#[repr(C)]`
96+
--> $DIR/trailing_zero_sized_array_without_repr_c.rs:53:1
8197
|
8298
LL | / struct LotsOfFields {
8399
LL | | f1: u32,
@@ -90,5 +106,5 @@ LL | | }
90106
|
91107
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute)
92108

93-
error: aborting due to 8 previous errors
109+
error: aborting due to 10 previous errors
94110

0 commit comments

Comments
 (0)