diff options
| author | bors <bors@rust-lang.org> | 2022-08-05 09:32:26 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2022-08-05 09:32:26 +0000 |
| commit | 9bbbf60b0442f1d56fc39f30274be77acc79164c (patch) | |
| tree | 1ce993d5a0b8f327611f5d4ab57c11ec3bd3c9e6 /src/test/codegen-units | |
| parent | cdfd675a63090182fd1c5f2ff58d8eaa115da156 (diff) | |
| parent | e3c7e04a4430942205872a8ed3c67531f22985bc (diff) | |
| download | rust-9bbbf60b0442f1d56fc39f30274be77acc79164c.tar.gz rust-9bbbf60b0442f1d56fc39f30274be77acc79164c.zip | |
Auto merge of #95977 - FabianWolff:issue-92790-dead-tuple, r=estebank
Warn about dead tuple struct fields Continuation of #92972. Fixes #92790. The language team has already commented on this in https://github.com/rust-lang/rust/pull/92972#issuecomment-1021511970; I have incorporated their requests here. Specifically, there is now a new allow-by-default `unused_tuple_struct_fields` lint (name bikesheddable), and fields of unit type are ignored (https://github.com/rust-lang/rust/pull/92972#issuecomment-1021815408), so error messages look like this: ``` error: field is never read: `1` --> $DIR/tuple-struct-field.rs:6:21 | LL | struct Wrapper(i32, [u8; LEN], String); | ^^^^^^^^^ | help: change the field to unit type to suppress this warning while preserving the field numbering | LL | struct Wrapper(i32, (), String); | ~~ ``` r? `@joshtriplett`
Diffstat (limited to 'src/test/codegen-units')
3 files changed, 8 insertions, 8 deletions
diff --git a/src/test/codegen-units/item-collection/generic-drop-glue.rs b/src/test/codegen-units/item-collection/generic-drop-glue.rs index 25cf5dad614..6df4ff7e58b 100644 --- a/src/test/codegen-units/item-collection/generic-drop-glue.rs +++ b/src/test/codegen-units/item-collection/generic-drop-glue.rs @@ -34,9 +34,9 @@ enum EnumNoDrop<T1, T2> { } -struct NonGenericNoDrop(i32); +struct NonGenericNoDrop(#[allow(unused_tuple_struct_fields)] i32); -struct NonGenericWithDrop(i32); +struct NonGenericWithDrop(#[allow(unused_tuple_struct_fields)] i32); //~ MONO_ITEM fn std::ptr::drop_in_place::<NonGenericWithDrop> - shim(Some(NonGenericWithDrop)) @@ generic_drop_glue-cgu.0[Internal] impl Drop for NonGenericWithDrop { diff --git a/src/test/codegen-units/item-collection/transitive-drop-glue.rs b/src/test/codegen-units/item-collection/transitive-drop-glue.rs index 8249e7cba94..e286c800b7c 100644 --- a/src/test/codegen-units/item-collection/transitive-drop-glue.rs +++ b/src/test/codegen-units/item-collection/transitive-drop-glue.rs @@ -6,9 +6,9 @@ #![feature(start)] //~ MONO_ITEM fn std::ptr::drop_in_place::<Root> - shim(Some(Root)) @@ transitive_drop_glue-cgu.0[Internal] -struct Root(Intermediate); +struct Root(#[allow(unused_tuple_struct_fields)] Intermediate); //~ MONO_ITEM fn std::ptr::drop_in_place::<Intermediate> - shim(Some(Intermediate)) @@ transitive_drop_glue-cgu.0[Internal] -struct Intermediate(Leaf); +struct Intermediate(#[allow(unused_tuple_struct_fields)] Leaf); //~ MONO_ITEM fn std::ptr::drop_in_place::<Leaf> - shim(Some(Leaf)) @@ transitive_drop_glue-cgu.0[Internal] struct Leaf; @@ -17,9 +17,9 @@ impl Drop for Leaf { fn drop(&mut self) {} } -struct RootGen<T>(IntermediateGen<T>); -struct IntermediateGen<T>(LeafGen<T>); -struct LeafGen<T>(T); +struct RootGen<T>(#[allow(unused_tuple_struct_fields)] IntermediateGen<T>); +struct IntermediateGen<T>(#[allow(unused_tuple_struct_fields)] LeafGen<T>); +struct LeafGen<T>(#[allow(unused_tuple_struct_fields)] T); impl<T> Drop for LeafGen<T> { fn drop(&mut self) {} diff --git a/src/test/codegen-units/item-collection/unsizing.rs b/src/test/codegen-units/item-collection/unsizing.rs index 81675377941..111a7231209 100644 --- a/src/test/codegen-units/item-collection/unsizing.rs +++ b/src/test/codegen-units/item-collection/unsizing.rs @@ -40,7 +40,7 @@ impl Trait for u32 { } #[derive(Clone, Copy)] -struct Wrapper<T: ?Sized>(*const T); +struct Wrapper<T: ?Sized>(#[allow(unused_tuple_struct_fields)] *const T); impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Wrapper<U>> for Wrapper<T> {} |
