Tidy import + update expected stderr

This commit is contained in:
Nathaniel Hamovitz 2021-10-18 03:13:48 -07:00
parent cd6862283e
commit 6377fb2fe7
2 changed files with 26 additions and 11 deletions

View file

@ -1,6 +1,5 @@
use clippy_utils::diagnostics::span_lint_and_help; use clippy_utils::diagnostics::span_lint_and_help;
use rustc_ast::Attribute; use rustc_ast::Attribute;
use rustc_hir::VariantData;
use rustc_hir::{Item, ItemKind}; use rustc_hir::{Item, ItemKind};
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::dep_graph::DepContext; 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 { 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 // 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). // can go find them).
attrs attrs
.iter() .iter()

View file

@ -1,5 +1,5 @@
error: trailing zero-sized array in a struct which is not marked `#[repr(C)]` 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 | / struct RarelyUseful {
LL | | field: i32, LL | | field: i32,
@ -11,7 +11,7 @@ LL | | }
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute) = 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)]` 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 | / struct OnlyField {
LL | | first_and_last: [usize; 0], LL | | first_and_last: [usize; 0],
@ -21,7 +21,7 @@ LL | | }
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute) = 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)]` 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 | / struct GenericArrayType<T> {
LL | | field: i32, LL | | field: i32,
@ -32,7 +32,7 @@ LL | | }
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute) = 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)]` 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 | / #[must_use]
LL | | struct OnlyAnotherAttributeMustUse { LL | | struct OnlyAnotherAttributeMustUse {
@ -44,7 +44,7 @@ LL | | }
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute) = 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)]` 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 | / struct OnlyAnotherAttributeDerive {
LL | | field: i32, LL | | field: i32,
@ -55,7 +55,7 @@ LL | | }
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute) = 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)]` 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 | / struct ZeroSizedWithConst {
LL | | field: i32, LL | | field: i32,
@ -66,7 +66,7 @@ LL | | }
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute) = 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)]` 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 | / struct ZeroSizedWithConstFunction {
LL | | field: i32, LL | | field: i32,
@ -77,7 +77,23 @@ LL | | }
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute) = 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)]` 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 | / struct LotsOfFields {
LL | | f1: u32, LL | | f1: u32,
@ -90,5 +106,5 @@ LL | | }
| |
= help: consider annotating the struct definition with `#[repr(C)]` (or another `repr` attribute) = 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