From 698f8c2f01ea549d77d7dc3338a12e04c11057b9 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:02:58 +0200 Subject: Adding upstream version 1.64.0+dfsg1. Signed-off-by: Daniel Baumann --- src/test/ui/lint/dead-code/tuple-struct-field.rs | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/test/ui/lint/dead-code/tuple-struct-field.rs (limited to 'src/test/ui/lint/dead-code/tuple-struct-field.rs') diff --git a/src/test/ui/lint/dead-code/tuple-struct-field.rs b/src/test/ui/lint/dead-code/tuple-struct-field.rs new file mode 100644 index 000000000..b15d70636 --- /dev/null +++ b/src/test/ui/lint/dead-code/tuple-struct-field.rs @@ -0,0 +1,37 @@ +#![deny(unused_tuple_struct_fields)] +//~^ NOTE: the lint level is defined here + +use std::marker::PhantomData; + +const LEN: usize = 4; + +struct SingleUnused(i32, [u8; LEN], String); +//~^ ERROR: field `1` is never read +//~| NOTE: field in this struct +//~| HELP: consider changing the field to be of unit type + +struct MultipleUnused(i32, f32, String, u8); +//~^ ERROR: fields `0`, `1`, `2` and `3` are never read +//~| NOTE: fields in this struct +//~| HELP: consider changing the fields to be of unit type + +struct GoodUnit(()); + +struct GoodPhantom(PhantomData); + +struct Void; +struct GoodVoid(Void); + +fn main() { + let w = SingleUnused(42, [0, 1, 2, 3], "abc".to_string()); + let _ = w.0; + let _ = w.2; + + let m = MultipleUnused(42, 3.14, "def".to_string(), 4u8); + + let gu = GoodUnit(()); + let gp = GoodPhantom(PhantomData); + let gv = GoodVoid(Void); + + let _ = (gu, gp, gv, m); +} -- cgit v1.2.3