From c4c7c76729ad5a20a017ea502128a42ab28d8c6a Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Wed, 29 Nov 2023 15:28:46 -0500 Subject: [PATCH 1/8] Address unused tuple struct fields in clippy --- .../src/methods/iter_overeager_cloned.rs | 8 ++++---- src/tools/clippy/clippy_lints/src/methods/mod.rs | 8 ++++---- .../clippy/clippy_lints/src/question_mark.rs | 5 ++--- .../src/transmute/transmute_undefined_repr.rs | 16 ++++++++-------- 4 files changed, 18 insertions(+), 19 deletions(-) diff --git a/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs b/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs index eac6df0545f..b2fe129cd95 100644 --- a/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs +++ b/src/tools/clippy/clippy_lints/src/methods/iter_overeager_cloned.rs @@ -22,7 +22,7 @@ pub(super) enum Op<'a> { // rm `.cloned()` // e.g. `map` `for_each` `all` `any` - NeedlessMove(&'a str, &'a Expr<'a>), + NeedlessMove(&'a Expr<'a>), // later `.cloned()` // and add `&` to the parameter of closure parameter @@ -59,7 +59,7 @@ pub(super) fn check<'tcx>( return; } - if let Op::NeedlessMove(_, expr) = op { + if let Op::NeedlessMove(expr) = op { let rustc_hir::ExprKind::Closure(closure) = expr.kind else { return; }; @@ -104,7 +104,7 @@ pub(super) fn check<'tcx>( } let (lint, msg, trailing_clone) = match op { - Op::RmCloned | Op::NeedlessMove(_, _) => (REDUNDANT_CLONE, "unneeded cloning of iterator items", ""), + Op::RmCloned | Op::NeedlessMove(_) => (REDUNDANT_CLONE, "unneeded cloning of iterator items", ""), Op::LaterCloned | Op::FixClosure(_, _) => ( ITER_OVEREAGER_CLONED, "unnecessarily eager cloning of iterator items", @@ -133,7 +133,7 @@ pub(super) fn check<'tcx>( diag.span_suggestion(replace_span, "try", snip, Applicability::MachineApplicable); } }, - Op::NeedlessMove(_, _) => { + Op::NeedlessMove(_) => { let method_span = expr.span.with_lo(cloned_call.span.hi()); if let Some(snip) = snippet_opt(cx, method_span) { let replace_span = expr.span.with_lo(cloned_recv.span.hi()); diff --git a/src/tools/clippy/clippy_lints/src/methods/mod.rs b/src/tools/clippy/clippy_lints/src/methods/mod.rs index 25b1ea526e2..c1e126137df 100644 --- a/src/tools/clippy/clippy_lints/src/methods/mod.rs +++ b/src/tools/clippy/clippy_lints/src/methods/mod.rs @@ -4186,7 +4186,7 @@ impl Methods { expr, recv, recv2, - iter_overeager_cloned::Op::NeedlessMove(name, arg), + iter_overeager_cloned::Op::NeedlessMove(arg), false, ); } @@ -4204,7 +4204,7 @@ impl Methods { expr, recv, recv2, - iter_overeager_cloned::Op::NeedlessMove(name, arg), + iter_overeager_cloned::Op::NeedlessMove(arg), false, ), Some(("chars", recv, _, _, _)) @@ -4379,7 +4379,7 @@ impl Methods { expr, recv, recv2, - iter_overeager_cloned::Op::NeedlessMove(name, arg), + iter_overeager_cloned::Op::NeedlessMove(arg), false, ), _ => {}, @@ -4433,7 +4433,7 @@ impl Methods { expr, recv, recv2, - iter_overeager_cloned::Op::NeedlessMove(name, m_arg), + iter_overeager_cloned::Op::NeedlessMove(m_arg), false, ), _ => {}, diff --git a/src/tools/clippy/clippy_lints/src/question_mark.rs b/src/tools/clippy/clippy_lints/src/question_mark.rs index 509d9483e1d..9469888a4d4 100644 --- a/src/tools/clippy/clippy_lints/src/question_mark.rs +++ b/src/tools/clippy/clippy_lints/src/question_mark.rs @@ -80,7 +80,6 @@ enum IfBlockType<'hir> { Ty<'hir>, Symbol, &'hir Expr<'hir>, - Option<&'hir Expr<'hir>>, ), /// An `if let Xxx(a) = b { c } else { d }` expression. /// @@ -143,7 +142,7 @@ fn check_let_some_else_return_none(cx: &LateContext<'_>, stmt: &Stmt<'_>) { fn is_early_return(smbl: Symbol, cx: &LateContext<'_>, if_block: &IfBlockType<'_>) -> bool { match *if_block { - IfBlockType::IfIs(caller, caller_ty, call_sym, if_then, _) => { + IfBlockType::IfIs(caller, caller_ty, call_sym, if_then) => { // If the block could be identified as `if x.is_none()/is_err()`, // we then only need to check the if_then return to see if it is none/err. is_type_diagnostic_item(cx, caller_ty, smbl) @@ -235,7 +234,7 @@ impl QuestionMark { && !is_else_clause(cx.tcx, expr) && let ExprKind::MethodCall(segment, caller, ..) = &cond.kind && let caller_ty = cx.typeck_results().expr_ty(caller) - && let if_block = IfBlockType::IfIs(caller, caller_ty, segment.ident.name, then, r#else) + && let if_block = IfBlockType::IfIs(caller, caller_ty, segment.ident.name, then) && (is_early_return(sym::Option, cx, &if_block) || is_early_return(sym::Result, cx, &if_block)) { let mut applicability = Applicability::MachineApplicable; diff --git a/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs b/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs index a65bc0ce458..db378cfd755 100644 --- a/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs +++ b/src/tools/clippy/clippy_lints/src/transmute/transmute_undefined_repr.rs @@ -26,18 +26,18 @@ pub(super) fn check<'tcx>( // `Repr(C)` <-> unordered type. // If the first field of the `Repr(C)` type matches then the transmute is ok - (ReducedTy::OrderedFields(_, Some(from_sub_ty)), ReducedTy::UnorderedFields(to_sub_ty)) - | (ReducedTy::UnorderedFields(from_sub_ty), ReducedTy::OrderedFields(_, Some(to_sub_ty))) => { + (ReducedTy::OrderedFields(Some(from_sub_ty)), ReducedTy::UnorderedFields(to_sub_ty)) + | (ReducedTy::UnorderedFields(from_sub_ty), ReducedTy::OrderedFields(Some(to_sub_ty))) => { from_ty = from_sub_ty; to_ty = to_sub_ty; continue; }, - (ReducedTy::OrderedFields(_, Some(from_sub_ty)), ReducedTy::Other(to_sub_ty)) if reduced_tys.to_fat_ptr => { + (ReducedTy::OrderedFields(Some(from_sub_ty)), ReducedTy::Other(to_sub_ty)) if reduced_tys.to_fat_ptr => { from_ty = from_sub_ty; to_ty = to_sub_ty; continue; }, - (ReducedTy::Other(from_sub_ty), ReducedTy::OrderedFields(_, Some(to_sub_ty))) + (ReducedTy::Other(from_sub_ty), ReducedTy::OrderedFields(Some(to_sub_ty))) if reduced_tys.from_fat_ptr => { from_ty = from_sub_ty; @@ -235,8 +235,8 @@ enum ReducedTy<'tcx> { TypeErasure { raw_ptr_only: bool }, /// The type is a struct containing either zero non-zero sized fields, or multiple non-zero /// sized fields with a defined order. - /// The second value is the first non-zero sized type. - OrderedFields(Ty<'tcx>, Option>), + /// The value is the first non-zero sized type. + OrderedFields(Option>), /// The type is a struct containing multiple non-zero sized fields with no defined order. UnorderedFields(Ty<'tcx>), /// Any other type. @@ -259,7 +259,7 @@ fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx> ty::Tuple(args) => { let mut iter = args.iter(); let Some(sized_ty) = iter.find(|&ty| !is_zero_sized_ty(cx, ty)) else { - return ReducedTy::OrderedFields(ty, None); + return ReducedTy::OrderedFields(None); }; if iter.all(|ty| is_zero_sized_ty(cx, ty)) { ty = sized_ty; @@ -281,7 +281,7 @@ fn reduce_ty<'tcx>(cx: &LateContext<'tcx>, mut ty: Ty<'tcx>) -> ReducedTy<'tcx> continue; } if def.repr().inhibit_struct_field_reordering_opt() { - ReducedTy::OrderedFields(ty, Some(sized_ty)) + ReducedTy::OrderedFields(Some(sized_ty)) } else { ReducedTy::UnorderedFields(ty) } From 2f6fc0518609ab08aaa14c6bfda608052056bb6b Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Wed, 29 Nov 2023 15:39:20 -0500 Subject: [PATCH 2/8] Address unused tuple struct fields in rustfmt --- src/tools/rustfmt/src/expr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index 7808f891336..8dead8f078d 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -1947,7 +1947,7 @@ fn rewrite_unary_op( } pub(crate) enum RhsAssignKind<'ast> { - Expr(&'ast ast::ExprKind, Span), + Expr(&'ast ast::ExprKind, #[allow(unused_tuple_struct_fields)] Span), Bounds, Ty, } From 9fcf9c141068984ffcbb4cb00c83d891043761e8 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Sun, 26 Nov 2023 14:48:34 -0500 Subject: [PATCH 3/8] Merge `unused_tuple_struct_fields` into `dead_code` This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group. --- compiler/rustc_lint/src/lib.rs | 1 + compiler/rustc_lint_defs/src/builtin.rs | 36 +++------------ compiler/rustc_passes/src/dead.rs | 58 +++++++++++++++---------- 3 files changed, 43 insertions(+), 52 deletions(-) diff --git a/compiler/rustc_lint/src/lib.rs b/compiler/rustc_lint/src/lib.rs index 93904fb5c56..76c630fc456 100644 --- a/compiler/rustc_lint/src/lib.rs +++ b/compiler/rustc_lint/src/lib.rs @@ -328,6 +328,7 @@ fn register_builtins(store: &mut LintStore) { store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures"); store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns"); store.register_renamed("non_fmt_panic", "non_fmt_panics"); + store.register_renamed("unused_tuple_struct_fields", "dead_code"); // These were moved to tool lints, but rustc still sees them when compiling normally, before // tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use diff --git a/compiler/rustc_lint_defs/src/builtin.rs b/compiler/rustc_lint_defs/src/builtin.rs index 399e6968fae..9158579bea3 100644 --- a/compiler/rustc_lint_defs/src/builtin.rs +++ b/compiler/rustc_lint_defs/src/builtin.rs @@ -125,7 +125,6 @@ declare_lint_pass! { UNUSED_MACROS, UNUSED_MUT, UNUSED_QUALIFICATIONS, - UNUSED_TUPLE_STRUCT_FIELDS, UNUSED_UNSAFE, UNUSED_VARIABLES, USELESS_DEPRECATED, @@ -697,8 +696,13 @@ declare_lint! { /// Dead code may signal a mistake or unfinished code. To silence the /// warning for individual items, prefix the name with an underscore such /// as `_foo`. If it was intended to expose the item outside of the crate, - /// consider adding a visibility modifier like `pub`. Otherwise consider - /// removing the unused code. + /// consider adding a visibility modifier like `pub`. + /// + /// To preserve the numbering of tuple structs with unused fields, + /// change the unused fields to have unit type or use + /// `PhantomData`. + /// + /// Otherwise consider removing the unused code. pub DEAD_CODE, Warn, "detect unused, unexported items" @@ -732,32 +736,6 @@ declare_lint! { "detects attributes that were not used by the compiler" } -declare_lint! { - /// The `unused_tuple_struct_fields` lint detects fields of tuple structs - /// that are never read. - /// - /// ### Example - /// - /// ```rust - /// #[warn(unused_tuple_struct_fields)] - /// struct S(i32, i32, i32); - /// let s = S(1, 2, 3); - /// let _ = (s.0, s.2); - /// ``` - /// - /// {{produces}} - /// - /// ### Explanation - /// - /// Tuple struct fields that are never read anywhere may indicate a - /// mistake or unfinished code. To silence this warning, consider - /// removing the unused field(s) or, to preserve the numbering of the - /// remaining fields, change the unused field(s) to have unit type. - pub UNUSED_TUPLE_STRUCT_FIELDS, - Allow, - "detects tuple struct fields that are never read" -} - declare_lint! { /// The `unreachable_code` lint detects unreachable code paths. /// diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 22aac1e775e..ac2ca23ad41 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -15,8 +15,8 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags; use rustc_middle::middle::privacy::Level; use rustc_middle::query::Providers; use rustc_middle::ty::{self, TyCtxt}; -use rustc_session::lint::builtin::{DEAD_CODE, UNUSED_TUPLE_STRUCT_FIELDS}; -use rustc_session::lint::{self, Lint, LintId}; +use rustc_session::lint; +use rustc_session::lint::builtin::DEAD_CODE; use rustc_span::symbol::{sym, Symbol}; use rustc_target::abi::FieldIdx; use std::mem; @@ -766,6 +766,12 @@ enum ShouldWarnAboutField { No, } +#[derive(Debug, Copy, Clone, PartialEq, Eq)] +enum ReportOn { + TupleField, + NamedField, +} + impl<'tcx> DeadVisitor<'tcx> { fn should_warn_about_field(&mut self, field: &ty::FieldDef) -> ShouldWarnAboutField { if self.live_symbols.contains(&field.did.expect_local()) { @@ -787,9 +793,9 @@ impl<'tcx> DeadVisitor<'tcx> { ShouldWarnAboutField::Yes } - fn def_lint_level(&self, lint: &'static Lint, id: LocalDefId) -> lint::Level { + fn def_lint_level(&self, id: LocalDefId) -> lint::Level { let hir_id = self.tcx.local_def_id_to_hir_id(id); - self.tcx.lint_level_at_node(lint, hir_id).0 + self.tcx.lint_level_at_node(DEAD_CODE, hir_id).0 } // # Panics @@ -803,7 +809,7 @@ impl<'tcx> DeadVisitor<'tcx> { dead_codes: &[&DeadItem], participle: &str, parent_item: Option, - lint: &'static Lint, + report_on: ReportOn, ) { let Some(&first_item) = dead_codes.first() else { return; @@ -864,8 +870,8 @@ impl<'tcx> DeadVisitor<'tcx> { None }; - let diag = if LintId::of(lint) == LintId::of(UNUSED_TUPLE_STRUCT_FIELDS) { - MultipleDeadCodes::UnusedTupleStructFields { + let diag = match report_on { + ReportOn::TupleField => MultipleDeadCodes::UnusedTupleStructFields { multiple, num, descr, @@ -874,9 +880,9 @@ impl<'tcx> DeadVisitor<'tcx> { change_fields_suggestion: ChangeFieldsToBeOfUnitType { num, spans: spans.clone() }, parent_info, ignored_derived_impls, - } - } else { - MultipleDeadCodes::DeadCodes { + }, + + ReportOn::NamedField => MultipleDeadCodes::DeadCodes { multiple, num, descr, @@ -884,11 +890,11 @@ impl<'tcx> DeadVisitor<'tcx> { name_list, parent_info, ignored_derived_impls, - } + }, }; let hir_id = tcx.local_def_id_to_hir_id(first_item.def_id); - self.tcx.emit_spanned_lint(lint, hir_id, MultiSpan::from_spans(spans), diag); + self.tcx.emit_spanned_lint(DEAD_CODE, hir_id, MultiSpan::from_spans(spans), diag); } fn warn_multiple( @@ -896,7 +902,7 @@ impl<'tcx> DeadVisitor<'tcx> { def_id: LocalDefId, participle: &str, dead_codes: Vec, - lint: &'static Lint, + report_on: ReportOn, ) { let mut dead_codes = dead_codes .iter() @@ -907,7 +913,7 @@ impl<'tcx> DeadVisitor<'tcx> { } dead_codes.sort_by_key(|v| v.level); for group in dead_codes[..].group_by(|a, b| a.level == b.level) { - self.lint_at_single_level(&group, participle, Some(def_id), lint); + self.lint_at_single_level(&group, participle, Some(def_id), report_on); } } @@ -915,9 +921,9 @@ impl<'tcx> DeadVisitor<'tcx> { let item = DeadItem { def_id: id, name: self.tcx.item_name(id.to_def_id()), - level: self.def_lint_level(DEAD_CODE, id), + level: self.def_lint_level(id), }; - self.lint_at_single_level(&[&item], participle, None, DEAD_CODE); + self.lint_at_single_level(&[&item], participle, None, ReportOn::NamedField); } fn check_definition(&mut self, def_id: LocalDefId) { @@ -964,12 +970,12 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) { let def_id = item.id.owner_id.def_id; if !visitor.is_live_code(def_id) { let name = tcx.item_name(def_id.to_def_id()); - let level = visitor.def_lint_level(DEAD_CODE, def_id); + let level = visitor.def_lint_level(def_id); dead_items.push(DeadItem { def_id, name, level }) } } - visitor.warn_multiple(item.owner_id.def_id, "used", dead_items, DEAD_CODE); + visitor.warn_multiple(item.owner_id.def_id, "used", dead_items, ReportOn::NamedField); } if !live_symbols.contains(&item.owner_id.def_id) { @@ -991,7 +997,7 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) { let def_id = variant.def_id.expect_local(); if !live_symbols.contains(&def_id) { // Record to group diagnostics. - let level = visitor.def_lint_level(DEAD_CODE, def_id); + let level = visitor.def_lint_level(def_id); dead_variants.push(DeadItem { def_id, name: variant.name, level }); continue; } @@ -999,24 +1005,30 @@ fn check_mod_deathness(tcx: TyCtxt<'_>, module: LocalModDefId) { let is_positional = variant.fields.raw.first().map_or(false, |field| { field.name.as_str().starts_with(|c: char| c.is_ascii_digit()) }); - let lint = if is_positional { UNUSED_TUPLE_STRUCT_FIELDS } else { DEAD_CODE }; + let report_on = + if is_positional { ReportOn::TupleField } else { ReportOn::NamedField }; let dead_fields = variant .fields .iter() .filter_map(|field| { let def_id = field.did.expect_local(); if let ShouldWarnAboutField::Yes = visitor.should_warn_about_field(field) { - let level = visitor.def_lint_level(lint, def_id); + let level = visitor.def_lint_level(def_id); Some(DeadItem { def_id, name: field.name, level }) } else { None } }) .collect(); - visitor.warn_multiple(def_id, "read", dead_fields, lint); + visitor.warn_multiple(def_id, "read", dead_fields, report_on); } - visitor.warn_multiple(item.owner_id.def_id, "constructed", dead_variants, DEAD_CODE); + visitor.warn_multiple( + item.owner_id.def_id, + "constructed", + dead_variants, + ReportOn::NamedField, + ); } } From 5772818dc8f4c5a0fec1f5b35b33e85764dcd4f4 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Wed, 27 Dec 2023 18:03:23 -0500 Subject: [PATCH 4/8] Adjust library tests for unused_tuple_struct_fields -> dead_code --- library/alloc/src/boxed.rs | 1 + library/alloc/src/boxed/thin.rs | 2 +- .../alloc/src/collections/btree/set/tests.rs | 2 +- .../alloc/src/collections/vec_deque/tests.rs | 2 +- library/alloc/tests/autotraits.rs | 2 +- library/alloc/tests/vec.rs | 6 +-- library/core/benches/slice.rs | 4 +- library/core/tests/any.rs | 2 +- library/core/tests/array.rs | 2 +- library/core/tests/atomic.rs | 2 +- library/core/tests/intrinsics.rs | 6 +-- library/core/tests/ptr.rs | 38 +++++++++---------- library/core/tests/slice.rs | 6 +-- library/std/src/collections/hash/set/tests.rs | 2 +- 14 files changed, 39 insertions(+), 38 deletions(-) diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index fdf5e134f4d..6977681e5a3 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -24,6 +24,7 @@ //! Creating a recursive data structure: //! //! ``` +//! ##[allow(dead_code)] //! #[derive(Debug)] //! enum List { //! Cons(T, Box>), diff --git a/library/alloc/src/boxed/thin.rs b/library/alloc/src/boxed/thin.rs index a8005b7067d..9463b73b574 100644 --- a/library/alloc/src/boxed/thin.rs +++ b/library/alloc/src/boxed/thin.rs @@ -171,7 +171,7 @@ struct WithHeader(NonNull, PhantomData); /// An opaque representation of `WithHeader` to avoid the /// projection invariance of `::Metadata`. #[repr(transparent)] -#[allow(unused_tuple_struct_fields)] // Field only used through `WithHeader` type above. +#[allow(dead_code)] // Field only used through `WithHeader` type above. struct WithOpaqueHeader(NonNull); impl WithOpaqueHeader { diff --git a/library/alloc/src/collections/btree/set/tests.rs b/library/alloc/src/collections/btree/set/tests.rs index 8726c5bfead..688ce57e9da 100644 --- a/library/alloc/src/collections/btree/set/tests.rs +++ b/library/alloc/src/collections/btree/set/tests.rs @@ -524,7 +524,7 @@ fn test_extend_ref() { #[test] fn test_recovery() { #[derive(Debug)] - struct Foo(&'static str, i32); + struct Foo(&'static str, #[allow(dead_code)] i32); impl PartialEq for Foo { fn eq(&self, other: &Self) -> bool { diff --git a/library/alloc/src/collections/vec_deque/tests.rs b/library/alloc/src/collections/vec_deque/tests.rs index b7fdebfa60b..f8ce4ca9788 100644 --- a/library/alloc/src/collections/vec_deque/tests.rs +++ b/library/alloc/src/collections/vec_deque/tests.rs @@ -1085,7 +1085,7 @@ fn test_clone_from() { fn test_vec_deque_truncate_drop() { static mut DROPS: u32 = 0; #[derive(Clone)] - struct Elem(i32); + struct Elem(#[allow(dead_code)] i32); impl Drop for Elem { fn drop(&mut self) { unsafe { diff --git a/library/alloc/tests/autotraits.rs b/library/alloc/tests/autotraits.rs index b41e457614e..ba5e28f7293 100644 --- a/library/alloc/tests/autotraits.rs +++ b/library/alloc/tests/autotraits.rs @@ -1,7 +1,7 @@ fn require_sync(_: T) {} fn require_send_sync(_: T) {} -struct NotSend(*const ()); +struct NotSend(#[allow(dead_code)] *const ()); unsafe impl Sync for NotSend {} #[test] diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs index 364dc920187..9ec6f6ae1ac 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -547,7 +547,7 @@ fn test_cmp() { #[test] fn test_vec_truncate_drop() { static mut DROPS: u32 = 0; - struct Elem(i32); + struct Elem(#[allow(dead_code)] i32); impl Drop for Elem { fn drop(&mut self) { unsafe { @@ -1089,7 +1089,7 @@ fn test_into_iter_advance_by() { #[test] fn test_into_iter_drop_allocator() { - struct ReferenceCountedAllocator<'a>(DropCounter<'a>); + struct ReferenceCountedAllocator<'a>(#[allow(dead_code)] DropCounter<'a>); unsafe impl Allocator for ReferenceCountedAllocator<'_> { fn allocate(&self, layout: Layout) -> Result, core::alloc::AllocError> { @@ -2407,7 +2407,7 @@ fn test_vec_dedup_multiple_ident() { #[test] fn test_vec_dedup_partialeq() { #[derive(Debug)] - struct Foo(i32, i32); + struct Foo(i32, #[allow(dead_code)] i32); impl PartialEq for Foo { fn eq(&self, other: &Foo) -> bool { diff --git a/library/core/benches/slice.rs b/library/core/benches/slice.rs index 3bfb35e684e..8f87a211449 100644 --- a/library/core/benches/slice.rs +++ b/library/core/benches/slice.rs @@ -91,7 +91,7 @@ fn binary_search_l3_worst_case(b: &mut Bencher) { } #[derive(Clone)] -struct Rgb(u8, u8, u8); +struct Rgb(#[allow(dead_code)] u8, #[allow(dead_code)] u8, #[allow(dead_code)] u8); impl Rgb { fn gen(i: usize) -> Self { @@ -154,7 +154,7 @@ swap_with_slice!(swap_with_slice_5x_usize_3000, 3000, |i| [i; 5]); #[bench] fn fill_byte_sized(b: &mut Bencher) { #[derive(Copy, Clone)] - struct NewType(u8); + struct NewType(#[allow(dead_code)] u8); let mut ary = [NewType(0); 1024]; diff --git a/library/core/tests/any.rs b/library/core/tests/any.rs index 8d2d31b6431..25002617d0b 100644 --- a/library/core/tests/any.rs +++ b/library/core/tests/any.rs @@ -122,7 +122,7 @@ fn any_unsized() { fn distinct_type_names() { // https://github.com/rust-lang/rust/issues/84666 - struct Velocity(f32, f32); + struct Velocity(#[allow(dead_code)] f32, #[allow(dead_code)] f32); fn type_name_of_val(_: T) -> &'static str { type_name::() diff --git a/library/core/tests/array.rs b/library/core/tests/array.rs index 3656eecca50..b1c1456ade1 100644 --- a/library/core/tests/array.rs +++ b/library/core/tests/array.rs @@ -262,7 +262,7 @@ fn array_default_impl_avoids_leaks_on_panic() { use core::sync::atomic::{AtomicUsize, Ordering::Relaxed}; static COUNTER: AtomicUsize = AtomicUsize::new(0); #[derive(Debug)] - struct Bomb(usize); + struct Bomb(#[allow(dead_code)] usize); impl Default for Bomb { fn default() -> Bomb { diff --git a/library/core/tests/atomic.rs b/library/core/tests/atomic.rs index a67a842d340..0d1c72a6892 100644 --- a/library/core/tests/atomic.rs +++ b/library/core/tests/atomic.rs @@ -188,7 +188,7 @@ fn ptr_bitops() { #[cfg(any(not(target_arch = "arm"), target_os = "linux"))] // Missing intrinsic in compiler-builtins fn ptr_bitops_tagging() { #[repr(align(16))] - struct Tagme(u128); + struct Tagme(#[allow(dead_code)] u128); let tagme = Tagme(1000); let ptr = &tagme as *const Tagme as *mut Tagme; diff --git a/library/core/tests/intrinsics.rs b/library/core/tests/intrinsics.rs index 06870c6d06c..740565d0df6 100644 --- a/library/core/tests/intrinsics.rs +++ b/library/core/tests/intrinsics.rs @@ -4,7 +4,7 @@ use core::intrinsics::assume; #[test] fn test_typeid_sized_types() { struct X; - struct Y(u32); + struct Y(#[allow(dead_code)] u32); assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(TypeId::of::(), TypeId::of::()); @@ -14,8 +14,8 @@ fn test_typeid_sized_types() { #[test] fn test_typeid_unsized_types() { trait Z {} - struct X(str); - struct Y(dyn Z + 'static); + struct X(#[allow(dead_code)] str); + struct Y(#[allow(dead_code)] dyn Z + 'static); assert_eq!(TypeId::of::(), TypeId::of::()); assert_eq!(TypeId::of::(), TypeId::of::()); diff --git a/library/core/tests/ptr.rs b/library/core/tests/ptr.rs index ee885adfeee..238f29c5980 100644 --- a/library/core/tests/ptr.rs +++ b/library/core/tests/ptr.rs @@ -451,34 +451,34 @@ fn align_offset_various_strides() { for ptr in 1usize..4 * align { unsafe { #[repr(packed)] - struct A3(u16, u8); + struct A3(#[allow(dead_code)] u16, #[allow(dead_code)] u8); x |= test_stride::(ptr::invalid::(ptr), align); - struct A4(u32); + struct A4(#[allow(dead_code)] u32); x |= test_stride::(ptr::invalid::(ptr), align); #[repr(packed)] - struct A5(u32, u8); + struct A5(#[allow(dead_code)] u32, #[allow(dead_code)] u8); x |= test_stride::(ptr::invalid::(ptr), align); #[repr(packed)] - struct A6(u32, u16); + struct A6(#[allow(dead_code)] u32, #[allow(dead_code)] u16); x |= test_stride::(ptr::invalid::(ptr), align); #[repr(packed)] - struct A7(u32, u16, u8); + struct A7(#[allow(dead_code)] u32, #[allow(dead_code)] u16, #[allow(dead_code)] u8); x |= test_stride::(ptr::invalid::(ptr), align); #[repr(packed)] - struct A8(u32, u32); + struct A8(#[allow(dead_code)] u32, #[allow(dead_code)] u32); x |= test_stride::(ptr::invalid::(ptr), align); #[repr(packed)] - struct A9(u32, u32, u8); + struct A9(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u8); x |= test_stride::(ptr::invalid::(ptr), align); #[repr(packed)] - struct A10(u32, u32, u16); + struct A10(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u16); x |= test_stride::(ptr::invalid::(ptr), align); x |= test_stride::(ptr::invalid::(ptr), align); @@ -517,34 +517,34 @@ fn align_offset_various_strides_const() { while ptr < 4 * align { unsafe { #[repr(packed)] - struct A3(u16, u8); + struct A3(#[allow(dead_code)] u16, #[allow(dead_code)] u8); test_stride::(ptr::invalid::(ptr), ptr, align); - struct A4(u32); + struct A4(#[allow(dead_code)] u32); test_stride::(ptr::invalid::(ptr), ptr, align); #[repr(packed)] - struct A5(u32, u8); + struct A5(#[allow(dead_code)] u32, #[allow(dead_code)] u8); test_stride::(ptr::invalid::(ptr), ptr, align); #[repr(packed)] - struct A6(u32, u16); + struct A6(#[allow(dead_code)] u32, #[allow(dead_code)] u16); test_stride::(ptr::invalid::(ptr), ptr, align); #[repr(packed)] - struct A7(u32, u16, u8); + struct A7(#[allow(dead_code)] u32, #[allow(dead_code)] u16, #[allow(dead_code)] u8); test_stride::(ptr::invalid::(ptr), ptr, align); #[repr(packed)] - struct A8(u32, u32); + struct A8(#[allow(dead_code)] u32, #[allow(dead_code)] u32); test_stride::(ptr::invalid::(ptr), ptr, align); #[repr(packed)] - struct A9(u32, u32, u8); + struct A9(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u8); test_stride::(ptr::invalid::(ptr), ptr, align); #[repr(packed)] - struct A10(u32, u32, u16); + struct A10(#[allow(dead_code)] u32, #[allow(dead_code)] u32, #[allow(dead_code)] u16); test_stride::(ptr::invalid::(ptr), ptr, align); test_stride::(ptr::invalid::(ptr), ptr, align); @@ -672,7 +672,7 @@ fn align_offset_issue_103361() { const SIZE: usize = 1 << 30; #[cfg(target_pointer_width = "16")] const SIZE: usize = 1 << 13; - struct HugeSize([u8; SIZE - 1]); + struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]); let _ = ptr::invalid::(SIZE).align_offset(SIZE); } @@ -684,7 +684,7 @@ fn align_offset_issue_103361_const() { const SIZE: usize = 1 << 30; #[cfg(target_pointer_width = "16")] const SIZE: usize = 1 << 13; - struct HugeSize([u8; SIZE - 1]); + struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]); const { assert!(ptr::invalid::(SIZE - 1).align_offset(SIZE) == SIZE - 1); @@ -834,7 +834,7 @@ fn ptr_metadata_bounds() { fn dyn_metadata() { #[derive(Debug)] #[repr(align(32))] - struct Something([u8; 47]); + struct Something(#[allow(dead_code)] [u8; 47]); let value = Something([0; 47]); let trait_object: &dyn Debug = &value; diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs index 33a30339856..cc1fc7e4d7e 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs @@ -2109,9 +2109,9 @@ fn test_align_to_zst() { #[test] fn test_align_to_non_trivial() { #[repr(align(8))] - struct U64(u64, u64); + struct U64(#[allow(dead_code)] u64, #[allow(dead_code)] u64); #[repr(align(8))] - struct U64U64U32(u64, u64, u32); + struct U64U64U32(#[allow(dead_code)] u64, #[allow(dead_code)] u64, #[allow(dead_code)] u32); let data = [ U64(1, 2), U64(3, 4), @@ -2196,7 +2196,7 @@ fn test_slice_partition_dedup_multiple_ident() { #[test] fn test_slice_partition_dedup_partialeq() { #[derive(Debug)] - struct Foo(i32, i32); + struct Foo(i32, #[allow(dead_code)] i32); impl PartialEq for Foo { fn eq(&self, other: &Foo) -> bool { diff --git a/library/std/src/collections/hash/set/tests.rs b/library/std/src/collections/hash/set/tests.rs index 208f61e755c..a1884090043 100644 --- a/library/std/src/collections/hash/set/tests.rs +++ b/library/std/src/collections/hash/set/tests.rs @@ -352,7 +352,7 @@ fn test_replace() { use crate::hash; #[derive(Debug)] - struct Foo(&'static str, i32); + struct Foo(&'static str, #[allow(dead_code)] i32); impl PartialEq for Foo { fn eq(&self, other: &Self) -> bool { From 53eca9fa877460973f29aca24e6636a4175df469 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Wed, 27 Dec 2023 17:11:58 -0500 Subject: [PATCH 5/8] Adjust compiler tests for unused_tuple_struct_fields -> dead_code --- .../item-collection/generic-drop-glue.rs | 4 ++-- .../item-collection/transitive-drop-glue.rs | 10 +++++----- tests/codegen-units/item-collection/unsizing.rs | 2 +- .../no_std-alloc-error-handler-custom.rs | 2 +- .../no_std-alloc-error-handler-default.rs | 2 +- tests/ui/array-slice-vec/show-boxed-slice.rs | 2 +- .../associated-const-type-parameters.rs | 2 +- .../associated-types/associated-types-method.rs | 2 +- .../associated-types-struct-field-numbered.rs | 2 +- tests/ui/associated-types/issue-25700-1.rs | 2 +- tests/ui/associated-types/issue-25700-2.rs | 4 ++-- tests/ui/associated-types/issue-25700.rs | 2 +- .../ui/async-await/async-fn-size-moved-locals.rs | 2 +- .../async-await/async-fn-size-uninit-locals.rs | 2 +- tests/ui/auto-traits/auto-traits.rs | 2 +- tests/ui/bench/issue-32062.rs | 4 ++-- tests/ui/binding/match-tag.rs | 2 +- tests/ui/binding/or-pattern.rs | 2 +- tests/ui/binding/simple-generic-match.rs | 2 +- .../builtin-superkinds-in-metadata2.rs | 2 +- .../migrations/auto_traits.fixed | 4 ++-- .../migrations/auto_traits.rs | 4 ++-- .../migrations/multi_diagnostics.fixed | 4 ++-- .../migrations/multi_diagnostics.rs | 4 ++-- .../migrations/significant_drop.fixed | 2 +- .../migrations/significant_drop.rs | 2 +- tests/ui/codegen/issue-16602-3.rs | 2 +- tests/ui/coercion/issue-14589.rs | 2 +- .../const-generics/const-argument-cross-crate.rs | 2 +- .../generic_const_exprs/associated-consts.rs | 2 +- .../const-generics/inhabited-assoc-ty-ice-1.rs | 2 +- .../const-generics/inhabited-assoc-ty-ice-2.rs | 2 +- tests/ui/consts/assoc-const.rs | 2 +- tests/ui/consts/const-needs_drop.rs | 4 ++-- .../ui/consts/const-size_of_val-align_of_val.rs | 2 +- .../null-raw-ptr-issue-119270.rs | 2 +- .../consts/const_in_pattern/warn_corner_cases.rs | 2 +- .../ui/consts/issue-70773-mir-typeck-lt-norm.rs | 2 +- tests/ui/consts/promoted_const_call4.rs | 2 +- tests/ui/consts/rvalue-static-promotion.rs | 2 +- tests/ui/consts/transmute-const.rs | 2 +- tests/ui/coroutine/size-moved-locals.rs | 2 +- tests/ui/derive-uninhabited-enum-38885.rs | 2 +- tests/ui/derive-uninhabited-enum-38885.stderr | 2 +- .../deriving-clone-generic-tuple-struct.rs | 2 +- tests/ui/deriving/deriving-copyclone.rs | 2 +- tests/ui/deriving/issue-58319.rs | 2 +- tests/ui/drop/dropck-eyepatch-reorder.rs | 8 ++++---- tests/ui/drop/dropck-eyepatch.rs | 8 ++++---- tests/ui/drop/dynamic-drop.rs | 2 +- tests/ui/dropck/issue-24805-dropck-itemless.rs | 2 +- .../dropck/issue-28498-ugeh-with-passed-to-fn.rs | 2 +- tests/ui/dyn-star/drop.rs | 2 +- .../discriminant_value-wrapper.rs | 2 +- tests/ui/enum-discriminant/discriminant_value.rs | 4 ++-- .../generic-default-type-params-cross-crate.rs | 2 +- tests/ui/generics/generic-ivec-leak.rs | 2 +- tests/ui/generics/generic-newtype-struct.rs | 2 +- tests/ui/generics/generic-no-mangle.fixed | 4 ++-- tests/ui/generics/generic-no-mangle.rs | 4 ++-- tests/ui/generics/generic-recursive-tag.rs | 2 +- tests/ui/generics/generic-tag-corruption.rs | 2 +- tests/ui/generics/generic-tag-local.rs | 2 +- tests/ui/generics/generic-tag.rs | 2 +- tests/ui/impl-trait/bounds_regression.rs | 2 +- tests/ui/inference/issue-36053.rs | 2 +- tests/ui/issues/issue-13027.rs | 2 +- tests/ui/issues/issue-14382.rs | 2 +- tests/ui/issues/issue-15858.rs | 2 +- tests/ui/issues/issue-17905.rs | 2 +- tests/ui/issues/issue-23491.rs | 2 +- tests/ui/issues/issue-24308.rs | 2 +- tests/ui/issues/issue-25089.rs | 2 +- tests/ui/issues/issue-25679.rs | 2 +- tests/ui/issues/issue-26127.rs | 2 +- tests/ui/issues/issue-26641.rs | 2 +- tests/ui/issues/issue-26709.rs | 2 +- tests/ui/issues/issue-27240.rs | 6 +++--- tests/ui/issues/issue-28498-must-work-ex1.rs | 2 +- tests/ui/issues/issue-28498-must-work-ex2.rs | 2 +- tests/ui/issues/issue-28498-ugeh-ex1.rs | 2 +- tests/ui/issues/issue-31267-additional.rs | 2 +- tests/ui/issues/issue-31299.rs | 4 ++-- tests/ui/issues/issue-34571.rs | 2 +- tests/ui/issues/issue-36278-prefix-nesting.rs | 2 +- tests/ui/issues/issue-4252.rs | 2 +- tests/ui/issues/issue-46069.rs | 2 +- tests/ui/issues/issue-5315.rs | 2 +- tests/ui/issues/issue-61894.rs | 2 +- tests/ui/issues/issue-7911.rs | 2 +- tests/ui/issues/issue-99838.rs | 4 ++-- tests/ui/layout/unsafe-cell-hides-niche.rs | 4 ++-- tests/ui/lint/dead-code/lint-dead-code-1.rs | 2 +- tests/ui/lint/dead-code/lint-dead-code-5.rs | 6 +++--- tests/ui/lint/dead-code/lint-dead-code-5.stderr | 2 +- .../multiple-dead-codes-in-the-same-struct.rs | 2 +- ...multiple-dead-codes-in-the-same-struct.stderr | 16 +++++++++++++++- tests/ui/lint/dead-code/tuple-struct-field.rs | 2 +- .../ui/lint/dead-code/tuple-struct-field.stderr | 4 ++-- tests/ui/lint/dead-code/with-impl.rs | 2 +- tests/ui/lint/unused/issue-104397.rs | 2 +- tests/ui/lint/unused/issue-105061-should-lint.rs | 2 +- tests/ui/lint/unused/issue-105061.rs | 2 +- tests/ui/list.rs | 2 +- tests/ui/macros/html-literals.rs | 2 +- tests/ui/macros/macro-tt-followed-by-seq.rs | 2 +- .../method-argument-inference-associated-type.rs | 2 +- .../method-probe-no-guessing-dyn-trait.rs | 4 ++-- tests/ui/mir/mir_codegen_switch.rs | 4 ++-- tests/ui/mir/mir_fat_ptr.rs | 2 +- tests/ui/mir/mir_raw_fat_ptr.rs | 2 +- tests/ui/mir/mir_refs_correct.rs | 4 ++-- .../suggest-removing-tuple-struct-field.fixed | 2 +- .../suggest-removing-tuple-struct-field.rs | 2 +- tests/ui/nullable-pointer-iotareduction.rs | 2 +- tests/ui/optimization-fuel-0.rs | 4 ++-- tests/ui/optimization-fuel-1.rs | 4 ++-- tests/ui/packed/issue-118537-field-offset-ice.rs | 2 +- tests/ui/packed/packed-struct-drop-aligned.rs | 2 +- tests/ui/packed/packed-struct-optimized-enum.rs | 2 +- tests/ui/packed/packed-tuple-struct-layout.rs | 4 ++-- .../issues/issue-70388-without-witness.fixed | 2 +- .../parser/issues/issue-70388-without-witness.rs | 2 +- ...where-clause-before-tuple-struct-body-0.fixed | 2 +- ...er-where-clause-before-tuple-struct-body-0.rs | 2 +- ...here-clause-before-tuple-struct-body-0.stderr | 6 +++--- tests/ui/pub/pub-ident-struct-4.fixed | 2 +- tests/ui/pub/pub-ident-struct-4.rs | 2 +- tests/ui/pub/pub-ident-struct-4.stderr | 4 ++-- tests/ui/range_inclusive.rs | 2 +- tests/ui/recursion_limit/issue-40003.rs | 2 +- tests/ui/repr/align-with-extern-c-fn.rs | 2 +- ...low-hide-behind-direct-unsafe-ptr-embedded.rs | 2 +- .../allow-hide-behind-direct-unsafe-ptr-param.rs | 2 +- ...w-hide-behind-indirect-unsafe-ptr-embedded.rs | 2 +- ...llow-hide-behind-indirect-unsafe-ptr-param.rs | 2 +- .../cant-hide-behind-direct-struct-embedded.rs | 2 +- .../cant-hide-behind-doubly-indirect-embedded.rs | 2 +- .../cant-hide-behind-doubly-indirect-param.rs | 2 +- .../cant-hide-behind-indirect-struct-embedded.rs | 2 +- .../cant-hide-behind-indirect-struct-param.rs | 2 +- tests/ui/rfcs/rfc-2151-raw-identifiers/attr.rs | 2 +- .../rfcs/rfc-2632-const-trait-impl/const-drop.rs | 2 +- .../specialization/specialization-cross-crate.rs | 2 +- ...ation-translate-projections-with-lifetimes.rs | 2 +- tests/ui/stdlib-unit-tests/raw-fat-ptr.rs | 2 +- tests/ui/struct-ctor-mangling.rs | 2 +- tests/ui/structs-enums/enum-null-pointer-opt.rs | 6 +++--- .../enum-nullable-simplifycfg-misopt.rs | 2 +- tests/ui/structs-enums/resource-in-struct.rs | 2 +- tests/ui/structs-enums/tuple-struct-construct.rs | 2 +- tests/ui/structs-enums/uninstantiable-struct.rs | 2 +- .../lifetimes/type-param-bound-scope.fixed | 2 +- .../lifetimes/type-param-bound-scope.rs | 2 +- tests/ui/trailing-comma.rs | 4 ++-- tests/ui/traits/augmented-assignments-trait.rs | 2 +- .../negative-impls/negated-auto-traits-rpass.rs | 2 +- tests/ui/traits/object/exclusion.rs | 2 +- tests/ui/traits/object/generics.rs | 2 +- tests/ui/traits/pointee-deduction.rs | 4 ++-- tests/ui/traits/principal-less-objects.rs | 2 +- .../enum-variant-generic-args-pass.rs | 2 +- tests/ui/typeck/issue-2063.rs | 2 +- tests/ui/unboxed-closures/type-id-higher-rank.rs | 2 +- tests/ui/unsized-locals/unsized-exprs-rpass.rs | 2 +- tests/ui/unsized/unchanged-param.rs | 4 ++-- 166 files changed, 223 insertions(+), 209 deletions(-) diff --git a/tests/codegen-units/item-collection/generic-drop-glue.rs b/tests/codegen-units/item-collection/generic-drop-glue.rs index 6df4ff7e58b..ca477d06610 100644 --- a/tests/codegen-units/item-collection/generic-drop-glue.rs +++ b/tests/codegen-units/item-collection/generic-drop-glue.rs @@ -34,9 +34,9 @@ enum EnumNoDrop { } -struct NonGenericNoDrop(#[allow(unused_tuple_struct_fields)] i32); +struct NonGenericNoDrop(#[allow(dead_code)] i32); -struct NonGenericWithDrop(#[allow(unused_tuple_struct_fields)] i32); +struct NonGenericWithDrop(#[allow(dead_code)] i32); //~ MONO_ITEM fn std::ptr::drop_in_place:: - shim(Some(NonGenericWithDrop)) @@ generic_drop_glue-cgu.0[Internal] impl Drop for NonGenericWithDrop { diff --git a/tests/codegen-units/item-collection/transitive-drop-glue.rs b/tests/codegen-units/item-collection/transitive-drop-glue.rs index e286c800b7c..5f20637b40f 100644 --- a/tests/codegen-units/item-collection/transitive-drop-glue.rs +++ b/tests/codegen-units/item-collection/transitive-drop-glue.rs @@ -6,9 +6,9 @@ #![feature(start)] //~ MONO_ITEM fn std::ptr::drop_in_place:: - shim(Some(Root)) @@ transitive_drop_glue-cgu.0[Internal] -struct Root(#[allow(unused_tuple_struct_fields)] Intermediate); +struct Root(#[allow(dead_code)] Intermediate); //~ MONO_ITEM fn std::ptr::drop_in_place:: - shim(Some(Intermediate)) @@ transitive_drop_glue-cgu.0[Internal] -struct Intermediate(#[allow(unused_tuple_struct_fields)] Leaf); +struct Intermediate(#[allow(dead_code)] Leaf); //~ MONO_ITEM fn std::ptr::drop_in_place:: - 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(#[allow(unused_tuple_struct_fields)] IntermediateGen); -struct IntermediateGen(#[allow(unused_tuple_struct_fields)] LeafGen); -struct LeafGen(#[allow(unused_tuple_struct_fields)] T); +struct RootGen(#[allow(dead_code)] IntermediateGen); +struct IntermediateGen(#[allow(dead_code)] LeafGen); +struct LeafGen(#[allow(dead_code)] T); impl Drop for LeafGen { fn drop(&mut self) {} diff --git a/tests/codegen-units/item-collection/unsizing.rs b/tests/codegen-units/item-collection/unsizing.rs index 111a7231209..34f52ce4e61 100644 --- a/tests/codegen-units/item-collection/unsizing.rs +++ b/tests/codegen-units/item-collection/unsizing.rs @@ -40,7 +40,7 @@ impl Trait for u32 { } #[derive(Clone, Copy)] -struct Wrapper(#[allow(unused_tuple_struct_fields)] *const T); +struct Wrapper(#[allow(dead_code)] *const T); impl, U: ?Sized> CoerceUnsized> for Wrapper {} diff --git a/tests/ui/allocator/no_std-alloc-error-handler-custom.rs b/tests/ui/allocator/no_std-alloc-error-handler-custom.rs index 28926243390..2323cf46d6f 100644 --- a/tests/ui/allocator/no_std-alloc-error-handler-custom.rs +++ b/tests/ui/allocator/no_std-alloc-error-handler-custom.rs @@ -74,7 +74,7 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! { extern "C" fn rust_eh_personality() {} #[derive(Default, Debug)] -struct Page(#[allow(unused_tuple_struct_fields)] [[u64; 32]; 16]); +struct Page(#[allow(dead_code)] [[u64; 32]; 16]); #[no_mangle] fn main(_argc: i32, _argv: *const *const u8) -> isize { diff --git a/tests/ui/allocator/no_std-alloc-error-handler-default.rs b/tests/ui/allocator/no_std-alloc-error-handler-default.rs index 56409e71339..488434a9a72 100644 --- a/tests/ui/allocator/no_std-alloc-error-handler-default.rs +++ b/tests/ui/allocator/no_std-alloc-error-handler-default.rs @@ -61,7 +61,7 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! { extern "C" fn rust_eh_personality() {} #[derive(Default, Debug)] -struct Page(#[allow(unused_tuple_struct_fields)] [[u64; 32]; 16]); +struct Page(#[allow(dead_code)] [[u64; 32]; 16]); #[no_mangle] fn main(_argc: i32, _argv: *const *const u8) -> isize { diff --git a/tests/ui/array-slice-vec/show-boxed-slice.rs b/tests/ui/array-slice-vec/show-boxed-slice.rs index c10f779b1f6..3ae3686e423 100644 --- a/tests/ui/array-slice-vec/show-boxed-slice.rs +++ b/tests/ui/array-slice-vec/show-boxed-slice.rs @@ -1,7 +1,7 @@ // run-pass #[derive(Debug)] -struct Foo(#[allow(unused_tuple_struct_fields)] Box<[u8]>); +struct Foo(#[allow(dead_code)] Box<[u8]>); pub fn main() { println!("{:?}", Foo(Box::new([0, 1, 2]))); diff --git a/tests/ui/associated-consts/associated-const-type-parameters.rs b/tests/ui/associated-consts/associated-const-type-parameters.rs index e7ead1045e6..b62d47458be 100644 --- a/tests/ui/associated-consts/associated-const-type-parameters.rs +++ b/tests/ui/associated-consts/associated-const-type-parameters.rs @@ -17,7 +17,7 @@ impl Foo for Def { const X: i32 = 97; } -struct Proxy(#[allow(unused_tuple_struct_fields)] T); +struct Proxy(#[allow(dead_code)] T); impl Foo for Proxy { const X: i32 = T::X; diff --git a/tests/ui/associated-types/associated-types-method.rs b/tests/ui/associated-types/associated-types-method.rs index 45df3ac20c2..6a6456cbbec 100644 --- a/tests/ui/associated-types/associated-types-method.rs +++ b/tests/ui/associated-types/associated-types-method.rs @@ -5,7 +5,7 @@ trait Device { type Resources; } -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct Foo(D, R); trait Tr { diff --git a/tests/ui/associated-types/associated-types-struct-field-numbered.rs b/tests/ui/associated-types/associated-types-struct-field-numbered.rs index 8612911d8f8..b71b71b25f5 100644 --- a/tests/ui/associated-types/associated-types-struct-field-numbered.rs +++ b/tests/ui/associated-types/associated-types-struct-field-numbered.rs @@ -9,7 +9,7 @@ pub trait UnifyKey { fn dummy(&self) { } } -pub struct Node(#[allow(unused_tuple_struct_fields)] K, K::Value); +pub struct Node(#[allow(dead_code)] K, K::Value); fn foo>,V : Clone>(node: &Node) -> Option { node.1.clone() diff --git a/tests/ui/associated-types/issue-25700-1.rs b/tests/ui/associated-types/issue-25700-1.rs index 5e71a52ba4e..79652dc882b 100644 --- a/tests/ui/associated-types/issue-25700-1.rs +++ b/tests/ui/associated-types/issue-25700-1.rs @@ -1,5 +1,5 @@ // run-pass -struct S(#[allow(unused_tuple_struct_fields)] Option<&'static T>); +struct S(#[allow(dead_code)] Option<&'static T>); trait Tr { type Out; } impl Tr for T { type Out = T; } diff --git a/tests/ui/associated-types/issue-25700-2.rs b/tests/ui/associated-types/issue-25700-2.rs index 89b1db496f9..f745da4a5cb 100644 --- a/tests/ui/associated-types/issue-25700-2.rs +++ b/tests/ui/associated-types/issue-25700-2.rs @@ -3,9 +3,9 @@ pub trait Parser { type Input; } -pub struct Iter(#[allow(unused_tuple_struct_fields)] P, P::Input); +pub struct Iter(#[allow(dead_code)] P, P::Input); -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] pub struct Map(P, F); impl Parser for Map where F: FnMut(P) { type Input = u8; diff --git a/tests/ui/associated-types/issue-25700.rs b/tests/ui/associated-types/issue-25700.rs index e5b9a97523d..a377e37349d 100644 --- a/tests/ui/associated-types/issue-25700.rs +++ b/tests/ui/associated-types/issue-25700.rs @@ -1,4 +1,4 @@ -struct S(#[allow(unused_tuple_struct_fields)] Option<&'static T>); +struct S(#[allow(dead_code)] Option<&'static T>); trait Tr { type Out; } impl Tr for T { type Out = T; } diff --git a/tests/ui/async-await/async-fn-size-moved-locals.rs b/tests/ui/async-await/async-fn-size-moved-locals.rs index 79b7239f359..fb64bb6db63 100644 --- a/tests/ui/async-await/async-fn-size-moved-locals.rs +++ b/tests/ui/async-await/async-fn-size-moved-locals.rs @@ -17,7 +17,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; const BIG_FUT_SIZE: usize = 1024; -struct BigFut(#[allow(unused_tuple_struct_fields)] [u8; BIG_FUT_SIZE]); +struct BigFut(#[allow(dead_code)] [u8; BIG_FUT_SIZE]); impl BigFut { fn new() -> Self { diff --git a/tests/ui/async-await/async-fn-size-uninit-locals.rs b/tests/ui/async-await/async-fn-size-uninit-locals.rs index 54617269354..fee3e27cfb8 100644 --- a/tests/ui/async-await/async-fn-size-uninit-locals.rs +++ b/tests/ui/async-await/async-fn-size-uninit-locals.rs @@ -17,7 +17,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; const BIG_FUT_SIZE: usize = 1024; -struct Big(#[allow(unused_tuple_struct_fields)] [u8; BIG_FUT_SIZE]); +struct Big(#[allow(dead_code)] [u8; BIG_FUT_SIZE]); impl Big { fn new() -> Self { diff --git a/tests/ui/auto-traits/auto-traits.rs b/tests/ui/auto-traits/auto-traits.rs index 7b52d9c176e..6d8e1a52ec1 100644 --- a/tests/ui/auto-traits/auto-traits.rs +++ b/tests/ui/auto-traits/auto-traits.rs @@ -9,7 +9,7 @@ unsafe auto trait AutoUnsafe {} impl !Auto for bool {} impl !AutoUnsafe for bool {} -struct AutoBool(#[allow(unused_tuple_struct_fields)] bool); +struct AutoBool(#[allow(dead_code)] bool); impl Auto for AutoBool {} unsafe impl AutoUnsafe for AutoBool {} diff --git a/tests/ui/bench/issue-32062.rs b/tests/ui/bench/issue-32062.rs index 7eb52196e16..99b8b7c6012 100644 --- a/tests/ui/bench/issue-32062.rs +++ b/tests/ui/bench/issue-32062.rs @@ -15,7 +15,7 @@ trait Parser { } } -struct Token(#[allow(unused_tuple_struct_fields)] T::Item) where T: Iterator; +struct Token(#[allow(dead_code)] T::Item) where T: Iterator; impl Parser for Token where T: Iterator { type Input = T; @@ -25,7 +25,7 @@ impl Parser for Token where T: Iterator { } } -struct Chain(#[allow(unused_tuple_struct_fields)] L, #[allow(unused_tuple_struct_fields)] R); +struct Chain(#[allow(dead_code)] L, #[allow(dead_code)] R); impl Parser for Chain where L: Parser, R: Parser { type Input = L::Input; diff --git a/tests/ui/binding/match-tag.rs b/tests/ui/binding/match-tag.rs index 407716aa28a..6914a1c6b6d 100644 --- a/tests/ui/binding/match-tag.rs +++ b/tests/ui/binding/match-tag.rs @@ -3,7 +3,7 @@ #![allow(non_camel_case_types)] -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] enum color { rgb(isize, isize, isize), rgba(isize, isize, isize, isize), diff --git a/tests/ui/binding/or-pattern.rs b/tests/ui/binding/or-pattern.rs index 47623a3d722..07559e414dc 100644 --- a/tests/ui/binding/or-pattern.rs +++ b/tests/ui/binding/or-pattern.rs @@ -1,7 +1,7 @@ // run-pass #![allow(non_camel_case_types)] -enum blah { a(isize, isize, #[allow(unused_tuple_struct_fields)] usize), b(isize, isize), c, } +enum blah { a(isize, isize, #[allow(dead_code)] usize), b(isize, isize), c, } fn or_alt(q: blah) -> isize { match q { blah::a(x, y, _) | blah::b(x, y) => { return x + y; } blah::c => { return 0; } } diff --git a/tests/ui/binding/simple-generic-match.rs b/tests/ui/binding/simple-generic-match.rs index 2cf050d011d..acac32b8231 100644 --- a/tests/ui/binding/simple-generic-match.rs +++ b/tests/ui/binding/simple-generic-match.rs @@ -3,6 +3,6 @@ // pretty-expanded FIXME #23616 -enum clam { a(#[allow(unused_tuple_struct_fields)] T), } +enum clam { a(#[allow(dead_code)] T), } pub fn main() { let c = clam::a(2); match c { clam::a::(_) => { } } } diff --git a/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs b/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs index cdde48871ea..2edc52c6f55 100644 --- a/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs +++ b/tests/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs @@ -12,7 +12,7 @@ use trait_superkinds_in_metadata::RequiresCopy; use std::marker; #[derive(Copy, Clone)] -struct X(#[allow(unused_tuple_struct_fields)] T); +struct X(#[allow(dead_code)] T); impl RequiresShare for X { } diff --git a/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed b/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed index b74b5e94e2b..e8ca5ccdc54 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed +++ b/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed @@ -51,10 +51,10 @@ fn test_sync_trait() { } /* Test Clone Trait Migration */ -struct S(Foo); +struct S(#[allow(dead_code)] Foo); struct T(i32); -struct U(S, T); +struct U(#[allow(dead_code)] S, T); impl Clone for U { fn clone(&self) -> Self { diff --git a/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.rs b/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.rs index e4965e33cc1..fb464b7f1e1 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.rs +++ b/tests/ui/closures/2229_closure_analysis/migrations/auto_traits.rs @@ -51,10 +51,10 @@ fn test_sync_trait() { } /* Test Clone Trait Migration */ -struct S(Foo); +struct S(#[allow(dead_code)] Foo); struct T(i32); -struct U(S, T); +struct U(#[allow(dead_code)] S, T); impl Clone for U { fn clone(&self) -> Self { diff --git a/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed b/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed index bde8c749731..7c4e5c0f9a5 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed +++ b/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed @@ -18,10 +18,10 @@ impl Foo { } } -struct S(#[allow(unused_tuple_struct_fields)] Foo); +struct S(#[allow(dead_code)] Foo); #[derive(Clone)] -struct T(#[allow(unused_tuple_struct_fields)] i32); +struct T(#[allow(dead_code)] i32); struct U(S, T); diff --git a/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs b/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs index 584c52ea134..f979db11b7e 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs +++ b/tests/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs @@ -18,10 +18,10 @@ impl Foo { } } -struct S(#[allow(unused_tuple_struct_fields)] Foo); +struct S(#[allow(dead_code)] Foo); #[derive(Clone)] -struct T(#[allow(unused_tuple_struct_fields)] i32); +struct T(#[allow(dead_code)] i32); struct U(S, T); diff --git a/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed b/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed index e99dbb5ab3a..672aa4be686 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed +++ b/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed @@ -13,7 +13,7 @@ impl Drop for Foo { } #[derive(Debug)] -struct ConstainsDropField(Foo, #[allow(unused_tuple_struct_fields)] Foo); +struct ConstainsDropField(Foo, #[allow(dead_code)] Foo); // `t` needs Drop because one of its elements needs drop, // therefore precise capture might affect drop ordering diff --git a/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.rs b/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.rs index 62a984c9eeb..9c751064688 100644 --- a/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.rs +++ b/tests/ui/closures/2229_closure_analysis/migrations/significant_drop.rs @@ -13,7 +13,7 @@ impl Drop for Foo { } #[derive(Debug)] -struct ConstainsDropField(Foo, #[allow(unused_tuple_struct_fields)] Foo); +struct ConstainsDropField(Foo, #[allow(dead_code)] Foo); // `t` needs Drop because one of its elements needs drop, // therefore precise capture might affect drop ordering diff --git a/tests/ui/codegen/issue-16602-3.rs b/tests/ui/codegen/issue-16602-3.rs index ca1ab3cc7fe..2307cfb81c7 100644 --- a/tests/ui/codegen/issue-16602-3.rs +++ b/tests/ui/codegen/issue-16602-3.rs @@ -2,7 +2,7 @@ #![allow(unused_variables)] #![allow(unused_assignments)] #[derive(Debug)] -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] enum Foo { Bar(u32, u32), Baz(&'static u32, &'static u32) diff --git a/tests/ui/coercion/issue-14589.rs b/tests/ui/coercion/issue-14589.rs index d35ee5c731e..f92385f8d72 100644 --- a/tests/ui/coercion/issue-14589.rs +++ b/tests/ui/coercion/issue-14589.rs @@ -20,5 +20,5 @@ impl Test { } trait Foo { fn dummy(&self) { }} -struct Output(#[allow(unused_tuple_struct_fields)] isize); +struct Output(#[allow(dead_code)] isize); impl Foo for Output {} diff --git a/tests/ui/const-generics/const-argument-cross-crate.rs b/tests/ui/const-generics/const-argument-cross-crate.rs index 5693409e992..ff9cebdf7ec 100644 --- a/tests/ui/const-generics/const-argument-cross-crate.rs +++ b/tests/ui/const-generics/const-argument-cross-crate.rs @@ -4,7 +4,7 @@ extern crate const_generic_lib; -struct Container(#[allow(unused_tuple_struct_fields)] const_generic_lib::Alias); +struct Container(#[allow(dead_code)] const_generic_lib::Alias); fn main() { let res = const_generic_lib::function(const_generic_lib::Struct([14u8, 1u8, 2u8])); diff --git a/tests/ui/const-generics/generic_const_exprs/associated-consts.rs b/tests/ui/const-generics/generic_const_exprs/associated-consts.rs index b839008d424..3bc72fe7faa 100644 --- a/tests/ui/const-generics/generic_const_exprs/associated-consts.rs +++ b/tests/ui/const-generics/generic_const_exprs/associated-consts.rs @@ -16,7 +16,7 @@ impl BlockCipher for BarCipher { const BLOCK_SIZE: usize = 32; } -pub struct Block(#[allow(unused_tuple_struct_fields)] C); +pub struct Block(#[allow(dead_code)] C); pub fn test() where diff --git a/tests/ui/const-generics/inhabited-assoc-ty-ice-1.rs b/tests/ui/const-generics/inhabited-assoc-ty-ice-1.rs index b385406b020..b4f44dac62d 100644 --- a/tests/ui/const-generics/inhabited-assoc-ty-ice-1.rs +++ b/tests/ui/const-generics/inhabited-assoc-ty-ice-1.rs @@ -9,7 +9,7 @@ trait Foo { const ASSOC: usize = 1; } -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct Iced(T, [(); T::ASSOC]) where [(); T::ASSOC]: ; diff --git a/tests/ui/const-generics/inhabited-assoc-ty-ice-2.rs b/tests/ui/const-generics/inhabited-assoc-ty-ice-2.rs index 216d29c7cd4..d6d0a80ab11 100644 --- a/tests/ui/const-generics/inhabited-assoc-ty-ice-2.rs +++ b/tests/ui/const-generics/inhabited-assoc-ty-ice-2.rs @@ -9,7 +9,7 @@ trait Foo { const ASSOC: usize = 1; } -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct Iced(T, [(); T::ASSOC]) where [(); T::ASSOC]: ; diff --git a/tests/ui/consts/assoc-const.rs b/tests/ui/consts/assoc-const.rs index f542f2dcb52..021bcb40102 100644 --- a/tests/ui/consts/assoc-const.rs +++ b/tests/ui/consts/assoc-const.rs @@ -6,7 +6,7 @@ trait Nat { } struct Zero; -struct Succ(#[allow(unused_tuple_struct_fields)] N); +struct Succ(#[allow(dead_code)] N); impl Nat for Zero { const VALUE: usize = 0; diff --git a/tests/ui/consts/const-needs_drop.rs b/tests/ui/consts/const-needs_drop.rs index 11ee7084ce8..bf622e38939 100644 --- a/tests/ui/consts/const-needs_drop.rs +++ b/tests/ui/consts/const-needs_drop.rs @@ -2,10 +2,10 @@ use std::mem; -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct Trivial(u8, f32); -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct NonTrivial(u8, String); const CONST_U8: bool = mem::needs_drop::(); diff --git a/tests/ui/consts/const-size_of_val-align_of_val.rs b/tests/ui/consts/const-size_of_val-align_of_val.rs index e8323e4ae60..cd678176761 100644 --- a/tests/ui/consts/const-size_of_val-align_of_val.rs +++ b/tests/ui/consts/const-size_of_val-align_of_val.rs @@ -5,7 +5,7 @@ use std::{mem, ptr}; -struct Foo(#[allow(unused_tuple_struct_fields)] u32); +struct Foo(#[allow(dead_code)] u32); #[derive(Clone, Copy)] struct Bar { diff --git a/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs b/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs index 03e91f2b3b1..436a2d0de74 100644 --- a/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs +++ b/tests/ui/consts/const_in_pattern/null-raw-ptr-issue-119270.rs @@ -1,7 +1,7 @@ // run-pass // Eventually this will be rejected (when the future-compat lints are turned into hard errors), and // then this test can be removed. But meanwhile we should ensure that this works and does not ICE. -struct NoDerive(i32); +struct NoDerive(#[allow(dead_code)] i32); #[derive(PartialEq)] struct WrapEmbedded(*const NoDerive); diff --git a/tests/ui/consts/const_in_pattern/warn_corner_cases.rs b/tests/ui/consts/const_in_pattern/warn_corner_cases.rs index 15cf3c84d85..d23d85335f8 100644 --- a/tests/ui/consts/const_in_pattern/warn_corner_cases.rs +++ b/tests/ui/consts/const_in_pattern/warn_corner_cases.rs @@ -15,7 +15,7 @@ #![warn(indirect_structural_match)] #[derive(Copy, Clone, Debug)] -struct NoDerive(#[allow(unused_tuple_struct_fields)] u32); +struct NoDerive(#[allow(dead_code)] u32); // This impl makes `NoDerive` irreflexive. impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } diff --git a/tests/ui/consts/issue-70773-mir-typeck-lt-norm.rs b/tests/ui/consts/issue-70773-mir-typeck-lt-norm.rs index dd56faa3185..f82ec005a01 100644 --- a/tests/ui/consts/issue-70773-mir-typeck-lt-norm.rs +++ b/tests/ui/consts/issue-70773-mir-typeck-lt-norm.rs @@ -1,7 +1,7 @@ // run-pass const HASH_LEN: usize = 20; -struct Hash(#[allow(unused_tuple_struct_fields)] [u8; HASH_LEN]); +struct Hash(#[allow(dead_code)] [u8; HASH_LEN]); fn init_hash(_: &mut [u8; HASH_LEN]) {} fn foo<'a>() -> &'a () { diff --git a/tests/ui/consts/promoted_const_call4.rs b/tests/ui/consts/promoted_const_call4.rs index 82a17b7bf86..bb97957179f 100644 --- a/tests/ui/consts/promoted_const_call4.rs +++ b/tests/ui/consts/promoted_const_call4.rs @@ -4,7 +4,7 @@ use std::sync::atomic::*; static FLAG: AtomicBool = AtomicBool::new(false); -struct NoisyDrop(&'static str); +struct NoisyDrop(#[allow(dead_code)] &'static str); impl Drop for NoisyDrop { fn drop(&mut self) { FLAG.store(true, Ordering::SeqCst); diff --git a/tests/ui/consts/rvalue-static-promotion.rs b/tests/ui/consts/rvalue-static-promotion.rs index c48d9eae928..f42e8b70593 100644 --- a/tests/ui/consts/rvalue-static-promotion.rs +++ b/tests/ui/consts/rvalue-static-promotion.rs @@ -4,7 +4,7 @@ use std::cell::Cell; const NONE_CELL_STRING: Option> = None; -struct Foo(#[allow(unused_tuple_struct_fields)] T); +struct Foo(#[allow(dead_code)] T); impl Foo { const FOO: Option> = None; } diff --git a/tests/ui/consts/transmute-const.rs b/tests/ui/consts/transmute-const.rs index c5c3dfc4cc7..65e5700d083 100644 --- a/tests/ui/consts/transmute-const.rs +++ b/tests/ui/consts/transmute-const.rs @@ -3,7 +3,7 @@ use std::mem; #[repr(transparent)] -struct Foo(#[allow(unused_tuple_struct_fields)] u32); +struct Foo(#[allow(dead_code)] u32); const TRANSMUTED_U32: u32 = unsafe { mem::transmute(Foo(3)) }; diff --git a/tests/ui/coroutine/size-moved-locals.rs b/tests/ui/coroutine/size-moved-locals.rs index 10f988cc066..fa657e3b275 100644 --- a/tests/ui/coroutine/size-moved-locals.rs +++ b/tests/ui/coroutine/size-moved-locals.rs @@ -18,7 +18,7 @@ use std::ops::Coroutine; const FOO_SIZE: usize = 1024; -struct Foo(#[allow(unused_tuple_struct_fields)] [u8; FOO_SIZE]); +struct Foo(#[allow(dead_code)] [u8; FOO_SIZE]); impl Drop for Foo { fn drop(&mut self) {} diff --git a/tests/ui/derive-uninhabited-enum-38885.rs b/tests/ui/derive-uninhabited-enum-38885.rs index 0089453ef0f..c11df030025 100644 --- a/tests/ui/derive-uninhabited-enum-38885.rs +++ b/tests/ui/derive-uninhabited-enum-38885.rs @@ -9,7 +9,7 @@ enum Void {} #[derive(Debug)] enum Foo { - Bar(u8), + Bar(#[allow(dead_code)] u8), Void(Void), //~ WARN variant `Void` is never constructed } diff --git a/tests/ui/derive-uninhabited-enum-38885.stderr b/tests/ui/derive-uninhabited-enum-38885.stderr index 3fabf446dc3..bcd8f6b7b53 100644 --- a/tests/ui/derive-uninhabited-enum-38885.stderr +++ b/tests/ui/derive-uninhabited-enum-38885.stderr @@ -3,7 +3,7 @@ warning: variant `Void` is never constructed | LL | enum Foo { | --- variant in this enum -LL | Bar(u8), +LL | Bar(#[allow(dead_code)] u8), LL | Void(Void), | ^^^^ | diff --git a/tests/ui/deriving/deriving-clone-generic-tuple-struct.rs b/tests/ui/deriving/deriving-clone-generic-tuple-struct.rs index 3480ccc1089..331d7298216 100644 --- a/tests/ui/deriving/deriving-clone-generic-tuple-struct.rs +++ b/tests/ui/deriving/deriving-clone-generic-tuple-struct.rs @@ -2,7 +2,7 @@ // pretty-expanded FIXME #23616 #[derive(Clone)] -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct S(T, ()); pub fn main() { diff --git a/tests/ui/deriving/deriving-copyclone.rs b/tests/ui/deriving/deriving-copyclone.rs index f8403b1feac..099feceae81 100644 --- a/tests/ui/deriving/deriving-copyclone.rs +++ b/tests/ui/deriving/deriving-copyclone.rs @@ -23,7 +23,7 @@ impl Clone for Liar { /// This struct is actually Copy... at least, it thinks it is! #[derive(Copy, Clone)] -struct Innocent(#[allow(unused_tuple_struct_fields)] Liar); +struct Innocent(#[allow(dead_code)] Liar); impl Innocent { fn new() -> Self { diff --git a/tests/ui/deriving/issue-58319.rs b/tests/ui/deriving/issue-58319.rs index 8041bd5bb3c..754f5032d16 100644 --- a/tests/ui/deriving/issue-58319.rs +++ b/tests/ui/deriving/issue-58319.rs @@ -3,7 +3,7 @@ fn main() {} #[derive(Clone)] pub struct Little; #[derive(Clone)] -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] pub struct Big( Little, Little, diff --git a/tests/ui/drop/dropck-eyepatch-reorder.rs b/tests/ui/drop/dropck-eyepatch-reorder.rs index 0d7af3d4f61..4a56c45aa92 100644 --- a/tests/ui/drop/dropck-eyepatch-reorder.rs +++ b/tests/ui/drop/dropck-eyepatch-reorder.rs @@ -12,10 +12,10 @@ trait Foo { fn foo(&self, _: &str); } struct Dt(&'static str, A); struct Dr<'a, B:'a+Foo>(&'static str, &'a B); -struct Pt(&'static str, #[allow(unused_tuple_struct_fields)] A, B); -struct Pr<'a, 'b, B:'a+'b+Foo>(&'static str, #[allow(unused_tuple_struct_fields)] &'a B, &'b B); -struct St(&'static str, #[allow(unused_tuple_struct_fields)] A); -struct Sr<'a, B:'a+Foo>(&'static str, #[allow(unused_tuple_struct_fields)] &'a B); +struct Pt(&'static str, #[allow(dead_code)] A, B); +struct Pr<'a, 'b, B:'a+'b+Foo>(&'static str, #[allow(dead_code)] &'a B, &'b B); +struct St(&'static str, #[allow(dead_code)] A); +struct Sr<'a, B:'a+Foo>(&'static str, #[allow(dead_code)] &'a B); impl Drop for Dt { fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } diff --git a/tests/ui/drop/dropck-eyepatch.rs b/tests/ui/drop/dropck-eyepatch.rs index 3c4840d5c7a..ff5a52b906b 100644 --- a/tests/ui/drop/dropck-eyepatch.rs +++ b/tests/ui/drop/dropck-eyepatch.rs @@ -35,10 +35,10 @@ trait Foo { fn foo(&self, _: &str); } struct Dt(&'static str, A); struct Dr<'a, B:'a+Foo>(&'static str, &'a B); -struct Pt(&'static str, #[allow(unused_tuple_struct_fields)] A, B); -struct Pr<'a, 'b, B:'a+'b+Foo>(&'static str, #[allow(unused_tuple_struct_fields)] &'a B, &'b B); -struct St(&'static str, #[allow(unused_tuple_struct_fields)] A); -struct Sr<'a, B:'a+Foo>(&'static str, #[allow(unused_tuple_struct_fields)] &'a B); +struct Pt(&'static str, #[allow(dead_code)] A, B); +struct Pr<'a, 'b, B:'a+'b+Foo>(&'static str, #[allow(dead_code)] &'a B, &'b B); +struct St(&'static str, #[allow(dead_code)] A); +struct Sr<'a, B:'a+Foo>(&'static str, #[allow(dead_code)] &'a B); impl Drop for Dt { fn drop(&mut self) { println!("drop {}", self.0); self.1.foo(self.0); } diff --git a/tests/ui/drop/dynamic-drop.rs b/tests/ui/drop/dynamic-drop.rs index d35913ed641..4745cceb516 100644 --- a/tests/ui/drop/dynamic-drop.rs +++ b/tests/ui/drop/dynamic-drop.rs @@ -103,7 +103,7 @@ fn dynamic_drop(a: &Allocator, c: bool) { }; } -struct TwoPtrs<'a>(Ptr<'a>, #[allow(unused_tuple_struct_fields)] Ptr<'a>); +struct TwoPtrs<'a>(Ptr<'a>, #[allow(dead_code)] Ptr<'a>); fn struct_dynamic_drop(a: &Allocator, c0: bool, c1: bool, c: bool) { for i in 0..2 { let x; diff --git a/tests/ui/dropck/issue-24805-dropck-itemless.rs b/tests/ui/dropck/issue-24805-dropck-itemless.rs index 45761b61c3e..4d71389351b 100644 --- a/tests/ui/dropck/issue-24805-dropck-itemless.rs +++ b/tests/ui/dropck/issue-24805-dropck-itemless.rs @@ -19,7 +19,7 @@ impl<'a, T> UserDefined for &'a T { } // ``` macro_rules! impl_drop { ($Bound:ident, $Id:ident) => { - struct $Id(#[allow(unused_tuple_struct_fields)] T); + struct $Id(#[allow(dead_code)] T); unsafe impl <#[may_dangle] T: $Bound> Drop for $Id { fn drop(&mut self) { } } diff --git a/tests/ui/dropck/issue-28498-ugeh-with-passed-to-fn.rs b/tests/ui/dropck/issue-28498-ugeh-with-passed-to-fn.rs index 04d0d32033a..d2b620f6940 100644 --- a/tests/ui/dropck/issue-28498-ugeh-with-passed-to-fn.rs +++ b/tests/ui/dropck/issue-28498-ugeh-with-passed-to-fn.rs @@ -21,7 +21,7 @@ impl Drop for ScribbleOnDrop { } } -struct Foo(u32, T, #[allow(unused_tuple_struct_fields)] Box fn(&'r T) -> String>); +struct Foo(u32, T, #[allow(dead_code)] Box fn(&'r T) -> String>); unsafe impl<#[may_dangle] T> Drop for Foo { fn drop(&mut self) { diff --git a/tests/ui/dyn-star/drop.rs b/tests/ui/dyn-star/drop.rs index 1478498c0a9..1acfe2f2d1c 100644 --- a/tests/ui/dyn-star/drop.rs +++ b/tests/ui/dyn-star/drop.rs @@ -6,7 +6,7 @@ use std::fmt::Debug; #[derive(Debug)] -struct Foo(usize); +struct Foo(#[allow(dead_code)] usize); impl Drop for Foo { fn drop(&mut self) { diff --git a/tests/ui/enum-discriminant/discriminant_value-wrapper.rs b/tests/ui/enum-discriminant/discriminant_value-wrapper.rs index 8e162d5c455..1f6bb0cdc3a 100644 --- a/tests/ui/enum-discriminant/discriminant_value-wrapper.rs +++ b/tests/ui/enum-discriminant/discriminant_value-wrapper.rs @@ -4,7 +4,7 @@ use std::mem; -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] enum ADT { First(u32, u32), Second(u64) diff --git a/tests/ui/enum-discriminant/discriminant_value.rs b/tests/ui/enum-discriminant/discriminant_value.rs index f3dfac298ad..2864cd40da0 100644 --- a/tests/ui/enum-discriminant/discriminant_value.rs +++ b/tests/ui/enum-discriminant/discriminant_value.rs @@ -27,14 +27,14 @@ enum CLike3 { D } -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] enum ADT { First(u32, u32), Second(u64) } enum NullablePointer { - Something(#[allow(unused_tuple_struct_fields)] &'static u32), + Something(#[allow(dead_code)] &'static u32), Nothing } diff --git a/tests/ui/generics/generic-default-type-params-cross-crate.rs b/tests/ui/generics/generic-default-type-params-cross-crate.rs index 834b15be1c5..f798901132b 100644 --- a/tests/ui/generics/generic-default-type-params-cross-crate.rs +++ b/tests/ui/generics/generic-default-type-params-cross-crate.rs @@ -5,7 +5,7 @@ extern crate default_type_params_xc; -struct Vec(#[allow(unused_tuple_struct_fields)] Option<(T,A)>); +struct Vec(#[allow(dead_code)] Option<(T,A)>); struct Foo; diff --git a/tests/ui/generics/generic-ivec-leak.rs b/tests/ui/generics/generic-ivec-leak.rs index 9610bdcb338..7a1d10a646d 100644 --- a/tests/ui/generics/generic-ivec-leak.rs +++ b/tests/ui/generics/generic-ivec-leak.rs @@ -1,5 +1,5 @@ // run-pass #![allow(non_camel_case_types)] -enum wrapper { wrapped(#[allow(unused_tuple_struct_fields)] T), } +enum wrapper { wrapped(#[allow(dead_code)] T), } pub fn main() { let _w = wrapper::wrapped(vec![1, 2, 3, 4, 5]); } diff --git a/tests/ui/generics/generic-newtype-struct.rs b/tests/ui/generics/generic-newtype-struct.rs index aa879f01a58..92523b76f98 100644 --- a/tests/ui/generics/generic-newtype-struct.rs +++ b/tests/ui/generics/generic-newtype-struct.rs @@ -1,7 +1,7 @@ // run-pass // pretty-expanded FIXME #23616 -struct S(#[allow(unused_tuple_struct_fields)] T); +struct S(#[allow(dead_code)] T); pub fn main() { let _s = S(2); diff --git a/tests/ui/generics/generic-no-mangle.fixed b/tests/ui/generics/generic-no-mangle.fixed index 501acb6e163..aa6d6310f5f 100644 --- a/tests/ui/generics/generic-no-mangle.fixed +++ b/tests/ui/generics/generic-no-mangle.fixed @@ -76,7 +76,7 @@ impl Trait2 for Foo { fn qux<'a>(x: &'a i32) -> &i32 { x } //~ ERROR functions generic over types or consts must be mangled } -pub struct Bar(#[allow(unused_tuple_struct_fields)] T); +pub struct Bar(#[allow(dead_code)] T); impl Bar { @@ -111,7 +111,7 @@ impl Trait3 for Bar { fn baz() {} //~ ERROR functions generic over types or consts must be mangled } -pub struct Baz<'a>(#[allow(unused_tuple_struct_fields)] &'a i32); +pub struct Baz<'a>(#[allow(dead_code)] &'a i32); impl<'a> Baz<'a> { #[no_mangle] diff --git a/tests/ui/generics/generic-no-mangle.rs b/tests/ui/generics/generic-no-mangle.rs index 74e407078e8..8a59ca75aaf 100644 --- a/tests/ui/generics/generic-no-mangle.rs +++ b/tests/ui/generics/generic-no-mangle.rs @@ -76,7 +76,7 @@ impl Trait2 for Foo { fn qux<'a>(x: &'a i32) -> &i32 { x } //~ ERROR functions generic over types or consts must be mangled } -pub struct Bar(#[allow(unused_tuple_struct_fields)] T); +pub struct Bar(#[allow(dead_code)] T); impl Bar { #[no_mangle] @@ -111,7 +111,7 @@ impl Trait3 for Bar { fn baz() {} //~ ERROR functions generic over types or consts must be mangled } -pub struct Baz<'a>(#[allow(unused_tuple_struct_fields)] &'a i32); +pub struct Baz<'a>(#[allow(dead_code)] &'a i32); impl<'a> Baz<'a> { #[no_mangle] diff --git a/tests/ui/generics/generic-recursive-tag.rs b/tests/ui/generics/generic-recursive-tag.rs index b344da1c7dd..5490822975a 100644 --- a/tests/ui/generics/generic-recursive-tag.rs +++ b/tests/ui/generics/generic-recursive-tag.rs @@ -1,7 +1,7 @@ // run-pass #![allow(non_camel_case_types)] -enum list { #[allow(unused_tuple_struct_fields)] cons(Box, Box>), nil, } +enum list { #[allow(dead_code)] cons(Box, Box>), nil, } pub fn main() { let _a: list = diff --git a/tests/ui/generics/generic-tag-corruption.rs b/tests/ui/generics/generic-tag-corruption.rs index 35de3c1f712..ae20a94d9fd 100644 --- a/tests/ui/generics/generic-tag-corruption.rs +++ b/tests/ui/generics/generic-tag-corruption.rs @@ -5,6 +5,6 @@ // This used to cause memory corruption in stage 0. // pretty-expanded FIXME #23616 -enum thing { some(#[allow(unused_tuple_struct_fields)] K), } +enum thing { some(#[allow(dead_code)] K), } pub fn main() { let _x = thing::some("hi".to_string()); } diff --git a/tests/ui/generics/generic-tag-local.rs b/tests/ui/generics/generic-tag-local.rs index c5772e84193..121ec74f8b7 100644 --- a/tests/ui/generics/generic-tag-local.rs +++ b/tests/ui/generics/generic-tag-local.rs @@ -3,6 +3,6 @@ // pretty-expanded FIXME #23616 -enum clam { a(#[allow(unused_tuple_struct_fields)] T), } +enum clam { a(#[allow(dead_code)] T), } pub fn main() { let _c = clam::a(3); } diff --git a/tests/ui/generics/generic-tag.rs b/tests/ui/generics/generic-tag.rs index 31fc2178d6d..9e844c72552 100644 --- a/tests/ui/generics/generic-tag.rs +++ b/tests/ui/generics/generic-tag.rs @@ -6,7 +6,7 @@ #![allow(unused_variables)] -enum option { some(#[allow(unused_tuple_struct_fields)] Box), none, } +enum option { some(#[allow(dead_code)] Box), none, } pub fn main() { let mut a: option = option::some::(Box::new(10)); diff --git a/tests/ui/impl-trait/bounds_regression.rs b/tests/ui/impl-trait/bounds_regression.rs index f32d83c0c40..89b0e3c55f9 100644 --- a/tests/ui/impl-trait/bounds_regression.rs +++ b/tests/ui/impl-trait/bounds_regression.rs @@ -15,7 +15,7 @@ pub fn future_from_coroutine< GenFuture(x) } -struct GenFuture>(#[allow(unused_tuple_struct_fields)] T); +struct GenFuture>(#[allow(dead_code)] T); impl> FakeFuture for GenFuture { type Output = T::Return; diff --git a/tests/ui/inference/issue-36053.rs b/tests/ui/inference/issue-36053.rs index 5c6d0780416..8eee1c33b0e 100644 --- a/tests/ui/inference/issue-36053.rs +++ b/tests/ui/inference/issue-36053.rs @@ -7,7 +7,7 @@ use std::iter::FusedIterator; -struct Thing<'a>(#[allow(unused_tuple_struct_fields)] &'a str); +struct Thing<'a>(#[allow(dead_code)] &'a str); impl<'a> Iterator for Thing<'a> { type Item = &'a str; fn next(&mut self) -> Option<&'a str> { diff --git a/tests/ui/issues/issue-13027.rs b/tests/ui/issues/issue-13027.rs index 64bf2a11d0e..ac0d1f11bd7 100644 --- a/tests/ui/issues/issue-13027.rs +++ b/tests/ui/issues/issue-13027.rs @@ -164,7 +164,7 @@ fn range_shadow_multi_pats() { fn misc() { enum Foo { - Bar(#[allow(unused_tuple_struct_fields)] usize, bool) + Bar(#[allow(dead_code)] usize, bool) } // This test basically mimics how trace_macros! macro is implemented, // which is a rare combination of vector patterns, multiple wild-card diff --git a/tests/ui/issues/issue-14382.rs b/tests/ui/issues/issue-14382.rs index dca24d0be8a..b5c2362f05c 100644 --- a/tests/ui/issues/issue-14382.rs +++ b/tests/ui/issues/issue-14382.rs @@ -1,6 +1,6 @@ // run-pass #[derive(Debug)] -struct Matrix4(#[allow(unused_tuple_struct_fields)] S); +struct Matrix4(#[allow(dead_code)] S); trait POrd {} fn translate>(s: S) -> Matrix4 { Matrix4(s) } diff --git a/tests/ui/issues/issue-15858.rs b/tests/ui/issues/issue-15858.rs index 8d65afc4883..77941c07671 100644 --- a/tests/ui/issues/issue-15858.rs +++ b/tests/ui/issues/issue-15858.rs @@ -12,7 +12,7 @@ impl Bar for BarImpl { } -struct Foo(#[allow(unused_tuple_struct_fields)] B); +struct Foo(#[allow(dead_code)] B); impl Drop for Foo { fn drop(&mut self) { diff --git a/tests/ui/issues/issue-17905.rs b/tests/ui/issues/issue-17905.rs index dae9648b917..83cea8b4395 100644 --- a/tests/ui/issues/issue-17905.rs +++ b/tests/ui/issues/issue-17905.rs @@ -1,7 +1,7 @@ // run-pass #[derive(Debug)] -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct Pair (T, V); impl Pair< diff --git a/tests/ui/issues/issue-23491.rs b/tests/ui/issues/issue-23491.rs index e5f9dd3efbd..efd83112353 100644 --- a/tests/ui/issues/issue-23491.rs +++ b/tests/ui/issues/issue-23491.rs @@ -1,7 +1,7 @@ // run-pass #![allow(unused_variables)] -struct Node(#[allow(unused_tuple_struct_fields)] T); +struct Node(#[allow(dead_code)] T); fn main() { let x: Box> = Box::new(Node([])); diff --git a/tests/ui/issues/issue-24308.rs b/tests/ui/issues/issue-24308.rs index 4a582c68efc..40950938fc7 100644 --- a/tests/ui/issues/issue-24308.rs +++ b/tests/ui/issues/issue-24308.rs @@ -4,7 +4,7 @@ pub trait Foo { fn method2(); } -struct Slice<'a, T: 'a>(#[allow(unused_tuple_struct_fields)] &'a [T]); +struct Slice<'a, T: 'a>(#[allow(dead_code)] &'a [T]); impl<'a, T: 'a> Foo for Slice<'a, T> { fn method2() { diff --git a/tests/ui/issues/issue-25089.rs b/tests/ui/issues/issue-25089.rs index c988f8f55fa..c7063b24608 100644 --- a/tests/ui/issues/issue-25089.rs +++ b/tests/ui/issues/issue-25089.rs @@ -4,7 +4,7 @@ use std::thread; -struct Foo(#[allow(unused_tuple_struct_fields)] i32); +struct Foo(#[allow(dead_code)] i32); impl Drop for Foo { fn drop(&mut self) { diff --git a/tests/ui/issues/issue-25679.rs b/tests/ui/issues/issue-25679.rs index b548da98888..8415eba887b 100644 --- a/tests/ui/issues/issue-25679.rs +++ b/tests/ui/issues/issue-25679.rs @@ -2,7 +2,7 @@ trait Device { type Resources; } -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct Foo(D, R); impl Foo { diff --git a/tests/ui/issues/issue-26127.rs b/tests/ui/issues/issue-26127.rs index f3f9c1d9ae8..b76f1ba51a4 100644 --- a/tests/ui/issues/issue-26127.rs +++ b/tests/ui/issues/issue-26127.rs @@ -1,7 +1,7 @@ // run-pass trait Tr { type T; } impl Tr for u8 { type T=(); } -struct S(#[allow(unused_tuple_struct_fields)] I::T); +struct S(#[allow(dead_code)] I::T); fn foo(i: I::T) { S::(i); diff --git a/tests/ui/issues/issue-26641.rs b/tests/ui/issues/issue-26641.rs index e08edd0b5cb..3256b71660f 100644 --- a/tests/ui/issues/issue-26641.rs +++ b/tests/ui/issues/issue-26641.rs @@ -1,5 +1,5 @@ // run-pass -struct Parser<'a>(#[allow(unused_tuple_struct_fields)] Box); +struct Parser<'a>(#[allow(dead_code)] Box); fn main() { let _x = Parser(Box::new(|_|{})); diff --git a/tests/ui/issues/issue-26709.rs b/tests/ui/issues/issue-26709.rs index 1bd2651dd6c..8a8186de5cc 100644 --- a/tests/ui/issues/issue-26709.rs +++ b/tests/ui/issues/issue-26709.rs @@ -1,5 +1,5 @@ // run-pass -struct Wrapper<'a, T: ?Sized>(&'a mut i32, #[allow(unused_tuple_struct_fields)] T); +struct Wrapper<'a, T: ?Sized>(&'a mut i32, #[allow(dead_code)] T); impl<'a, T: ?Sized> Drop for Wrapper<'a, T> { fn drop(&mut self) { diff --git a/tests/ui/issues/issue-27240.rs b/tests/ui/issues/issue-27240.rs index eaf254f3361..b518e58d194 100644 --- a/tests/ui/issues/issue-27240.rs +++ b/tests/ui/issues/issue-27240.rs @@ -2,12 +2,12 @@ #![allow(unused_assignments)] #![allow(unused_variables)] use std::fmt; -struct NoisyDrop(#[allow(unused_tuple_struct_fields)] T); +struct NoisyDrop(#[allow(dead_code)] T); impl Drop for NoisyDrop { fn drop(&mut self) {} } -struct Bar(#[allow(unused_tuple_struct_fields)] [*const NoisyDrop; 2]); +struct Bar(#[allow(dead_code)] [*const NoisyDrop; 2]); fn fine() { let (u,b); @@ -15,7 +15,7 @@ fn fine() { b = Bar([&NoisyDrop(&u), &NoisyDrop(&u)]); } -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct Bar2(*const NoisyDrop, *const NoisyDrop); fn lolwut() { diff --git a/tests/ui/issues/issue-28498-must-work-ex1.rs b/tests/ui/issues/issue-28498-must-work-ex1.rs index ab6d190e0a1..37234699893 100644 --- a/tests/ui/issues/issue-28498-must-work-ex1.rs +++ b/tests/ui/issues/issue-28498-must-work-ex1.rs @@ -6,7 +6,7 @@ use std::cell::Cell; -struct Concrete<'a>(#[allow(unused_tuple_struct_fields)] u32, Cell>>); +struct Concrete<'a>(#[allow(dead_code)] u32, Cell>>); fn main() { let mut data = Vec::new(); diff --git a/tests/ui/issues/issue-28498-must-work-ex2.rs b/tests/ui/issues/issue-28498-must-work-ex2.rs index 378d736ee3d..ab0b7196082 100644 --- a/tests/ui/issues/issue-28498-must-work-ex2.rs +++ b/tests/ui/issues/issue-28498-must-work-ex2.rs @@ -6,7 +6,7 @@ use std::cell::Cell; -struct Concrete<'a>(#[allow(unused_tuple_struct_fields)] u32, Cell>>); +struct Concrete<'a>(#[allow(dead_code)] u32, Cell>>); struct Foo { data: Vec } diff --git a/tests/ui/issues/issue-28498-ugeh-ex1.rs b/tests/ui/issues/issue-28498-ugeh-ex1.rs index 24bf706cef9..ce49cf1ff99 100644 --- a/tests/ui/issues/issue-28498-ugeh-ex1.rs +++ b/tests/ui/issues/issue-28498-ugeh-ex1.rs @@ -8,7 +8,7 @@ #![feature(dropck_eyepatch)] use std::cell::Cell; -struct Concrete<'a>(#[allow(unused_tuple_struct_fields)] u32, Cell>>); +struct Concrete<'a>(#[allow(dead_code)] u32, Cell>>); struct Foo { data: Vec } diff --git a/tests/ui/issues/issue-31267-additional.rs b/tests/ui/issues/issue-31267-additional.rs index 7f0cbd658f1..c6e93533e7c 100644 --- a/tests/ui/issues/issue-31267-additional.rs +++ b/tests/ui/issues/issue-31267-additional.rs @@ -6,7 +6,7 @@ struct Bar; const BAZ: Bar = Bar; #[derive(Debug)] -struct Foo(#[allow(unused_tuple_struct_fields)] [Bar; 1]); +struct Foo(#[allow(dead_code)] [Bar; 1]); struct Biz; diff --git a/tests/ui/issues/issue-31299.rs b/tests/ui/issues/issue-31299.rs index 78c3252d32e..e3c422cb97c 100644 --- a/tests/ui/issues/issue-31299.rs +++ b/tests/ui/issues/issue-31299.rs @@ -25,9 +25,9 @@ impl Front for Vec { type Back = Vec; } -struct PtrBack(#[allow(unused_tuple_struct_fields)] Vec); +struct PtrBack(#[allow(dead_code)] Vec); -struct M(#[allow(unused_tuple_struct_fields)] PtrBack>); +struct M(#[allow(dead_code)] PtrBack>); #[allow(unused_must_use)] fn main() { diff --git a/tests/ui/issues/issue-34571.rs b/tests/ui/issues/issue-34571.rs index 5498091da58..c392f59d8da 100644 --- a/tests/ui/issues/issue-34571.rs +++ b/tests/ui/issues/issue-34571.rs @@ -1,7 +1,7 @@ // run-pass #[repr(u8)] enum Foo { - Foo(#[allow(unused_tuple_struct_fields)] u8), + Foo(#[allow(dead_code)] u8), } fn main() { diff --git a/tests/ui/issues/issue-36278-prefix-nesting.rs b/tests/ui/issues/issue-36278-prefix-nesting.rs index a809f7f1329..5f476932018 100644 --- a/tests/ui/issues/issue-36278-prefix-nesting.rs +++ b/tests/ui/issues/issue-36278-prefix-nesting.rs @@ -5,7 +5,7 @@ use std::mem; const SZ: usize = 100; -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct P([u8; SZ], T); type Ack = P>; diff --git a/tests/ui/issues/issue-4252.rs b/tests/ui/issues/issue-4252.rs index 0d47a7f0c16..9b82121baa2 100644 --- a/tests/ui/issues/issue-4252.rs +++ b/tests/ui/issues/issue-4252.rs @@ -7,7 +7,7 @@ trait X { } #[derive(Debug)] -struct Y(#[allow(unused_tuple_struct_fields)] isize); +struct Y(#[allow(dead_code)] isize); #[derive(Debug)] struct Z { diff --git a/tests/ui/issues/issue-46069.rs b/tests/ui/issues/issue-46069.rs index c418128c186..f80ea932001 100644 --- a/tests/ui/issues/issue-46069.rs +++ b/tests/ui/issues/issue-46069.rs @@ -2,7 +2,7 @@ use std::iter::{Fuse, Cloned}; use std::slice::Iter; -struct Foo<'a, T: 'a>(#[allow(unused_tuple_struct_fields)] &'a T); +struct Foo<'a, T: 'a>(#[allow(dead_code)] &'a T); impl<'a, T: 'a> Copy for Foo<'a, T> {} impl<'a, T: 'a> Clone for Foo<'a, T> { fn clone(&self) -> Self { *self } diff --git a/tests/ui/issues/issue-5315.rs b/tests/ui/issues/issue-5315.rs index 0c121a5eee6..81d075a98a9 100644 --- a/tests/ui/issues/issue-5315.rs +++ b/tests/ui/issues/issue-5315.rs @@ -1,7 +1,7 @@ // run-pass // pretty-expanded FIXME #23616 -struct A(#[allow(unused_tuple_struct_fields)] bool); +struct A(#[allow(dead_code)] bool); pub fn main() { let f = A; diff --git a/tests/ui/issues/issue-61894.rs b/tests/ui/issues/issue-61894.rs index 776fdbb7466..fe934bdeb60 100644 --- a/tests/ui/issues/issue-61894.rs +++ b/tests/ui/issues/issue-61894.rs @@ -4,7 +4,7 @@ use std::any::type_name; -struct Bar(#[allow(unused_tuple_struct_fields)] M); +struct Bar(#[allow(dead_code)] M); impl Bar { fn foo(&self) -> &'static str { diff --git a/tests/ui/issues/issue-7911.rs b/tests/ui/issues/issue-7911.rs index f64887136ca..d4db3b0776b 100644 --- a/tests/ui/issues/issue-7911.rs +++ b/tests/ui/issues/issue-7911.rs @@ -6,7 +6,7 @@ trait FooBar { fn dummy(&self) { } } -struct Bar(#[allow(unused_tuple_struct_fields)] i32); +struct Bar(#[allow(dead_code)] i32); struct Foo { bar: Bar } impl FooBar for Bar {} diff --git a/tests/ui/issues/issue-99838.rs b/tests/ui/issues/issue-99838.rs index 2e81d5e8221..3bddca43daa 100644 --- a/tests/ui/issues/issue-99838.rs +++ b/tests/ui/issues/issue-99838.rs @@ -2,7 +2,7 @@ use std::hint; -struct U16(u16); +struct U16(#[allow(dead_code)] u16); impl Drop for U16 { fn drop(&mut self) { @@ -23,7 +23,7 @@ struct Wrapper { } #[repr(packed)] -struct Misalign(u8, Wrapper); +struct Misalign(#[allow(dead_code)] u8, Wrapper); fn main() { let m = Misalign( diff --git a/tests/ui/layout/unsafe-cell-hides-niche.rs b/tests/ui/layout/unsafe-cell-hides-niche.rs index 68bcc3c1aff..8d6cea10933 100644 --- a/tests/ui/layout/unsafe-cell-hides-niche.rs +++ b/tests/ui/layout/unsafe-cell-hides-niche.rs @@ -14,10 +14,10 @@ use std::mem::size_of; use std::num::NonZeroU32 as N32; use std::sync::{Mutex, RwLock}; -struct Wrapper(#[allow(unused_tuple_struct_fields)] T); +struct Wrapper(#[allow(dead_code)] T); #[repr(transparent)] -struct Transparent(#[allow(unused_tuple_struct_fields)] T); +struct Transparent(#[allow(dead_code)] T); struct NoNiche(UnsafeCell); diff --git a/tests/ui/lint/dead-code/lint-dead-code-1.rs b/tests/ui/lint/dead-code/lint-dead-code-1.rs index 8f5a4c41ef2..ddcafedf7bc 100644 --- a/tests/ui/lint/dead-code/lint-dead-code-1.rs +++ b/tests/ui/lint/dead-code/lint-dead-code-1.rs @@ -37,7 +37,7 @@ struct UsedStruct1 { #[allow(dead_code)] x: isize } -struct UsedStruct2(isize); +struct UsedStruct2(#[allow(dead_code)] isize); struct UsedStruct3; pub struct UsedStruct4; // this struct is never used directly, but its method is, so we don't want diff --git a/tests/ui/lint/dead-code/lint-dead-code-5.rs b/tests/ui/lint/dead-code/lint-dead-code-5.rs index ed90fb46429..76067d114a1 100644 --- a/tests/ui/lint/dead-code/lint-dead-code-5.rs +++ b/tests/ui/lint/dead-code/lint-dead-code-5.rs @@ -2,12 +2,12 @@ #![deny(dead_code)] enum Enum1 { - Variant1(isize), + Variant1(#[allow(dead_code)] isize), Variant2 //~ ERROR: variant `Variant2` is never constructed } enum Enum2 { - Variant3(bool), + Variant3(#[allow(dead_code)] bool), #[allow(dead_code)] Variant4(isize), Variant5 { _x: isize }, //~ ERROR: variants `Variant5` and `Variant6` are never constructed @@ -15,7 +15,7 @@ enum Enum2 { _Variant7, Variant8 { _field: bool }, Variant9, - Variant10(usize) + Variant10(#[allow(dead_code)] usize) } impl Enum2 { diff --git a/tests/ui/lint/dead-code/lint-dead-code-5.stderr b/tests/ui/lint/dead-code/lint-dead-code-5.stderr index eaf43e45361..a583f234a3d 100644 --- a/tests/ui/lint/dead-code/lint-dead-code-5.stderr +++ b/tests/ui/lint/dead-code/lint-dead-code-5.stderr @@ -3,7 +3,7 @@ error: variant `Variant2` is never constructed | LL | enum Enum1 { | ----- variant in this enum -LL | Variant1(isize), +LL | Variant1(#[allow(dead_code)] isize), LL | Variant2 | ^^^^^^^^ | diff --git a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs index a478153b3f4..942c5516500 100644 --- a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs +++ b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.rs @@ -17,7 +17,7 @@ struct Bar { // Issue 119267: this should not ICE. #[derive(Debug)] -struct Foo(usize, #[allow(unused)] usize); +struct Foo(usize, #[allow(unused)] usize); //~ WARN field `0` is never read fn main() { Bar { diff --git a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr index 0e5c78a7167..06f9b229c18 100644 --- a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr +++ b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr @@ -51,5 +51,19 @@ note: the lint level is defined here LL | #[forbid(dead_code)] | ^^^^^^^^^ -error: aborting due to 2 previous errors; 1 warning emitted +warning: field `0` is never read + --> $DIR/multiple-dead-codes-in-the-same-struct.rs:20:12 + | +LL | struct Foo(usize, #[allow(unused)] usize); + | --- ^^^^^ + | | + | field in this struct + | + = note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis +help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field + | +LL | struct Foo((), #[allow(unused)] usize); + | ~~ + +error: aborting due to 2 previous errors; 2 warnings emitted diff --git a/tests/ui/lint/dead-code/tuple-struct-field.rs b/tests/ui/lint/dead-code/tuple-struct-field.rs index 14fb30be949..d13fe029289 100644 --- a/tests/ui/lint/dead-code/tuple-struct-field.rs +++ b/tests/ui/lint/dead-code/tuple-struct-field.rs @@ -1,4 +1,4 @@ -#![deny(unused_tuple_struct_fields)] +#![deny(dead_code)] //~^ NOTE: the lint level is defined here use std::marker::PhantomData; diff --git a/tests/ui/lint/dead-code/tuple-struct-field.stderr b/tests/ui/lint/dead-code/tuple-struct-field.stderr index b8ad5cbe4e9..0154d5489f9 100644 --- a/tests/ui/lint/dead-code/tuple-struct-field.stderr +++ b/tests/ui/lint/dead-code/tuple-struct-field.stderr @@ -9,8 +9,8 @@ LL | struct SingleUnused(i32, [u8; LEN], String); note: the lint level is defined here --> $DIR/tuple-struct-field.rs:1:9 | -LL | #![deny(unused_tuple_struct_fields)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #![deny(dead_code)] + | ^^^^^^^^^ help: consider changing the field to be of unit type to suppress this warning while preserving the field numbering, or remove the field | LL | struct SingleUnused(i32, (), String); diff --git a/tests/ui/lint/dead-code/with-impl.rs b/tests/ui/lint/dead-code/with-impl.rs index 812fcdd09b6..147ec7b9e2e 100644 --- a/tests/ui/lint/dead-code/with-impl.rs +++ b/tests/ui/lint/dead-code/with-impl.rs @@ -2,7 +2,7 @@ #![deny(dead_code)] -pub struct GenericFoo(#[allow(unused_tuple_struct_fields)] T); +pub struct GenericFoo(#[allow(dead_code)] T); type Foo = GenericFoo; diff --git a/tests/ui/lint/unused/issue-104397.rs b/tests/ui/lint/unused/issue-104397.rs index 94e15cd96bc..c17e532c17f 100644 --- a/tests/ui/lint/unused/issue-104397.rs +++ b/tests/ui/lint/unused/issue-104397.rs @@ -3,7 +3,7 @@ #![warn(unused)] #![deny(warnings)] -struct Inv<'a>(&'a mut &'a ()); +struct Inv<'a>(#[allow(dead_code)] &'a mut &'a ()); trait Trait {} impl Trait for for<'a> fn(Inv<'a>) {} diff --git a/tests/ui/lint/unused/issue-105061-should-lint.rs b/tests/ui/lint/unused/issue-105061-should-lint.rs index 7e4e0947349..433c2882089 100644 --- a/tests/ui/lint/unused/issue-105061-should-lint.rs +++ b/tests/ui/lint/unused/issue-105061-should-lint.rs @@ -1,7 +1,7 @@ #![warn(unused)] #![deny(warnings)] -struct Inv<'a>(&'a mut &'a ()); +struct Inv<'a>(#[allow(dead_code)] &'a mut &'a ()); trait Trait<'a> {} impl<'b> Trait<'b> for for<'a> fn(Inv<'a>) {} diff --git a/tests/ui/lint/unused/issue-105061.rs b/tests/ui/lint/unused/issue-105061.rs index 92d636d0ac6..6043daf209d 100644 --- a/tests/ui/lint/unused/issue-105061.rs +++ b/tests/ui/lint/unused/issue-105061.rs @@ -1,7 +1,7 @@ #![warn(unused)] #![deny(warnings)] -struct Inv<'a>(&'a mut &'a ()); +struct Inv<'a>(#[allow(dead_code)] &'a mut &'a ()); trait Trait {} impl Trait for (for<'a> fn(Inv<'a>),) {} diff --git a/tests/ui/list.rs b/tests/ui/list.rs index ffe9f93860a..e44c94b3219 100644 --- a/tests/ui/list.rs +++ b/tests/ui/list.rs @@ -3,7 +3,7 @@ #![allow(non_camel_case_types)] // pretty-expanded FIXME #23616 -enum list { #[allow(unused_tuple_struct_fields)] cons(isize, Box), nil, } +enum list { #[allow(dead_code)] cons(isize, Box), nil, } pub fn main() { list::cons(10, Box::new(list::cons(11, Box::new(list::cons(12, Box::new(list::nil)))))); diff --git a/tests/ui/macros/html-literals.rs b/tests/ui/macros/html-literals.rs index 26f00fed9c4..e5ff425041a 100644 --- a/tests/ui/macros/html-literals.rs +++ b/tests/ui/macros/html-literals.rs @@ -88,7 +88,7 @@ pub fn main() { ); } -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] enum HTMLFragment { tag(String, Vec ), text(String), diff --git a/tests/ui/macros/macro-tt-followed-by-seq.rs b/tests/ui/macros/macro-tt-followed-by-seq.rs index 080dbcfdd41..67238df8524 100644 --- a/tests/ui/macros/macro-tt-followed-by-seq.rs +++ b/tests/ui/macros/macro-tt-followed-by-seq.rs @@ -5,7 +5,7 @@ use self::Join::*; #[derive(Debug)] -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] enum Join { Keep(A,B), Skip(A,B), diff --git a/tests/ui/methods/method-argument-inference-associated-type.rs b/tests/ui/methods/method-argument-inference-associated-type.rs index a3c31fab1c2..852747d06b5 100644 --- a/tests/ui/methods/method-argument-inference-associated-type.rs +++ b/tests/ui/methods/method-argument-inference-associated-type.rs @@ -7,7 +7,7 @@ pub trait Service { fn call(&self, _req: Self::Request); } -pub struct S(#[allow(unused_tuple_struct_fields)] T); +pub struct S(#[allow(dead_code)] T); impl Service for ClientMap { type Request = S>; diff --git a/tests/ui/methods/method-probe-no-guessing-dyn-trait.rs b/tests/ui/methods/method-probe-no-guessing-dyn-trait.rs index ec41b711709..787191a26fb 100644 --- a/tests/ui/methods/method-probe-no-guessing-dyn-trait.rs +++ b/tests/ui/methods/method-probe-no-guessing-dyn-trait.rs @@ -15,7 +15,7 @@ trait MyTrait1 { impl MyTrait1 for Foo {} -struct Foo(#[allow(unused_tuple_struct_fields)] T); +struct Foo(#[allow(dead_code)] T); impl Deref for Foo<()> { type Target = dyn MyTrait1 + 'static; @@ -33,7 +33,7 @@ trait MyTrait2 { } impl MyTrait2 for u32 {} -struct Bar(#[allow(unused_tuple_struct_fields)] T, u32); +struct Bar(#[allow(dead_code)] T, u32); impl Deref for Bar { type Target = dyn MyTrait2 + 'static; fn deref(&self) -> &(dyn MyTrait2 + 'static) { diff --git a/tests/ui/mir/mir_codegen_switch.rs b/tests/ui/mir/mir_codegen_switch.rs index 9c93499d948..afdcd36f4bc 100644 --- a/tests/ui/mir/mir_codegen_switch.rs +++ b/tests/ui/mir/mir_codegen_switch.rs @@ -1,7 +1,7 @@ // run-pass enum Abc { - A(#[allow(unused_tuple_struct_fields)] u8), - B(#[allow(unused_tuple_struct_fields)] i8), + A(#[allow(dead_code)] u8), + B(#[allow(dead_code)] i8), C, D, } diff --git a/tests/ui/mir/mir_fat_ptr.rs b/tests/ui/mir/mir_fat_ptr.rs index 7c3e07c9e34..0c07fba6e94 100644 --- a/tests/ui/mir/mir_fat_ptr.rs +++ b/tests/ui/mir/mir_fat_ptr.rs @@ -1,7 +1,7 @@ // run-pass // test that ordinary fat pointer operations work. -struct Wrapper(#[allow(unused_tuple_struct_fields)] u32, T); +struct Wrapper(#[allow(dead_code)] u32, T); struct FatPtrContainer<'a> { ptr: &'a [u8] diff --git a/tests/ui/mir/mir_raw_fat_ptr.rs b/tests/ui/mir/mir_raw_fat_ptr.rs index f4a9afd2308..8e5a2043dc6 100644 --- a/tests/ui/mir/mir_raw_fat_ptr.rs +++ b/tests/ui/mir/mir_raw_fat_ptr.rs @@ -105,7 +105,7 @@ impl Foo for T { } } -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct S(u32, T); fn main_ref() { diff --git a/tests/ui/mir/mir_refs_correct.rs b/tests/ui/mir/mir_refs_correct.rs index 6cd9526b749..c5b57f52743 100644 --- a/tests/ui/mir/mir_refs_correct.rs +++ b/tests/ui/mir/mir_refs_correct.rs @@ -3,7 +3,7 @@ extern crate mir_external_refs as ext; -struct S(#[allow(unused_tuple_struct_fields)] u8); +struct S(#[allow(dead_code)] u8); #[derive(Debug, PartialEq, Eq)] struct Unit; @@ -46,7 +46,7 @@ impl T for O {} impl X for S {} enum E { - U(#[allow(unused_tuple_struct_fields)] u8) + U(#[allow(dead_code)] u8) } #[derive(PartialEq, Debug, Eq)] diff --git a/tests/ui/mismatched_types/suggest-removing-tuple-struct-field.fixed b/tests/ui/mismatched_types/suggest-removing-tuple-struct-field.fixed index 63b65ab20fe..b8eeb3d5cae 100644 --- a/tests/ui/mismatched_types/suggest-removing-tuple-struct-field.fixed +++ b/tests/ui/mismatched_types/suggest-removing-tuple-struct-field.fixed @@ -4,7 +4,7 @@ macro_rules! my_wrapper { ($expr:expr) => { MyWrapper($expr) } } -pub struct MyWrapper(u32); +pub struct MyWrapper(#[allow(dead_code)] u32); fn main() { let value = MyWrapper(123); diff --git a/tests/ui/mismatched_types/suggest-removing-tuple-struct-field.rs b/tests/ui/mismatched_types/suggest-removing-tuple-struct-field.rs index 2ab4e3955f3..54a13c67350 100644 --- a/tests/ui/mismatched_types/suggest-removing-tuple-struct-field.rs +++ b/tests/ui/mismatched_types/suggest-removing-tuple-struct-field.rs @@ -4,7 +4,7 @@ macro_rules! my_wrapper { ($expr:expr) => { MyWrapper($expr) } } -pub struct MyWrapper(u32); +pub struct MyWrapper(#[allow(dead_code)] u32); fn main() { let value = MyWrapper(123); diff --git a/tests/ui/nullable-pointer-iotareduction.rs b/tests/ui/nullable-pointer-iotareduction.rs index d345fec8118..3f3a962664e 100644 --- a/tests/ui/nullable-pointer-iotareduction.rs +++ b/tests/ui/nullable-pointer-iotareduction.rs @@ -8,7 +8,7 @@ // trying to get assert failure messages that at least identify which case // failed. -enum E { Thing(isize, T), #[allow(unused_tuple_struct_fields)] Nothing((), ((), ()), [i8; 0]) } +enum E { Thing(isize, T), #[allow(dead_code)] Nothing((), ((), ()), [i8; 0]) } impl E { fn is_none(&self) -> bool { match *self { diff --git a/tests/ui/optimization-fuel-0.rs b/tests/ui/optimization-fuel-0.rs index 2643dbea1c4..77c727ad0f7 100644 --- a/tests/ui/optimization-fuel-0.rs +++ b/tests/ui/optimization-fuel-0.rs @@ -6,9 +6,9 @@ use std::mem::size_of; // compile-flags: -Z fuel=foo=0 -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct S1(u8, u16, u8); -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct S2(u8, u16, u8); fn main() { diff --git a/tests/ui/optimization-fuel-1.rs b/tests/ui/optimization-fuel-1.rs index d5e2255d9f0..8b3d139201e 100644 --- a/tests/ui/optimization-fuel-1.rs +++ b/tests/ui/optimization-fuel-1.rs @@ -6,9 +6,9 @@ use std::mem::size_of; // compile-flags: -Z fuel=foo=1 -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct S1(u8, u16, u8); -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct S2(u8, u16, u8); fn main() { diff --git a/tests/ui/packed/issue-118537-field-offset-ice.rs b/tests/ui/packed/issue-118537-field-offset-ice.rs index 657aec64003..679d9d754e3 100644 --- a/tests/ui/packed/issue-118537-field-offset-ice.rs +++ b/tests/ui/packed/issue-118537-field-offset-ice.rs @@ -3,7 +3,7 @@ use std::mem; #[repr(packed(4))] -struct Slice([u32]); +struct Slice(#[allow(dead_code)] [u32]); #[repr(packed(2), C)] struct PackedSized { diff --git a/tests/ui/packed/packed-struct-drop-aligned.rs b/tests/ui/packed/packed-struct-drop-aligned.rs index 4fec72763a4..6c2907c86e9 100644 --- a/tests/ui/packed/packed-struct-drop-aligned.rs +++ b/tests/ui/packed/packed-struct-drop-aligned.rs @@ -24,7 +24,7 @@ impl<'a> Drop for Aligned<'a> { } #[repr(transparent)] -struct NotCopy(#[allow(unused_tuple_struct_fields)] u8); +struct NotCopy(#[allow(dead_code)] u8); #[repr(packed)] struct Packed<'a>(NotCopy, Aligned<'a>); diff --git a/tests/ui/packed/packed-struct-optimized-enum.rs b/tests/ui/packed/packed-struct-optimized-enum.rs index 5e1a1f518c5..c3540f7619b 100644 --- a/tests/ui/packed/packed-struct-optimized-enum.rs +++ b/tests/ui/packed/packed-struct-optimized-enum.rs @@ -1,6 +1,6 @@ // run-pass #[repr(packed)] -struct Packed(#[allow(unused_tuple_struct_fields)] T); +struct Packed(#[allow(dead_code)] T); impl Copy for Packed {} impl Clone for Packed { diff --git a/tests/ui/packed/packed-tuple-struct-layout.rs b/tests/ui/packed/packed-tuple-struct-layout.rs index 931be5b9414..879553142da 100644 --- a/tests/ui/packed/packed-tuple-struct-layout.rs +++ b/tests/ui/packed/packed-tuple-struct-layout.rs @@ -2,11 +2,11 @@ use std::mem; #[repr(packed)] -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct S4(u8,[u8; 3]); #[repr(packed)] -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct S5(u8,u32); pub fn main() { diff --git a/tests/ui/parser/issues/issue-70388-without-witness.fixed b/tests/ui/parser/issues/issue-70388-without-witness.fixed index 8d981405ea1..58721495dcd 100644 --- a/tests/ui/parser/issues/issue-70388-without-witness.fixed +++ b/tests/ui/parser/issues/issue-70388-without-witness.fixed @@ -1,7 +1,7 @@ // run-rustfix // This is for checking if we can apply suggestions as-is. -pub struct Foo(#[allow(unused_tuple_struct_fields)] i32); +pub struct Foo(#[allow(dead_code)] i32); fn main() { let Foo(..) = Foo(0); //~ ERROR unexpected `...` diff --git a/tests/ui/parser/issues/issue-70388-without-witness.rs b/tests/ui/parser/issues/issue-70388-without-witness.rs index bf36073083a..2e679db5464 100644 --- a/tests/ui/parser/issues/issue-70388-without-witness.rs +++ b/tests/ui/parser/issues/issue-70388-without-witness.rs @@ -1,7 +1,7 @@ // run-rustfix // This is for checking if we can apply suggestions as-is. -pub struct Foo(#[allow(unused_tuple_struct_fields)] i32); +pub struct Foo(#[allow(dead_code)] i32); fn main() { let Foo(...) = Foo(0); //~ ERROR unexpected `...` diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed index 227c40e97c0..a09ff3e5417 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.fixed @@ -1,7 +1,7 @@ // Regression test for issues #100790 and #106439. // run-rustfix -pub struct Example(usize) +pub struct Example(#[allow(dead_code)] usize) where (): Sized; //~^^^ ERROR where clauses are not allowed before tuple struct bodies diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs index 3699e6fe572..e86f2a8acb8 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.rs @@ -4,7 +4,7 @@ pub struct Example where (): Sized, -(usize); +(#[allow(dead_code)] usize); //~^^^ ERROR where clauses are not allowed before tuple struct bodies struct _Demo diff --git a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr index 18aa5fadb6b..ddbf237e866 100644 --- a/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr +++ b/tests/ui/parser/recover/recover-where-clause-before-tuple-struct-body-0.stderr @@ -6,12 +6,12 @@ LL | pub struct Example LL | / where LL | | (): Sized, | |______________^ unexpected where clause -LL | (usize); - | ------- the struct body +LL | (#[allow(dead_code)] usize); + | --------------------------- the struct body | help: move the body before the where clause | -LL ~ pub struct Example(usize) +LL ~ pub struct Example(#[allow(dead_code)] usize) LL | where LL ~ (): Sized; | diff --git a/tests/ui/pub/pub-ident-struct-4.fixed b/tests/ui/pub/pub-ident-struct-4.fixed index b49fa678e1b..71c6f0a6994 100644 --- a/tests/ui/pub/pub-ident-struct-4.fixed +++ b/tests/ui/pub/pub-ident-struct-4.fixed @@ -1,6 +1,6 @@ // run-rustfix -pub struct T(String); +pub struct T(#[allow(dead_code)] String); //~^ ERROR missing `struct` for struct definition fn main() {} diff --git a/tests/ui/pub/pub-ident-struct-4.rs b/tests/ui/pub/pub-ident-struct-4.rs index 20bc94b0acb..971f39a8ce1 100644 --- a/tests/ui/pub/pub-ident-struct-4.rs +++ b/tests/ui/pub/pub-ident-struct-4.rs @@ -1,6 +1,6 @@ // run-rustfix -pub T(String); +pub T(#[allow(dead_code)] String); //~^ ERROR missing `struct` for struct definition fn main() {} diff --git a/tests/ui/pub/pub-ident-struct-4.stderr b/tests/ui/pub/pub-ident-struct-4.stderr index 470874e0637..5fbb02c8673 100644 --- a/tests/ui/pub/pub-ident-struct-4.stderr +++ b/tests/ui/pub/pub-ident-struct-4.stderr @@ -1,12 +1,12 @@ error: missing `struct` for struct definition --> $DIR/pub-ident-struct-4.rs:3:4 | -LL | pub T(String); +LL | pub T(#[allow(dead_code)] String); | ^ | help: add `struct` here to parse `T` as a public struct | -LL | pub struct T(String); +LL | pub struct T(#[allow(dead_code)] String); | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/range_inclusive.rs b/tests/ui/range_inclusive.rs index c9107d24ed0..2425113b904 100644 --- a/tests/ui/range_inclusive.rs +++ b/tests/ui/range_inclusive.rs @@ -11,7 +11,7 @@ fn foo() -> isize { 42 } pub fn return_range_to() -> RangeToInclusive { return ..=1; } #[derive(Debug)] -struct P(#[allow(unused_tuple_struct_fields)] u8); +struct P(#[allow(dead_code)] u8); pub fn main() { let mut count = 0; diff --git a/tests/ui/recursion_limit/issue-40003.rs b/tests/ui/recursion_limit/issue-40003.rs index 5e61361f987..01a2aaffb9e 100644 --- a/tests/ui/recursion_limit/issue-40003.rs +++ b/tests/ui/recursion_limit/issue-40003.rs @@ -153,7 +153,7 @@ mod stream { } enum Slot { - Next(#[allow(unused_tuple_struct_fields)] usize), + Next(#[allow(dead_code)] usize), _Data { _a: T }, } diff --git a/tests/ui/repr/align-with-extern-c-fn.rs b/tests/ui/repr/align-with-extern-c-fn.rs index 9e490e27ad1..659ef88fce6 100644 --- a/tests/ui/repr/align-with-extern-c-fn.rs +++ b/tests/ui/repr/align-with-extern-c-fn.rs @@ -8,7 +8,7 @@ #![feature(repr_align)] #[repr(align(16))] -pub struct A(#[allow(unused_tuple_struct_fields)] i64); +pub struct A(#[allow(dead_code)] i64); #[allow(improper_ctypes_definitions)] pub extern "C" fn foo(x: A) {} diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs index 1914e155493..c95777b0ef1 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs @@ -5,7 +5,7 @@ #![warn(pointer_structural_match)] -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); +struct NoDerive(#[allow(dead_code)] i32); // This impl makes NoDerive irreflexive // (which doesn't matter here because `<*const T>::eq` won't recur on `T`). diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs index e713b003b00..3f663fd09f8 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs @@ -5,7 +5,7 @@ #![warn(pointer_structural_match)] -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); +struct NoDerive(#[allow(dead_code)] i32); // This impl makes NoDerive irreflexive // (which doesn't matter here because `<*const T>::eq` won't recur on `T`). diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs index 04da14c5419..56b7988e0e4 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs @@ -5,7 +5,7 @@ #![warn(pointer_structural_match)] -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); +struct NoDerive(#[allow(dead_code)] i32); // This impl makes NoDerive irreflexive // (which doesn't matter here because `<*const T>::eq` won't recur on `T`). diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs index 8313c25e753..3ebe3225437 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs @@ -5,7 +5,7 @@ #![warn(pointer_structural_match)] -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); +struct NoDerive(#[allow(dead_code)] i32); // This impl makes NoDerive irreflexive // (which doesn't matter here because `<*const T>::eq` won't recur on `T`). diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs index 7623839fdd1..bb5e243d934 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs @@ -5,7 +5,7 @@ // // See discussion on rust-lang/rust#62307 and rust-lang/rust#62339 -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); +struct NoDerive(#[allow(dead_code)] i32); // This impl makes NoDerive irreflexive. impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs index 894739ff705..e3abb47cf73 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs @@ -7,7 +7,7 @@ #![warn(indirect_structural_match)] // run-pass -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); +struct NoDerive(#[allow(dead_code)] i32); // This impl makes NoDerive irreflexive. impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs index 1699dae4624..2d3788eea8a 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs @@ -7,7 +7,7 @@ #![warn(indirect_structural_match)] // run-pass -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); +struct NoDerive(#[allow(dead_code)] i32); // This impl makes NoDerive irreflexive. impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs index 2672bdd9e56..65df7788d90 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs @@ -7,7 +7,7 @@ #![warn(indirect_structural_match)] // run-pass -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); +struct NoDerive(#[allow(dead_code)] i32); // This impl makes NoDerive irreflexive. impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } diff --git a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs index 3489995ae71..88260fd1081 100644 --- a/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs +++ b/tests/ui/rfcs/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs @@ -7,7 +7,7 @@ #![warn(indirect_structural_match)] // run-pass -struct NoDerive(#[allow(unused_tuple_struct_fields)] i32); +struct NoDerive(#[allow(dead_code)] i32); // This impl makes NoDerive irreflexive. impl PartialEq for NoDerive { fn eq(&self, _: &Self) -> bool { false } } diff --git a/tests/ui/rfcs/rfc-2151-raw-identifiers/attr.rs b/tests/ui/rfcs/rfc-2151-raw-identifiers/attr.rs index d359067f627..0deb8c7f119 100644 --- a/tests/ui/rfcs/rfc-2151-raw-identifiers/attr.rs +++ b/tests/ui/rfcs/rfc-2151-raw-identifiers/attr.rs @@ -7,7 +7,7 @@ struct Test { } #[r#derive(r#Debug)] -struct Test2(#[allow(unused_tuple_struct_fields)] u32); +struct Test2(#[allow(dead_code)] u32); pub fn main() { assert_eq!(mem::size_of::(), 9); diff --git a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs index 4836d2b02ce..75797b1cbfe 100644 --- a/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs +++ b/tests/ui/rfcs/rfc-2632-const-trait-impl/const-drop.rs @@ -100,7 +100,7 @@ implements_const_drop! { } fn main() { - struct HasDropGlue(#[allow(unused_tuple_struct_fields)] Box); + struct HasDropGlue(#[allow(dead_code)] Box); struct HasDropImpl; impl Drop for HasDropImpl { fn drop(&mut self) { diff --git a/tests/ui/specialization/specialization-cross-crate.rs b/tests/ui/specialization/specialization-cross-crate.rs index d9381d66152..4b2ac07378d 100644 --- a/tests/ui/specialization/specialization-cross-crate.rs +++ b/tests/ui/specialization/specialization-cross-crate.rs @@ -14,7 +14,7 @@ struct NotClone; struct MarkedAndClone; impl MyMarker for MarkedAndClone {} -struct MyType(#[allow(unused_tuple_struct_fields)] T); +struct MyType(#[allow(dead_code)] T); impl Foo for MyType { default fn foo(&self) -> &'static str { "generic MyType" diff --git a/tests/ui/specialization/specialization-translate-projections-with-lifetimes.rs b/tests/ui/specialization/specialization-translate-projections-with-lifetimes.rs index 904aeaa088b..f06afc8ba41 100644 --- a/tests/ui/specialization/specialization-translate-projections-with-lifetimes.rs +++ b/tests/ui/specialization/specialization-translate-projections-with-lifetimes.rs @@ -14,7 +14,7 @@ impl<'a> WithAssoc for &'a () { type Item = &'a u32; } -struct Cloned(#[allow(unused_tuple_struct_fields)] I); +struct Cloned(#[allow(dead_code)] I); impl<'a, I, T: 'a> Iterator for Cloned where I: WithAssoc, T: Clone diff --git a/tests/ui/stdlib-unit-tests/raw-fat-ptr.rs b/tests/ui/stdlib-unit-tests/raw-fat-ptr.rs index 6b0b09c9894..0f535523dcc 100644 --- a/tests/ui/stdlib-unit-tests/raw-fat-ptr.rs +++ b/tests/ui/stdlib-unit-tests/raw-fat-ptr.rs @@ -39,7 +39,7 @@ impl Foo for T { } } -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] struct S(u32, T); fn main() { diff --git a/tests/ui/struct-ctor-mangling.rs b/tests/ui/struct-ctor-mangling.rs index ba6abbf03a5..159e21d2863 100644 --- a/tests/ui/struct-ctor-mangling.rs +++ b/tests/ui/struct-ctor-mangling.rs @@ -4,7 +4,7 @@ fn size_of_val(_: &T) -> usize { std::mem::size_of::() } -struct Foo(#[allow(unused_tuple_struct_fields)] i64); +struct Foo(#[allow(dead_code)] i64); // Test that the (symbol) mangling of `Foo` (the `struct` type) and that of // `typeof Foo` (the function type of the `struct` constructor) don't collide. diff --git a/tests/ui/structs-enums/enum-null-pointer-opt.rs b/tests/ui/structs-enums/enum-null-pointer-opt.rs index 85fa1eac2e2..356f8a6dd36 100644 --- a/tests/ui/structs-enums/enum-null-pointer-opt.rs +++ b/tests/ui/structs-enums/enum-null-pointer-opt.rs @@ -10,8 +10,8 @@ use std::sync::Arc; trait Trait { fn dummy(&self) { } } trait Mirror { type Image; } impl Mirror for T { type Image = T; } -struct ParamTypeStruct(#[allow(unused_tuple_struct_fields)] T); -struct AssocTypeStruct(#[allow(unused_tuple_struct_fields)] ::Image); +struct ParamTypeStruct(#[allow(dead_code)] T); +struct AssocTypeStruct(#[allow(dead_code)] ::Image); #[repr(transparent)] union MaybeUninitUnion { _value: T, @@ -46,7 +46,7 @@ fn main() { struct Foo { _a: Box } - struct Bar(#[allow(unused_tuple_struct_fields)] Box); + struct Bar(#[allow(dead_code)] Box); // Should apply through structs assert_eq!(size_of::(), size_of::>()); diff --git a/tests/ui/structs-enums/enum-nullable-simplifycfg-misopt.rs b/tests/ui/structs-enums/enum-nullable-simplifycfg-misopt.rs index a05cf8b93d5..4bd7ee45dfe 100644 --- a/tests/ui/structs-enums/enum-nullable-simplifycfg-misopt.rs +++ b/tests/ui/structs-enums/enum-nullable-simplifycfg-misopt.rs @@ -6,7 +6,7 @@ * represented with nullable pointers could be misoptimized in some cases. */ -enum List { Nil, Cons(X, #[allow(unused_tuple_struct_fields)] Box>) } +enum List { Nil, Cons(X, #[allow(dead_code)] Box>) } pub fn main() { match List::Cons(10, Box::new(List::Nil)) { List::Cons(10, _) => {} diff --git a/tests/ui/structs-enums/resource-in-struct.rs b/tests/ui/structs-enums/resource-in-struct.rs index 9613ca62a49..267ad6b4a86 100644 --- a/tests/ui/structs-enums/resource-in-struct.rs +++ b/tests/ui/structs-enums/resource-in-struct.rs @@ -25,7 +25,7 @@ fn close_res(i: closable) -> close_res { } } -enum option { none, some(#[allow(unused_tuple_struct_fields)] T), } +enum option { none, some(#[allow(dead_code)] T), } fn sink(_res: option) { } diff --git a/tests/ui/structs-enums/tuple-struct-construct.rs b/tests/ui/structs-enums/tuple-struct-construct.rs index fbf97e6b225..dc7cbaffddb 100644 --- a/tests/ui/structs-enums/tuple-struct-construct.rs +++ b/tests/ui/structs-enums/tuple-struct-construct.rs @@ -1,5 +1,5 @@ // run-pass -#[allow(unused_tuple_struct_fields)] +#[allow(dead_code)] #[derive(Debug)] struct Foo(isize, isize); diff --git a/tests/ui/structs-enums/uninstantiable-struct.rs b/tests/ui/structs-enums/uninstantiable-struct.rs index b24effe5a9c..15f2fc424bb 100644 --- a/tests/ui/structs-enums/uninstantiable-struct.rs +++ b/tests/ui/structs-enums/uninstantiable-struct.rs @@ -1,4 +1,4 @@ // run-pass -pub struct Z(#[allow(unused_tuple_struct_fields)] &'static Z); +pub struct Z(#[allow(dead_code)] &'static Z); pub fn main() {} diff --git a/tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed b/tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed index 470cc67b973..3257ea04c69 100644 --- a/tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed +++ b/tests/ui/suggestions/lifetimes/type-param-bound-scope.fixed @@ -2,7 +2,7 @@ // trait, impl or associated fn. // run-rustfix -struct Inv<'a>(Option<*mut &'a u8>); +struct Inv<'a>(#[allow(dead_code)] Option<*mut &'a u8>); fn check_bound<'a, A: 'a>(_: A, _: Inv<'a>) {} diff --git a/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs b/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs index 874788e13ef..fcc13aad996 100644 --- a/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs +++ b/tests/ui/suggestions/lifetimes/type-param-bound-scope.rs @@ -2,7 +2,7 @@ // trait, impl or associated fn. // run-rustfix -struct Inv<'a>(Option<*mut &'a u8>); +struct Inv<'a>(#[allow(dead_code)] Option<*mut &'a u8>); fn check_bound<'a, A: 'a>(_: A, _: Inv<'a>) {} diff --git a/tests/ui/trailing-comma.rs b/tests/ui/trailing-comma.rs index 90adba99e54..31091398508 100644 --- a/tests/ui/trailing-comma.rs +++ b/tests/ui/trailing-comma.rs @@ -3,7 +3,7 @@ fn f(_: T,) {} -struct Foo(#[allow(unused_tuple_struct_fields)] T); +struct Foo(#[allow(dead_code)] T); struct Bar; @@ -14,7 +14,7 @@ impl Bar { } enum Baz { - Qux(#[allow(unused_tuple_struct_fields)] isize,), + Qux(#[allow(dead_code)] isize,), } #[allow(unused,)] diff --git a/tests/ui/traits/augmented-assignments-trait.rs b/tests/ui/traits/augmented-assignments-trait.rs index 747a5393f12..75168c4f1e5 100644 --- a/tests/ui/traits/augmented-assignments-trait.rs +++ b/tests/ui/traits/augmented-assignments-trait.rs @@ -1,7 +1,7 @@ // run-pass use std::ops::AddAssign; -struct Int(#[allow(unused_tuple_struct_fields)] i32); +struct Int(#[allow(dead_code)] i32); impl AddAssign for Int { fn add_assign(&mut self, _: Int) { diff --git a/tests/ui/traits/negative-impls/negated-auto-traits-rpass.rs b/tests/ui/traits/negative-impls/negated-auto-traits-rpass.rs index 0bc611c26ca..05345d3432b 100644 --- a/tests/ui/traits/negative-impls/negated-auto-traits-rpass.rs +++ b/tests/ui/traits/negative-impls/negated-auto-traits-rpass.rs @@ -5,7 +5,7 @@ pub struct WaitToken; impl !Send for WaitToken {} -pub struct Test(#[allow(unused_tuple_struct_fields)] T); +pub struct Test(#[allow(dead_code)] T); unsafe impl Send for Test {} pub fn spawn(_: F) -> () where F: FnOnce(), F: Send + 'static {} diff --git a/tests/ui/traits/object/exclusion.rs b/tests/ui/traits/object/exclusion.rs index 766dceeaffe..3abd3bbfccf 100644 --- a/tests/ui/traits/object/exclusion.rs +++ b/tests/ui/traits/object/exclusion.rs @@ -8,7 +8,7 @@ trait Future: 'static { } } -struct Map(#[allow(unused_tuple_struct_fields)] A); +struct Map(#[allow(dead_code)] A); impl Future for Map {} pub struct Promise; diff --git a/tests/ui/traits/object/generics.rs b/tests/ui/traits/object/generics.rs index 5a4a6aecc6b..e2e70d43ab8 100644 --- a/tests/ui/traits/object/generics.rs +++ b/tests/ui/traits/object/generics.rs @@ -25,7 +25,7 @@ impl Impl { // test for #8601 -enum Type { Constant(#[allow(unused_tuple_struct_fields)] T) } +enum Type { Constant(#[allow(dead_code)] T) } trait Trait { fn method(&self, _: Type<(K,V)>) -> isize; diff --git a/tests/ui/traits/pointee-deduction.rs b/tests/ui/traits/pointee-deduction.rs index c333b0129c8..82e3aa1ae89 100644 --- a/tests/ui/traits/pointee-deduction.rs +++ b/tests/ui/traits/pointee-deduction.rs @@ -13,8 +13,8 @@ impl Foo for () { type Bar = (); } -struct Wrapper1(#[allow(unused_tuple_struct_fields)] ::Bar); -struct Wrapper2(#[allow(unused_tuple_struct_fields)] as Pointee>::Metadata); +struct Wrapper1(#[allow(dead_code)] ::Bar); +struct Wrapper2(#[allow(dead_code)] as Pointee>::Metadata); fn main() { let _: Wrapper2<()> = Wrapper2(()); diff --git a/tests/ui/traits/principal-less-objects.rs b/tests/ui/traits/principal-less-objects.rs index 62bad0d7d77..5fe01efa4f8 100644 --- a/tests/ui/traits/principal-less-objects.rs +++ b/tests/ui/traits/principal-less-objects.rs @@ -7,7 +7,7 @@ use std::mem; // Array is to make sure the size is not exactly pointer-size, so // we can be sure we are measuring the right size in the // `size_of_val` test. -struct SetOnDrop<'a>(&'a AtomicUsize, #[allow(unused_tuple_struct_fields)] [u8; 64]); +struct SetOnDrop<'a>(&'a AtomicUsize, #[allow(dead_code)] [u8; 64]); impl<'a> Drop for SetOnDrop<'a> { fn drop(&mut self) { self.0.store(self.0.load(Ordering::Relaxed) + 1, Ordering::Relaxed); diff --git a/tests/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs b/tests/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs index 0aa644db052..d869794ec0a 100644 --- a/tests/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs +++ b/tests/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs @@ -9,7 +9,7 @@ #![allow(irrefutable_let_patterns)] -enum Enum { TSVariant(#[allow(unused_tuple_struct_fields)] T), SVariant { _v: T }, UVariant } +enum Enum { TSVariant(#[allow(dead_code)] T), SVariant { _v: T }, UVariant } type Alias = Enum; type AliasFixed = Enum<()>; diff --git a/tests/ui/typeck/issue-2063.rs b/tests/ui/typeck/issue-2063.rs index f08f9d4cfe4..b00bbc082af 100644 --- a/tests/ui/typeck/issue-2063.rs +++ b/tests/ui/typeck/issue-2063.rs @@ -3,7 +3,7 @@ // cause compiler to loop. Note that no instances // of such a type could ever be constructed. -struct T(#[allow(unused_tuple_struct_fields)] Box); +struct T(#[allow(dead_code)] Box); trait ToStr2 { fn my_to_string(&self) -> String; diff --git a/tests/ui/unboxed-closures/type-id-higher-rank.rs b/tests/ui/unboxed-closures/type-id-higher-rank.rs index 1f8aec205fb..a9db71a0399 100644 --- a/tests/ui/unboxed-closures/type-id-higher-rank.rs +++ b/tests/ui/unboxed-closures/type-id-higher-rank.rs @@ -4,7 +4,7 @@ use std::any::{Any, TypeId}; -struct Struct<'a>(#[allow(unused_tuple_struct_fields)] &'a ()); +struct Struct<'a>(#[allow(dead_code)] &'a ()); trait Trait<'a> {} fn main() { diff --git a/tests/ui/unsized-locals/unsized-exprs-rpass.rs b/tests/ui/unsized-locals/unsized-exprs-rpass.rs index 175b02fcb81..83d3680f72f 100644 --- a/tests/ui/unsized-locals/unsized-exprs-rpass.rs +++ b/tests/ui/unsized-locals/unsized-exprs-rpass.rs @@ -2,7 +2,7 @@ #![allow(incomplete_features, unused_braces, unused_parens)] #![feature(unsized_tuple_coercion, unsized_locals, unsized_fn_params)] -struct A(#[allow(unused_tuple_struct_fields)] X); +struct A(#[allow(dead_code)] X); fn udrop(_x: T) {} fn foo() -> Box<[u8]> { diff --git a/tests/ui/unsized/unchanged-param.rs b/tests/ui/unsized/unchanged-param.rs index 6bdc89310eb..8aa2ed15344 100644 --- a/tests/ui/unsized/unchanged-param.rs +++ b/tests/ui/unsized/unchanged-param.rs @@ -1,8 +1,8 @@ // run-pass // Test that we allow unsizing even if there is an unchanged param in the // field getting unsized. -struct A(#[allow(unused_tuple_struct_fields)] T, B); -struct B(#[allow(unused_tuple_struct_fields)] T, U); +struct A(#[allow(dead_code)] T, B); +struct B(#[allow(dead_code)] T, U); fn main() { let x: A<[u32; 1], [u32; 1]> = A([0; 1], B([0; 1], [0; 1])); From 93f553049bec1b306694ef4292093f1b54817efd Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Wed, 29 Nov 2023 15:29:11 -0500 Subject: [PATCH 6/8] Remove #[allow(unused_tuple_struct_fields)] from Clippy tests --- .../auxiliary/helper.rs | 1 - src/tools/clippy/tests/ui/format.fixed | 1 - src/tools/clippy/tests/ui/format.rs | 1 - src/tools/clippy/tests/ui/format.stderr | 30 +++++------ .../ui/from_iter_instead_of_collect.fixed | 2 +- .../tests/ui/from_iter_instead_of_collect.rs | 2 +- .../clippy/tests/ui/must_use_candidates.fixed | 1 - .../clippy/tests/ui/must_use_candidates.rs | 1 - .../tests/ui/must_use_candidates.stderr | 10 ++-- .../clippy/tests/ui/numbered_fields.fixed | 1 - src/tools/clippy/tests/ui/numbered_fields.rs | 1 - .../clippy/tests/ui/numbered_fields.stderr | 4 +- .../clippy/tests/ui/option_if_let_else.fixed | 1 - .../clippy/tests/ui/option_if_let_else.rs | 1 - .../clippy/tests/ui/option_if_let_else.stderr | 50 +++++++++---------- .../clippy/tests/ui/unreadable_literal.fixed | 1 - .../clippy/tests/ui/unreadable_literal.rs | 1 - .../clippy/tests/ui/unreadable_literal.stderr | 20 ++++---- 18 files changed, 59 insertions(+), 70 deletions(-) diff --git a/src/tools/clippy/tests/ui/borrow_interior_mutable_const/auxiliary/helper.rs b/src/tools/clippy/tests/ui/borrow_interior_mutable_const/auxiliary/helper.rs index b03c21262c3..96e037d4fcd 100644 --- a/src/tools/clippy/tests/ui/borrow_interior_mutable_const/auxiliary/helper.rs +++ b/src/tools/clippy/tests/ui/borrow_interior_mutable_const/auxiliary/helper.rs @@ -2,7 +2,6 @@ // As the most common case is the `http` crate, it replicates `http::HeaderName`'s structure. #![allow(clippy::declare_interior_mutable_const)] -#![allow(unused_tuple_struct_fields)] use std::sync::atomic::AtomicUsize; diff --git a/src/tools/clippy/tests/ui/format.fixed b/src/tools/clippy/tests/ui/format.fixed index 36679a9c883..2b32fdeae2b 100644 --- a/src/tools/clippy/tests/ui/format.fixed +++ b/src/tools/clippy/tests/ui/format.fixed @@ -1,6 +1,5 @@ #![warn(clippy::useless_format)] #![allow( - unused_tuple_struct_fields, clippy::print_literal, clippy::redundant_clone, clippy::to_string_in_format_args, diff --git a/src/tools/clippy/tests/ui/format.rs b/src/tools/clippy/tests/ui/format.rs index b0920daf088..bad192067e9 100644 --- a/src/tools/clippy/tests/ui/format.rs +++ b/src/tools/clippy/tests/ui/format.rs @@ -1,6 +1,5 @@ #![warn(clippy::useless_format)] #![allow( - unused_tuple_struct_fields, clippy::print_literal, clippy::redundant_clone, clippy::to_string_in_format_args, diff --git a/src/tools/clippy/tests/ui/format.stderr b/src/tools/clippy/tests/ui/format.stderr index d4630a8f1da..e02fdb1e415 100644 --- a/src/tools/clippy/tests/ui/format.stderr +++ b/src/tools/clippy/tests/ui/format.stderr @@ -1,5 +1,5 @@ error: useless use of `format!` - --> $DIR/format.rs:20:5 + --> $DIR/format.rs:19:5 | LL | format!("foo"); | ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()` @@ -8,19 +8,19 @@ LL | format!("foo"); = help: to override `-D warnings` add `#[allow(clippy::useless_format)]` error: useless use of `format!` - --> $DIR/format.rs:21:5 + --> $DIR/format.rs:20:5 | LL | format!("{{}}"); | ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{}".to_string()` error: useless use of `format!` - --> $DIR/format.rs:22:5 + --> $DIR/format.rs:21:5 | LL | format!("{{}} abc {{}}"); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"{} abc {}".to_string()` error: useless use of `format!` - --> $DIR/format.rs:23:5 + --> $DIR/format.rs:22:5 | LL | / format!( LL | | r##"foo {{}} @@ -35,67 +35,67 @@ LL ~ " bar"##.to_string(); | error: useless use of `format!` - --> $DIR/format.rs:28:13 + --> $DIR/format.rs:27:13 | LL | let _ = format!(""); | ^^^^^^^^^^^ help: consider using `String::new()`: `String::new()` error: useless use of `format!` - --> $DIR/format.rs:30:5 + --> $DIR/format.rs:29:5 | LL | format!("{}", "foo"); | ^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `"foo".to_string()` error: useless use of `format!` - --> $DIR/format.rs:38:5 + --> $DIR/format.rs:37:5 | LL | format!("{}", arg); | ^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `arg.to_string()` error: useless use of `format!` - --> $DIR/format.rs:68:5 + --> $DIR/format.rs:67:5 | LL | format!("{}", 42.to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `42.to_string()` error: useless use of `format!` - --> $DIR/format.rs:70:5 + --> $DIR/format.rs:69:5 | LL | format!("{}", x.display().to_string()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.display().to_string()` error: useless use of `format!` - --> $DIR/format.rs:74:18 + --> $DIR/format.rs:73:18 | LL | let _ = Some(format!("{}", a + "bar")); | ^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `a + "bar"` error: useless use of `format!` - --> $DIR/format.rs:78:22 + --> $DIR/format.rs:77:22 | LL | let _s: String = format!("{}", &*v.join("\n")); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `(&*v.join("\n")).to_string()` error: useless use of `format!` - --> $DIR/format.rs:84:13 + --> $DIR/format.rs:83:13 | LL | let _ = format!("{x}"); | ^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()` error: useless use of `format!` - --> $DIR/format.rs:86:13 + --> $DIR/format.rs:85:13 | LL | let _ = format!("{y}", y = x); | ^^^^^^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `x.to_string()` error: useless use of `format!` - --> $DIR/format.rs:90:13 + --> $DIR/format.rs:89:13 | LL | let _ = format!("{abc}"); | ^^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `abc.to_string()` error: useless use of `format!` - --> $DIR/format.rs:92:13 + --> $DIR/format.rs:91:13 | LL | let _ = format!("{xx}"); | ^^^^^^^^^^^^^^^ help: consider using `.to_string()`: `xx.to_string()` diff --git a/src/tools/clippy/tests/ui/from_iter_instead_of_collect.fixed b/src/tools/clippy/tests/ui/from_iter_instead_of_collect.fixed index 82c8e1d8abd..c250162dfb8 100644 --- a/src/tools/clippy/tests/ui/from_iter_instead_of_collect.fixed +++ b/src/tools/clippy/tests/ui/from_iter_instead_of_collect.fixed @@ -1,5 +1,5 @@ #![warn(clippy::from_iter_instead_of_collect)] -#![allow(unused_imports, unused_tuple_struct_fields)] +#![allow(unused_imports)] #![allow(clippy::useless_vec)] use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque}; diff --git a/src/tools/clippy/tests/ui/from_iter_instead_of_collect.rs b/src/tools/clippy/tests/ui/from_iter_instead_of_collect.rs index 2aed6b14be1..8adbb841c8b 100644 --- a/src/tools/clippy/tests/ui/from_iter_instead_of_collect.rs +++ b/src/tools/clippy/tests/ui/from_iter_instead_of_collect.rs @@ -1,5 +1,5 @@ #![warn(clippy::from_iter_instead_of_collect)] -#![allow(unused_imports, unused_tuple_struct_fields)] +#![allow(unused_imports)] #![allow(clippy::useless_vec)] use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque}; diff --git a/src/tools/clippy/tests/ui/must_use_candidates.fixed b/src/tools/clippy/tests/ui/must_use_candidates.fixed index 3ed705b2906..db20ba29f3d 100644 --- a/src/tools/clippy/tests/ui/must_use_candidates.fixed +++ b/src/tools/clippy/tests/ui/must_use_candidates.fixed @@ -1,7 +1,6 @@ #![feature(never_type)] #![allow( unused_mut, - unused_tuple_struct_fields, clippy::redundant_allocation, clippy::needless_pass_by_ref_mut )] diff --git a/src/tools/clippy/tests/ui/must_use_candidates.rs b/src/tools/clippy/tests/ui/must_use_candidates.rs index ab8efea0ac7..d7e56130245 100644 --- a/src/tools/clippy/tests/ui/must_use_candidates.rs +++ b/src/tools/clippy/tests/ui/must_use_candidates.rs @@ -1,7 +1,6 @@ #![feature(never_type)] #![allow( unused_mut, - unused_tuple_struct_fields, clippy::redundant_allocation, clippy::needless_pass_by_ref_mut )] diff --git a/src/tools/clippy/tests/ui/must_use_candidates.stderr b/src/tools/clippy/tests/ui/must_use_candidates.stderr index 581399f3e48..39446bf6cd9 100644 --- a/src/tools/clippy/tests/ui/must_use_candidates.stderr +++ b/src/tools/clippy/tests/ui/must_use_candidates.stderr @@ -1,5 +1,5 @@ error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:16:1 + --> $DIR/must_use_candidates.rs:15:1 | LL | pub fn pure(i: u8) -> u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn pure(i: u8) -> u8` @@ -8,25 +8,25 @@ LL | pub fn pure(i: u8) -> u8 { = help: to override `-D warnings` add `#[allow(clippy::must_use_candidate)]` error: this method could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:21:5 + --> $DIR/must_use_candidates.rs:20:5 | LL | pub fn inherent_pure(&self) -> u8 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn inherent_pure(&self) -> u8` error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:52:1 + --> $DIR/must_use_candidates.rs:51:1 | LL | pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn with_marker(_d: std::marker::PhantomData<&mut u32>) -> bool` error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:64:1 + --> $DIR/must_use_candidates.rs:63:1 | LL | pub fn rcd(_x: Rc) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn rcd(_x: Rc) -> bool` error: this function could have a `#[must_use]` attribute - --> $DIR/must_use_candidates.rs:72:1 + --> $DIR/must_use_candidates.rs:71:1 | LL | pub fn arcd(_x: Arc) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: add the attribute: `#[must_use] pub fn arcd(_x: Arc) -> bool` diff --git a/src/tools/clippy/tests/ui/numbered_fields.fixed b/src/tools/clippy/tests/ui/numbered_fields.fixed index 7f0a6f8e544..dc88081ba0a 100644 --- a/src/tools/clippy/tests/ui/numbered_fields.fixed +++ b/src/tools/clippy/tests/ui/numbered_fields.fixed @@ -1,5 +1,4 @@ #![warn(clippy::init_numbered_fields)] -#![allow(unused_tuple_struct_fields)] #[derive(Default)] struct TupleStruct(u32, u32, u8); diff --git a/src/tools/clippy/tests/ui/numbered_fields.rs b/src/tools/clippy/tests/ui/numbered_fields.rs index 38f3b36ec4d..e8fa652e3c1 100644 --- a/src/tools/clippy/tests/ui/numbered_fields.rs +++ b/src/tools/clippy/tests/ui/numbered_fields.rs @@ -1,5 +1,4 @@ #![warn(clippy::init_numbered_fields)] -#![allow(unused_tuple_struct_fields)] #[derive(Default)] struct TupleStruct(u32, u32, u8); diff --git a/src/tools/clippy/tests/ui/numbered_fields.stderr b/src/tools/clippy/tests/ui/numbered_fields.stderr index d52a0cf15a8..76f5e082f32 100644 --- a/src/tools/clippy/tests/ui/numbered_fields.stderr +++ b/src/tools/clippy/tests/ui/numbered_fields.stderr @@ -1,5 +1,5 @@ error: used a field initializer for a tuple struct - --> $DIR/numbered_fields.rs:18:13 + --> $DIR/numbered_fields.rs:17:13 | LL | let _ = TupleStruct { | _____________^ @@ -13,7 +13,7 @@ LL | | }; = help: to override `-D warnings` add `#[allow(clippy::init_numbered_fields)]` error: used a field initializer for a tuple struct - --> $DIR/numbered_fields.rs:25:13 + --> $DIR/numbered_fields.rs:24:13 | LL | let _ = TupleStruct { | _____________^ diff --git a/src/tools/clippy/tests/ui/option_if_let_else.fixed b/src/tools/clippy/tests/ui/option_if_let_else.fixed index 363520112ef..d443334bb05 100644 --- a/src/tools/clippy/tests/ui/option_if_let_else.fixed +++ b/src/tools/clippy/tests/ui/option_if_let_else.fixed @@ -1,6 +1,5 @@ #![warn(clippy::option_if_let_else)] #![allow( - unused_tuple_struct_fields, clippy::ref_option_ref, clippy::equatable_if_let, clippy::let_unit_value, diff --git a/src/tools/clippy/tests/ui/option_if_let_else.rs b/src/tools/clippy/tests/ui/option_if_let_else.rs index aaa87a0db54..317c35bf842 100644 --- a/src/tools/clippy/tests/ui/option_if_let_else.rs +++ b/src/tools/clippy/tests/ui/option_if_let_else.rs @@ -1,6 +1,5 @@ #![warn(clippy::option_if_let_else)] #![allow( - unused_tuple_struct_fields, clippy::ref_option_ref, clippy::equatable_if_let, clippy::let_unit_value, diff --git a/src/tools/clippy/tests/ui/option_if_let_else.stderr b/src/tools/clippy/tests/ui/option_if_let_else.stderr index 55a8360ffd0..e053d356ff2 100644 --- a/src/tools/clippy/tests/ui/option_if_let_else.stderr +++ b/src/tools/clippy/tests/ui/option_if_let_else.stderr @@ -1,5 +1,5 @@ error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:11:5 + --> $DIR/option_if_let_else.rs:10:5 | LL | / if let Some(x) = string { LL | | (true, x) @@ -12,19 +12,19 @@ LL | | } = help: to override `-D warnings` add `#[allow(clippy::option_if_let_else)]` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:29:13 + --> $DIR/option_if_let_else.rs:28:13 | LL | let _ = if let Some(s) = *string { s.len() } else { 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `string.map_or(0, |s| s.len())` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:30:13 + --> $DIR/option_if_let_else.rs:29:13 | LL | let _ = if let Some(s) = &num { s } else { &0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:31:13 + --> $DIR/option_if_let_else.rs:30:13 | LL | let _ = if let Some(s) = &mut num { | _____________^ @@ -44,13 +44,13 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:37:13 + --> $DIR/option_if_let_else.rs:36:13 | LL | let _ = if let Some(ref s) = num { s } else { &0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `num.as_ref().map_or(&0, |s| s)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:38:13 + --> $DIR/option_if_let_else.rs:37:13 | LL | let _ = if let Some(mut s) = num { | _____________^ @@ -70,7 +70,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:44:13 + --> $DIR/option_if_let_else.rs:43:13 | LL | let _ = if let Some(ref mut s) = num { | _____________^ @@ -90,7 +90,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:53:5 + --> $DIR/option_if_let_else.rs:52:5 | LL | / if let Some(x) = arg { LL | | let y = x * x; @@ -109,7 +109,7 @@ LL + }) | error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:66:13 + --> $DIR/option_if_let_else.rs:65:13 | LL | let _ = if let Some(x) = arg { | _____________^ @@ -121,7 +121,7 @@ LL | | }; | |_____^ help: try: `arg.map_or_else(side_effect, |x| x)` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:75:13 + --> $DIR/option_if_let_else.rs:74:13 | LL | let _ = if let Some(x) = arg { | _____________^ @@ -144,7 +144,7 @@ LL ~ }, |x| x * x * x * x); | error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:108:13 + --> $DIR/option_if_let_else.rs:107:13 | LL | / if let Some(idx) = s.find('.') { LL | | vec![s[..idx].to_string(), s[idx..].to_string()] @@ -154,7 +154,7 @@ LL | | } | |_____________^ help: try: `s.find('.').map_or_else(|| vec![s.to_string()], |idx| vec![s[..idx].to_string(), s[idx..].to_string()])` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:119:5 + --> $DIR/option_if_let_else.rs:118:5 | LL | / if let Ok(binding) = variable { LL | | println!("Ok {binding}"); @@ -177,13 +177,13 @@ LL + }) | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:143:13 + --> $DIR/option_if_let_else.rs:142:13 | LL | let _ = if let Some(x) = optional { x + 2 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `optional.map_or(5, |x| x + 2)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:153:13 + --> $DIR/option_if_let_else.rs:152:13 | LL | let _ = if let Some(x) = Some(0) { | _____________^ @@ -205,13 +205,13 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:181:13 + --> $DIR/option_if_let_else.rs:180:13 | LL | let _ = if let Some(x) = Some(0) { s.len() + x } else { s.len() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `Some(0).map_or(s.len(), |x| s.len() + x)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:185:13 + --> $DIR/option_if_let_else.rs:184:13 | LL | let _ = if let Some(x) = Some(0) { | _____________^ @@ -231,7 +231,7 @@ LL ~ }); | error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:224:13 + --> $DIR/option_if_let_else.rs:223:13 | LL | let _ = match s { | _____________^ @@ -241,7 +241,7 @@ LL | | }; | |_____^ help: try: `s.map_or(1, |string| string.len())` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:228:13 + --> $DIR/option_if_let_else.rs:227:13 | LL | let _ = match Some(10) { | _____________^ @@ -251,7 +251,7 @@ LL | | }; | |_____^ help: try: `Some(10).map_or(5, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:234:13 + --> $DIR/option_if_let_else.rs:233:13 | LL | let _ = match res { | _____________^ @@ -261,7 +261,7 @@ LL | | }; | |_____^ help: try: `res.map_or(1, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:238:13 + --> $DIR/option_if_let_else.rs:237:13 | LL | let _ = match res { | _____________^ @@ -271,13 +271,13 @@ LL | | }; | |_____^ help: try: `res.map_or(1, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:242:13 + --> $DIR/option_if_let_else.rs:241:13 | LL | let _ = if let Ok(a) = res { a + 1 } else { 5 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `res.map_or(5, |a| a + 1)` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:259:17 + --> $DIR/option_if_let_else.rs:258:17 | LL | let _ = match initial { | _________________^ @@ -287,7 +287,7 @@ LL | | }; | |_________^ help: try: `initial.as_ref().map_or(42, |value| do_something(value))` error: use Option::map_or instead of an if let/else - --> $DIR/option_if_let_else.rs:266:17 + --> $DIR/option_if_let_else.rs:265:17 | LL | let _ = match initial { | _________________^ @@ -297,7 +297,7 @@ LL | | }; | |_________^ help: try: `initial.as_mut().map_or(42, |value| do_something2(value))` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:289:24 + --> $DIR/option_if_let_else.rs:288:24 | LL | let mut _hashmap = if let Some(hm) = &opt { | ________________________^ @@ -308,7 +308,7 @@ LL | | }; | |_____^ help: try: `opt.as_ref().map_or_else(HashMap::new, |hm| hm.clone())` error: use Option::map_or_else instead of an if let/else - --> $DIR/option_if_let_else.rs:295:19 + --> $DIR/option_if_let_else.rs:294:19 | LL | let mut _hm = if let Some(hm) = &opt { hm.clone() } else { new_map!() }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `opt.as_ref().map_or_else(|| new_map!(), |hm| hm.clone())` diff --git a/src/tools/clippy/tests/ui/unreadable_literal.fixed b/src/tools/clippy/tests/ui/unreadable_literal.fixed index 6d8c719ee07..fb9c2672db8 100644 --- a/src/tools/clippy/tests/ui/unreadable_literal.fixed +++ b/src/tools/clippy/tests/ui/unreadable_literal.fixed @@ -1,5 +1,4 @@ #![warn(clippy::unreadable_literal)] -#![allow(unused_tuple_struct_fields)] struct Foo(u64); diff --git a/src/tools/clippy/tests/ui/unreadable_literal.rs b/src/tools/clippy/tests/ui/unreadable_literal.rs index 42ca773c351..0a24fa85254 100644 --- a/src/tools/clippy/tests/ui/unreadable_literal.rs +++ b/src/tools/clippy/tests/ui/unreadable_literal.rs @@ -1,5 +1,4 @@ #![warn(clippy::unreadable_literal)] -#![allow(unused_tuple_struct_fields)] struct Foo(u64); diff --git a/src/tools/clippy/tests/ui/unreadable_literal.stderr b/src/tools/clippy/tests/ui/unreadable_literal.stderr index d7a3377ec37..37f91acf82b 100644 --- a/src/tools/clippy/tests/ui/unreadable_literal.stderr +++ b/src/tools/clippy/tests/ui/unreadable_literal.stderr @@ -1,5 +1,5 @@ error: long literal lacking separators - --> $DIR/unreadable_literal.rs:32:17 + --> $DIR/unreadable_literal.rs:31:17 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `0b11_0110_i64` @@ -8,55 +8,55 @@ LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); = help: to override `-D warnings` add `#[allow(clippy::unreadable_literal)]` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:32:31 + --> $DIR/unreadable_literal.rs:31:31 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^^^^^ help: consider: `0x1234_5678_usize` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:32:49 + --> $DIR/unreadable_literal.rs:31:49 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^ help: consider: `123_456_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:32:61 + --> $DIR/unreadable_literal.rs:31:61 | LL | let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32); | ^^^^^^^^^^^^ help: consider: `1.234_567_f32` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:34:20 + --> $DIR/unreadable_literal.rs:33:20 | LL | let _bad_sci = 1.123456e1; | ^^^^^^^^^^ help: consider: `1.123_456e1` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:36:18 + --> $DIR/unreadable_literal.rs:35:18 | LL | let _fail1 = 0xabcdef; | ^^^^^^^^ help: consider: `0x00ab_cdef` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:37:23 + --> $DIR/unreadable_literal.rs:36:23 | LL | let _fail2: u32 = 0xBAFEBAFE; | ^^^^^^^^^^ help: consider: `0xBAFE_BAFE` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:38:18 + --> $DIR/unreadable_literal.rs:37:18 | LL | let _fail3 = 0xabcdeff; | ^^^^^^^^^ help: consider: `0x0abc_deff` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:39:24 + --> $DIR/unreadable_literal.rs:38:24 | LL | let _fail4: i128 = 0xabcabcabcabcabcabc; | ^^^^^^^^^^^^^^^^^^^^ help: consider: `0x00ab_cabc_abca_bcab_cabc` error: long literal lacking separators - --> $DIR/unreadable_literal.rs:40:18 + --> $DIR/unreadable_literal.rs:39:18 | LL | let _fail5 = 1.100300400; | ^^^^^^^^^^^ help: consider: `1.100_300_400` From 10f40231924b0b1046c63b22fee98b1ca5a3a188 Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Wed, 29 Nov 2023 16:14:09 -0500 Subject: [PATCH 7/8] Allow unused tuple struct fields in Miri tests Otherwise the newly-detected dead code causes new output --- .../miri/tests/fail/both_borrows/newtype_pair_retagging.rs | 2 +- src/tools/miri/tests/fail/both_borrows/newtype_retagging.rs | 2 +- .../tests/fail/concurrency/read_only_atomic_load_large.rs | 2 +- src/tools/miri/tests/fail/dangling_pointers/dyn_size.rs | 2 +- .../fail/function_pointers/abi_mismatch_array_vs_struct.rs | 2 +- src/tools/miri/tests/fail/issue-miri-1112.rs | 2 +- src/tools/miri/tests/fail/unaligned_pointers/drop_in_place.rs | 2 +- .../miri/tests/fail/unaligned_pointers/promise_alignment.rs | 4 ++-- src/tools/miri/tests/pass/align_offset_symbolic.rs | 4 ++-- src/tools/miri/tests/pass/box-custom-alloc.rs | 2 +- src/tools/miri/tests/pass/box.rs | 2 +- src/tools/miri/tests/pass/fat_ptr.rs | 2 +- .../miri/tests/pass/issues/issue-3200-packed2-field-offset.rs | 2 +- src/tools/miri/tests/pass/issues/issue-34571.rs | 2 +- .../miri/tests/pass/issues/issue-36278-prefix-nesting.rs | 2 +- src/tools/miri/tests/pass/packed_struct.rs | 2 +- .../miri/tests/pass/stacked-borrows/no_field_retagging.rs | 2 +- .../tests/pass/stacked-borrows/non_scalar_field_retagging.rs | 2 +- src/tools/miri/tests/pass/stacked-borrows/stacked-borrows.rs | 2 +- src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs | 2 +- src/tools/miri/tests/pass/zst_variant_drop.rs | 2 +- 21 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.rs b/src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.rs index 98dbef6a996..57a7d2f9e7b 100644 --- a/src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.rs +++ b/src/tools/miri/tests/fail/both_borrows/newtype_pair_retagging.rs @@ -3,7 +3,7 @@ //@[stack]error-in-other-file: which is strongly protected //@[tree]error-in-other-file: /deallocation through .* is forbidden/ -struct Newtype<'a>(&'a mut i32, i32); +struct Newtype<'a>(#[allow(dead_code)] &'a mut i32, #[allow(dead_code)] i32); fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) { dealloc(); diff --git a/src/tools/miri/tests/fail/both_borrows/newtype_retagging.rs b/src/tools/miri/tests/fail/both_borrows/newtype_retagging.rs index e280050cdad..746d04d1af1 100644 --- a/src/tools/miri/tests/fail/both_borrows/newtype_retagging.rs +++ b/src/tools/miri/tests/fail/both_borrows/newtype_retagging.rs @@ -4,7 +4,7 @@ //@[stack]error-in-other-file: which is strongly protected //@[tree]error-in-other-file: /deallocation through .* is forbidden/ -struct Newtype<'a>(&'a mut i32); +struct Newtype<'a>(#[allow(dead_code)] &'a mut i32); fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) { dealloc(); diff --git a/src/tools/miri/tests/fail/concurrency/read_only_atomic_load_large.rs b/src/tools/miri/tests/fail/concurrency/read_only_atomic_load_large.rs index a9a8f0f5ddd..2d1cb04907c 100644 --- a/src/tools/miri/tests/fail/concurrency/read_only_atomic_load_large.rs +++ b/src/tools/miri/tests/fail/concurrency/read_only_atomic_load_large.rs @@ -6,7 +6,7 @@ use std::sync::atomic::{AtomicI64, Ordering}; #[repr(align(8))] -struct AlignedI64(i64); +struct AlignedI64(#[allow(dead_code)] i64); fn main() { static X: AlignedI64 = AlignedI64(0); diff --git a/src/tools/miri/tests/fail/dangling_pointers/dyn_size.rs b/src/tools/miri/tests/fail/dangling_pointers/dyn_size.rs index fa01bbc19c9..0ed7b91997c 100644 --- a/src/tools/miri/tests/fail/dangling_pointers/dyn_size.rs +++ b/src/tools/miri/tests/fail/dangling_pointers/dyn_size.rs @@ -1,7 +1,7 @@ // should find the bug even without retagging //@compile-flags: -Zmiri-disable-stacked-borrows -struct SliceWithHead(u8, [u8]); +struct SliceWithHead(#[allow(dead_code)] u8, #[allow(dead_code)] [u8]); fn main() { let buf = [0u32; 1]; diff --git a/src/tools/miri/tests/fail/function_pointers/abi_mismatch_array_vs_struct.rs b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_array_vs_struct.rs index 415e91b250f..401927f5f6c 100644 --- a/src/tools/miri/tests/fail/function_pointers/abi_mismatch_array_vs_struct.rs +++ b/src/tools/miri/tests/fail/function_pointers/abi_mismatch_array_vs_struct.rs @@ -3,7 +3,7 @@ // Some targets treat arrays and structs very differently. We would probably catch that on those // targets since we check the `PassMode`; here we ensure that we catch it on *all* targets // (in particular, on x86-64 the pass mode is `Indirect` for both of these). -struct S(i32, i32, i32, i32); +struct S(#[allow(dead_code)] i32, #[allow(dead_code)] i32, #[allow(dead_code)] i32, #[allow(dead_code)] i32); type A = [i32; 4]; fn main() { diff --git a/src/tools/miri/tests/fail/issue-miri-1112.rs b/src/tools/miri/tests/fail/issue-miri-1112.rs index 387253a3f98..9542673b0d9 100644 --- a/src/tools/miri/tests/fail/issue-miri-1112.rs +++ b/src/tools/miri/tests/fail/issue-miri-1112.rs @@ -1,7 +1,7 @@ trait Empty {} #[repr(transparent)] -pub struct FunnyPointer(dyn Empty); +pub struct FunnyPointer(#[allow(dead_code)] dyn Empty); #[repr(C)] pub struct Meta { diff --git a/src/tools/miri/tests/fail/unaligned_pointers/drop_in_place.rs b/src/tools/miri/tests/fail/unaligned_pointers/drop_in_place.rs index d71d5954a40..2283231eb01 100644 --- a/src/tools/miri/tests/fail/unaligned_pointers/drop_in_place.rs +++ b/src/tools/miri/tests/fail/unaligned_pointers/drop_in_place.rs @@ -1,7 +1,7 @@ //@compile-flags: -Cdebug-assertions=no #[repr(transparent)] -struct HasDrop(u8); +struct HasDrop(#[allow(dead_code)] u8); impl Drop for HasDrop { fn drop(&mut self) {} diff --git a/src/tools/miri/tests/fail/unaligned_pointers/promise_alignment.rs b/src/tools/miri/tests/fail/unaligned_pointers/promise_alignment.rs index 82753fe803c..e075db66039 100644 --- a/src/tools/miri/tests/fail/unaligned_pointers/promise_alignment.rs +++ b/src/tools/miri/tests/fail/unaligned_pointers/promise_alignment.rs @@ -7,7 +7,7 @@ mod utils; #[repr(align(8))] #[derive(Copy, Clone)] -struct Align8(u64); +struct Align8(#[allow(dead_code)] u64); fn main() { let buffer = [0u32; 128]; // get some 4-aligned memory @@ -35,7 +35,7 @@ fn main() { if cfg!(read_unaligned_ptr) { #[repr(align(16))] #[derive(Copy, Clone)] - struct Align16(u128); + struct Align16(#[allow(dead_code)] u128); let align16 = if align8.addr() % 16 == 0 { align8 } else { align8.wrapping_add(2) }; assert!(align16.addr() % 16 == 0); diff --git a/src/tools/miri/tests/pass/align_offset_symbolic.rs b/src/tools/miri/tests/pass/align_offset_symbolic.rs index 3e493952d28..4df364bac7a 100644 --- a/src/tools/miri/tests/pass/align_offset_symbolic.rs +++ b/src/tools/miri/tests/pass/align_offset_symbolic.rs @@ -46,7 +46,7 @@ fn test_align_to() { { #[repr(align(8))] #[derive(Copy, Clone)] - struct Align8(u64); + struct Align8(#[allow(dead_code)] u64); let (_l, m, _r) = unsafe { s.align_to::() }; assert!(m.len() > 0); @@ -97,7 +97,7 @@ fn huge_align() { const SIZE: usize = 1 << 30; #[cfg(target_pointer_width = "16")] const SIZE: usize = 1 << 13; - struct HugeSize([u8; SIZE - 1]); + struct HugeSize(#[allow(dead_code)] [u8; SIZE - 1]); let _ = std::ptr::invalid::(SIZE).align_offset(SIZE); } diff --git a/src/tools/miri/tests/pass/box-custom-alloc.rs b/src/tools/miri/tests/pass/box-custom-alloc.rs index 3d055961d15..75b512f6f72 100644 --- a/src/tools/miri/tests/pass/box-custom-alloc.rs +++ b/src/tools/miri/tests/pass/box-custom-alloc.rs @@ -57,7 +57,7 @@ fn test1() { } // Make the allocator itself so big that the Box is not even a ScalarPair any more. -struct OnceAllocRef<'s, 'a>(&'s OnceAlloc<'a>, u64); +struct OnceAllocRef<'s, 'a>(&'s OnceAlloc<'a>, #[allow(dead_code)] u64); unsafe impl<'shared, 'a: 'shared> Allocator for OnceAllocRef<'shared, 'a> { fn allocate(&self, layout: Layout) -> Result, AllocError> { diff --git a/src/tools/miri/tests/pass/box.rs b/src/tools/miri/tests/pass/box.rs index 3bb481aab88..174bf8be30b 100644 --- a/src/tools/miri/tests/pass/box.rs +++ b/src/tools/miri/tests/pass/box.rs @@ -46,7 +46,7 @@ fn boxed_pair_to_vec() { } #[derive(Debug)] - struct Foo(u64); + struct Foo(#[allow(dead_code)] u64); fn reinterstruct(box_pair: Box) -> Vec { let ref_pair = Box::leak(box_pair) as *mut PairFoo; let ptr_foo = unsafe { std::ptr::addr_of_mut!((*ref_pair).fst) }; diff --git a/src/tools/miri/tests/pass/fat_ptr.rs b/src/tools/miri/tests/pass/fat_ptr.rs index 8317156a218..c5603d2cf80 100644 --- a/src/tools/miri/tests/pass/fat_ptr.rs +++ b/src/tools/miri/tests/pass/fat_ptr.rs @@ -1,6 +1,6 @@ // test that ordinary fat pointer operations work. -struct Wrapper(u32, T); +struct Wrapper(#[allow(dead_code)] u32, T); struct FatPtrContainer<'a> { ptr: &'a [u8], diff --git a/src/tools/miri/tests/pass/issues/issue-3200-packed2-field-offset.rs b/src/tools/miri/tests/pass/issues/issue-3200-packed2-field-offset.rs index a8a7387ecdc..bdcb87e1a2e 100644 --- a/src/tools/miri/tests/pass/issues/issue-3200-packed2-field-offset.rs +++ b/src/tools/miri/tests/pass/issues/issue-3200-packed2-field-offset.rs @@ -2,7 +2,7 @@ use std::mem; #[repr(packed(4))] -struct Slice([u32]); +struct Slice(#[allow(dead_code)] [u32]); #[repr(packed(2), C)] struct PackedSized { diff --git a/src/tools/miri/tests/pass/issues/issue-34571.rs b/src/tools/miri/tests/pass/issues/issue-34571.rs index e1ed8d19e4e..bdb0d39ceba 100644 --- a/src/tools/miri/tests/pass/issues/issue-34571.rs +++ b/src/tools/miri/tests/pass/issues/issue-34571.rs @@ -1,6 +1,6 @@ #[repr(u8)] enum Foo { - Foo(u8), + Foo(#[allow(dead_code)] u8), } fn main() { diff --git a/src/tools/miri/tests/pass/issues/issue-36278-prefix-nesting.rs b/src/tools/miri/tests/pass/issues/issue-36278-prefix-nesting.rs index 6bc8f02c3ba..faa37fb58ef 100644 --- a/src/tools/miri/tests/pass/issues/issue-36278-prefix-nesting.rs +++ b/src/tools/miri/tests/pass/issues/issue-36278-prefix-nesting.rs @@ -4,7 +4,7 @@ use std::mem; const SZ: usize = 100; -struct P([u8; SZ], T); +struct P(#[allow(dead_code)] [u8; SZ], T); type Ack = P>; diff --git a/src/tools/miri/tests/pass/packed_struct.rs b/src/tools/miri/tests/pass/packed_struct.rs index 0b06167aec2..b86235e0c67 100644 --- a/src/tools/miri/tests/pass/packed_struct.rs +++ b/src/tools/miri/tests/pass/packed_struct.rs @@ -102,7 +102,7 @@ fn test_inner_packed() { struct Inner(u32); #[derive(Clone, Copy)] - struct Outer(u8, Inner); + struct Outer(#[allow(dead_code)] u8, Inner); let o = Outer(0, Inner(42)); let _x = o.1; diff --git a/src/tools/miri/tests/pass/stacked-borrows/no_field_retagging.rs b/src/tools/miri/tests/pass/stacked-borrows/no_field_retagging.rs index 48fc8e8668c..507df068a7e 100644 --- a/src/tools/miri/tests/pass/stacked-borrows/no_field_retagging.rs +++ b/src/tools/miri/tests/pass/stacked-borrows/no_field_retagging.rs @@ -1,6 +1,6 @@ //@compile-flags: -Zmiri-retag-fields=none -struct Newtype<'a>(&'a mut i32); +struct Newtype<'a>(#[allow(dead_code)] &'a mut i32); fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) { dealloc(); diff --git a/src/tools/miri/tests/pass/stacked-borrows/non_scalar_field_retagging.rs b/src/tools/miri/tests/pass/stacked-borrows/non_scalar_field_retagging.rs index ddedc19c999..06c0b683810 100644 --- a/src/tools/miri/tests/pass/stacked-borrows/non_scalar_field_retagging.rs +++ b/src/tools/miri/tests/pass/stacked-borrows/non_scalar_field_retagging.rs @@ -1,6 +1,6 @@ //@compile-flags: -Zmiri-retag-fields=scalar -struct Newtype<'a>(&'a mut i32, i32, i32); +struct Newtype<'a>(#[allow(dead_code)] &'a mut i32, #[allow(dead_code)] i32, #[allow(dead_code)] i32); fn dealloc_while_running(_n: Newtype<'_>, dealloc: impl FnOnce()) { dealloc(); diff --git a/src/tools/miri/tests/pass/stacked-borrows/stacked-borrows.rs b/src/tools/miri/tests/pass/stacked-borrows/stacked-borrows.rs index dd3ee36f988..734411ccc72 100644 --- a/src/tools/miri/tests/pass/stacked-borrows/stacked-borrows.rs +++ b/src/tools/miri/tests/pass/stacked-borrows/stacked-borrows.rs @@ -226,7 +226,7 @@ fn not_unpin_not_protected() { // the self-referential-coroutine situation, it does not seem worth the potential trouble.) use std::marker::PhantomPinned; - pub struct NotUnpin(i32, PhantomPinned); + pub struct NotUnpin(#[allow(dead_code)] i32, PhantomPinned); fn inner(x: &mut NotUnpin, f: fn(&mut NotUnpin)) { // `f` may mutate, but it may not deallocate! diff --git a/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs b/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs index d45be91afcc..adad18c1af3 100644 --- a/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs +++ b/src/tools/miri/tests/pass/tree_borrows/tree-borrows.rs @@ -318,7 +318,7 @@ fn not_unpin_not_protected() { // the self-referential-coroutine situation, it does not seem worth the potential trouble.) use std::marker::PhantomPinned; - pub struct NotUnpin(i32, PhantomPinned); + pub struct NotUnpin(#[allow(dead_code)] i32, PhantomPinned); fn inner(x: &mut NotUnpin, f: fn(&mut NotUnpin)) { // `f` may mutate, but it may not deallocate! diff --git a/src/tools/miri/tests/pass/zst_variant_drop.rs b/src/tools/miri/tests/pass/zst_variant_drop.rs index a76f64ce29d..3da6959b221 100644 --- a/src/tools/miri/tests/pass/zst_variant_drop.rs +++ b/src/tools/miri/tests/pass/zst_variant_drop.rs @@ -10,7 +10,7 @@ impl Drop for Foo { static mut FOO: bool = false; enum Bar { - A(Box), + A(#[allow(dead_code)] Box), B(Foo), } From 26194a3ffaf14b86e78ddcd0f2f88c609624d14b Mon Sep 17 00:00:00 2001 From: Jake Goulding Date: Thu, 30 Nov 2023 08:22:31 -0500 Subject: [PATCH 8/8] Rename `unused_tuple_struct_fields` in rustfmt Otherwise tests fail due to unknown lint and dead code warnings. --- src/tools/rustfmt/src/expr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index 8dead8f078d..4b86c2acdc5 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -1947,7 +1947,7 @@ fn rewrite_unary_op( } pub(crate) enum RhsAssignKind<'ast> { - Expr(&'ast ast::ExprKind, #[allow(unused_tuple_struct_fields)] Span), + Expr(&'ast ast::ExprKind, #[allow(dead_code)] Span), Bounds, Ty, }