From ee9a896b66b3a810658d78f744765a4eb1309071 Mon Sep 17 00:00:00 2001 From: Fabian Wolff Date: Mon, 17 Jan 2022 19:02:50 +0100 Subject: [PATCH] Warn about dead tuple struct fields --- compiler/rustc_apfloat/src/ppc.rs | 4 +- .../src/infer/error_reporting/mod.rs | 25 +++---- compiler/rustc_passes/src/check_attr.rs | 9 +-- compiler/rustc_passes/src/dead.rs | 69 +++++++++++++++++-- .../rustc_resolve/src/build_reduced_graph.rs | 4 +- .../rustc_resolve/src/late/diagnostics.rs | 2 +- compiler/rustc_resolve/src/lib.rs | 12 ++-- compiler/rustc_serialize/tests/json.rs | 4 +- library/alloc/src/boxed.rs | 1 + .../alloc/src/collections/btree/set/tests.rs | 2 +- .../alloc/src/collections/vec_deque/tests.rs | 2 +- library/alloc/tests/vec.rs | 6 +- library/core/benches/slice.rs | 3 +- library/core/src/ptr/mod.rs | 2 + library/core/tests/any.rs | 1 + library/core/tests/array.rs | 2 +- library/core/tests/intrinsics.rs | 6 +- library/core/tests/ptr.rs | 12 +++- library/core/tests/slice.rs | 4 +- library/std/src/collections/hash/set/tests.rs | 2 +- library/std/src/io/cursor/tests.rs | 2 +- src/librustdoc/clean/mod.rs | 5 +- src/librustdoc/clean/types.rs | 6 +- src/librustdoc/clean/utils.rs | 2 +- src/librustdoc/fold.rs | 2 +- src/librustdoc/formats/cache.rs | 2 +- src/librustdoc/formats/item_type.rs | 2 +- src/librustdoc/html/render/print_item.rs | 4 +- src/librustdoc/json/conversions.rs | 2 +- .../passes/check_doc_test_visibility.rs | 2 +- src/librustdoc/passes/stripper.rs | 2 +- src/librustdoc/visit.rs | 2 +- .../item-collection/generic-drop-glue.rs | 4 +- .../item-collection/transitive-drop-glue.rs | 10 +-- .../codegen-units/item-collection/unsizing.rs | 2 +- .../run-make-fulldeps/issues-41478-43796/a.rs | 2 +- src/test/ui/align-with-extern-c-fn.rs | 2 +- .../no_std-alloc-error-handler-custom.rs | 2 +- .../no_std-alloc-error-handler-default.rs | 2 +- .../ui/array-slice-vec/show-boxed-slice.rs | 2 +- .../associated-const-type-parameters.rs | 2 +- .../ui/associated-type-bounds/enum-bounds.rs | 1 + .../associated-types-method.rs | 1 + .../associated-types-struct-field-numbered.rs | 2 +- .../async-await/async-fn-size-moved-locals.rs | 2 +- .../async-fn-size-uninit-locals.rs | 2 +- src/test/ui/auto-traits/auto-traits.rs | 2 +- src/test/ui/bench/issue-32062.rs | 4 +- src/test/ui/binding/match-tag.rs | 2 +- src/test/ui/binding/or-pattern.rs | 2 +- src/test/ui/binding/simple-generic-match.rs | 2 +- .../builtin-superkinds-in-metadata2.rs | 2 +- src/test/ui/chalkify/builtin-copy-clone.rs | 2 +- .../migrations/auto_traits.fixed | 6 +- .../migrations/auto_traits.rs | 6 +- .../migrations/multi_diagnostics.fixed | 4 +- .../migrations/multi_diagnostics.rs | 4 +- .../migrations/significant_drop.fixed | 2 +- .../migrations/significant_drop.rs | 2 +- src/test/ui/coercion/issue-14589.rs | 2 +- ...ly_uninhabited_uses_correct_param_env-1.rs | 1 + ...ly_uninhabited_uses_correct_param_env-2.rs | 1 + .../const-argument-cross-crate.rs | 2 +- .../generic_const_exprs/associated-consts.rs | 2 +- .../transparent-maybeunit-array-wrapper.rs | 2 +- src/test/ui/consts/assoc-const.rs | 2 +- src/test/ui/consts/const-needs_drop.rs | 2 + .../consts/const-size_of_val-align_of_val.rs | 2 +- .../const_in_pattern/warn_corner_cases.rs | 2 +- .../consts/issue-70773-mir-typeck-lt-norm.rs | 2 +- src/test/ui/consts/rvalue-static-promotion.rs | 2 +- src/test/ui/consts/transmute-const.rs | 2 +- src/test/ui/derive-uninhabited-enum-38885.rs | 4 +- .../ui/derive-uninhabited-enum-38885.stderr | 4 +- .../deriving-clone-generic-tuple-struct.rs | 1 + src/test/ui/deriving/deriving-copyclone.rs | 2 +- src/test/ui/deriving/issue-58319.rs | 1 + src/test/ui/drop/dropck-eyepatch-reorder.rs | 8 +-- src/test/ui/drop/dropck-eyepatch.rs | 8 +-- src/test/ui/drop/dynamic-drop.rs | 2 +- .../issue-28498-ugeh-with-passed-to-fn.rs | 2 +- .../discriminant_value-wrapper.rs | 1 + .../enum-discriminant/discriminant_value.rs | 3 +- src/test/ui/generator/size-moved-locals.rs | 2 +- ...generic-default-type-params-cross-crate.rs | 2 +- src/test/ui/generics/generic-ivec-leak.rs | 2 +- .../ui/generics/generic-newtype-struct.rs | 2 +- src/test/ui/generics/generic-no-mangle.fixed | 4 +- src/test/ui/generics/generic-no-mangle.rs | 4 +- src/test/ui/generics/generic-recursive-tag.rs | 2 +- .../ui/generics/generic-tag-corruption.rs | 2 +- src/test/ui/generics/generic-tag-local.rs | 2 +- src/test/ui/generics/generic-tag.rs | 2 +- src/test/ui/impl-trait/bounds_regression.rs | 2 +- .../ui/inline-const/const-expr-lifetime.rs | 2 +- src/test/ui/issues/issue-13027.rs | 2 +- src/test/ui/issues/issue-14382.rs | 2 +- src/test/ui/issues/issue-15858.rs | 2 +- src/test/ui/issues/issue-16602-3.rs | 1 + src/test/ui/issues/issue-17905.rs | 1 + src/test/ui/issues/issue-2063.rs | 2 +- src/test/ui/issues/issue-23491.rs | 2 +- src/test/ui/issues/issue-24308.rs | 2 +- .../ui/issues/issue-24805-dropck-itemless.rs | 2 +- src/test/ui/issues/issue-25089.rs | 2 +- src/test/ui/issues/issue-25679.rs | 1 + src/test/ui/issues/issue-25700-1.rs | 2 +- src/test/ui/issues/issue-25700-2.rs | 3 +- src/test/ui/issues/issue-25700.rs | 2 +- src/test/ui/issues/issue-26127.rs | 2 +- src/test/ui/issues/issue-26641.rs | 2 +- src/test/ui/issues/issue-26709.rs | 2 +- src/test/ui/issues/issue-27240.rs | 5 +- .../ui/issues/issue-28498-must-work-ex1.rs | 2 +- .../ui/issues/issue-28498-must-work-ex2.rs | 2 +- src/test/ui/issues/issue-28498-ugeh-ex1.rs | 2 +- src/test/ui/issues/issue-29147-rpass.rs | 1 + src/test/ui/issues/issue-29147.rs | 1 + src/test/ui/issues/issue-29147.stderr | 4 +- src/test/ui/issues/issue-31267-additional.rs | 2 +- src/test/ui/issues/issue-31299.rs | 4 +- src/test/ui/issues/issue-34571.rs | 2 +- src/test/ui/issues/issue-36053.rs | 2 +- .../ui/issues/issue-36278-prefix-nesting.rs | 1 + src/test/ui/issues/issue-40003.rs | 2 +- src/test/ui/issues/issue-4252.rs | 2 +- src/test/ui/issues/issue-46069.rs | 2 +- src/test/ui/issues/issue-5315.rs | 2 +- src/test/ui/issues/issue-61894.rs | 2 +- src/test/ui/issues/issue-7911.rs | 2 +- src/test/ui/layout/unsafe-cell-hides-niche.rs | 6 +- .../ui/lint/dead-code/lint-dead-code-1.rs | 2 +- .../ui/lint/dead-code/lint-dead-code-1.stderr | 8 ++- .../ui/lint/dead-code/lint-dead-code-5.rs | 6 +- .../ui/lint/dead-code/lint-dead-code-5.stderr | 28 ++++++-- .../ui/lint/dead-code/tuple-struct-field.rs | 4 +- .../lint/dead-code/tuple-struct-field.stderr | 14 ++++ .../lint/dead-code/unused-struct-variant.rs | 2 +- .../dead-code/unused-struct-variant.stderr | 16 +++-- src/test/ui/lint/dead-code/with-impl.rs | 2 +- src/test/ui/list.rs | 2 +- src/test/ui/macros/html-literals.rs | 1 + .../ui/macros/macro-tt-followed-by-seq.rs | 1 + ...thod-argument-inference-associated-type.rs | 2 +- .../method-probe-no-guessing-dyn-trait.rs | 4 +- src/test/ui/mir/mir_codegen_switch.rs | 4 +- src/test/ui/mir/mir_fat_ptr.rs | 2 +- src/test/ui/mir/mir_raw_fat_ptr.rs | 1 + src/test/ui/mir/mir_refs_correct.rs | 4 +- src/test/ui/nullable-pointer-iotareduction.rs | 2 +- src/test/ui/optimization-fuel-0.rs | 2 + src/test/ui/optimization-fuel-1.rs | 2 + .../ui/packed/packed-struct-drop-aligned.rs | 2 +- .../ui/packed/packed-struct-optimized-enum.rs | 2 +- .../ui/packed/packed-tuple-struct-layout.rs | 2 + .../issues/issue-70388-without-witness.fixed | 2 +- .../issues/issue-70388-without-witness.rs | 2 +- src/test/ui/range_inclusive.rs | 2 +- src/test/ui/repr/repr-no-niche.rs | 16 ++--- ...-hide-behind-direct-unsafe-ptr-embedded.rs | 2 +- ...low-hide-behind-direct-unsafe-ptr-param.rs | 2 +- ...ide-behind-indirect-unsafe-ptr-embedded.rs | 2 +- ...w-hide-behind-indirect-unsafe-ptr-param.rs | 2 +- ...cant-hide-behind-direct-struct-embedded.rs | 2 +- ...nt-hide-behind-doubly-indirect-embedded.rs | 2 +- .../cant-hide-behind-doubly-indirect-param.rs | 2 +- ...nt-hide-behind-indirect-struct-embedded.rs | 2 +- .../cant-hide-behind-indirect-struct-param.rs | 2 +- .../rfc-2632-const-trait-impl/const-drop.rs | 2 +- .../ui/rfcs/rfc-2151-raw-identifiers/attr.rs | 2 +- .../specialization-cross-crate.rs | 2 +- ...on-translate-projections-with-lifetimes.rs | 2 +- src/test/ui/stdlib-unit-tests/raw-fat-ptr.rs | 1 + src/test/ui/struct-ctor-mangling.rs | 2 +- .../ui/structs-enums/enum-null-pointer-opt.rs | 6 +- .../enum-nullable-simplifycfg-misopt.rs | 2 +- .../ui/structs-enums/resource-in-struct.rs | 2 +- .../structs-enums/tuple-struct-construct.rs | 1 + .../ui/structs-enums/uninstantiable-struct.rs | 2 +- src/test/ui/trailing-comma.rs | 4 +- .../ui/traits/augmented-assignments-trait.rs | 2 +- .../negated-auto-traits-rpass.rs | 2 +- src/test/ui/traits/object/exclusion.rs | 2 +- src/test/ui/traits/object/generics.rs | 2 +- src/test/ui/traits/pointee-deduction.rs | 4 +- src/test/ui/traits/principal-less-objects.rs | 2 +- .../enum-variant-generic-args-pass.rs | 2 +- .../unboxed-closures/type-id-higher-rank.rs | 2 +- .../ui/unsized-locals/unsized-exprs-rpass.rs | 2 +- src/test/ui/unsized/unchanged-param.rs | 4 +- .../auxiliary/helper.rs | 6 +- src/tools/clippy/tests/ui/format.fixed | 2 +- src/tools/clippy/tests/ui/format.rs | 2 +- .../ui/from_iter_instead_of_collect.fixed | 2 +- .../tests/ui/from_iter_instead_of_collect.rs | 2 +- .../clippy/tests/ui/must_use_candidates.fixed | 2 +- .../clippy/tests/ui/must_use_candidates.rs | 2 +- .../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 | 2 +- .../clippy/tests/ui/option_if_let_else.rs | 2 +- .../clippy/tests/ui/unreadable_literal.fixed | 4 +- .../clippy/tests/ui/unreadable_literal.rs | 4 +- src/tools/rustfmt/src/expr.rs | 8 +-- src/tools/rustfmt/src/items.rs | 6 +- src/tools/rustfmt/src/macros.rs | 2 +- 207 files changed, 422 insertions(+), 284 deletions(-) create mode 100644 src/test/ui/lint/dead-code/tuple-struct-field.stderr diff --git a/compiler/rustc_apfloat/src/ppc.rs b/compiler/rustc_apfloat/src/ppc.rs index 4ae8edf3157eb..a4d48358aa364 100644 --- a/compiler/rustc_apfloat/src/ppc.rs +++ b/compiler/rustc_apfloat/src/ppc.rs @@ -30,7 +30,7 @@ pub type DoubleDouble = DoubleFloat; // FIXME: Implement all operations in DoubleDouble, and delete these // semantics. // FIXME(eddyb) This shouldn't need to be `pub`, it's only used in bounds. -pub struct FallbackS(F); +pub struct FallbackS(#[allow(dead_code)] F); type Fallback = ieee::IeeeFloat>; impl ieee::Semantics for FallbackS { // Forbid any conversion to/from bits. @@ -45,7 +45,7 @@ impl ieee::Semantics for FallbackS { // truncate the mantissa. The result of that second conversion // may be inexact, but should never underflow. // FIXME(eddyb) This shouldn't need to be `pub`, it's only used in bounds. -pub struct FallbackExtendedS(F); +pub struct FallbackExtendedS(#[allow(dead_code)] F); type FallbackExtended = ieee::IeeeFloat>; impl ieee::Semantics for FallbackExtendedS { // Forbid any conversion to/from bits. diff --git a/compiler/rustc_infer/src/infer/error_reporting/mod.rs b/compiler/rustc_infer/src/infer/error_reporting/mod.rs index 6d39dadc7ba3f..45e1050f84897 100644 --- a/compiler/rustc_infer/src/infer/error_reporting/mod.rs +++ b/compiler/rustc_infer/src/infer/error_reporting/mod.rs @@ -2377,9 +2377,9 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { #[derive(Debug)] enum SubOrigin<'hir> { GAT(&'hir hir::Generics<'hir>), - Impl(&'hir hir::Generics<'hir>), - Trait(&'hir hir::Generics<'hir>), - Fn(&'hir hir::Generics<'hir>), + Impl, + Trait, + Fn, Unknown, } let sub_origin = 'origin: { @@ -2397,9 +2397,8 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }) => SubOrigin::GAT(generics), Node::ImplItem(hir::ImplItem { kind: hir::ImplItemKind::Fn(..), - generics, .. - }) => SubOrigin::Fn(generics), + }) => SubOrigin::Fn, Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Type(..), generics, @@ -2407,21 +2406,19 @@ impl<'a, 'tcx> InferCtxt<'a, 'tcx> { }) => SubOrigin::GAT(generics), Node::TraitItem(hir::TraitItem { kind: hir::TraitItemKind::Fn(..), - generics, .. - }) => SubOrigin::Fn(generics), + }) => SubOrigin::Fn, Node::Item(hir::Item { - kind: hir::ItemKind::Trait(_, _, generics, _, _), + kind: hir::ItemKind::Trait(..), .. - }) => SubOrigin::Trait(generics), + }) => SubOrigin::Trait, Node::Item(hir::Item { - kind: hir::ItemKind::Impl(hir::Impl { generics, .. }), + kind: hir::ItemKind::Impl(hir::Impl { .. }), .. - }) => SubOrigin::Impl(generics), + }) => SubOrigin::Impl, Node::Item(hir::Item { - kind: hir::ItemKind::Fn(_, generics, _), - .. - }) => SubOrigin::Fn(generics), + kind: hir::ItemKind::Fn(..), .. + }) => SubOrigin::Fn, _ => continue, }; } diff --git a/compiler/rustc_passes/src/check_attr.rs b/compiler/rustc_passes/src/check_attr.rs index d7b00699491d4..e4aa71de90a41 100644 --- a/compiler/rustc_passes/src/check_attr.rs +++ b/compiler/rustc_passes/src/check_attr.rs @@ -51,7 +51,7 @@ pub(crate) fn target_from_impl_item<'tcx>( #[derive(Clone, Copy)] enum ItemLike<'tcx> { Item(&'tcx Item<'tcx>), - ForeignItem(&'tcx ForeignItem<'tcx>), + ForeignItem, } struct CheckAttrVisitor<'tcx> { @@ -1889,12 +1889,7 @@ impl<'tcx> Visitor<'tcx> for CheckAttrVisitor<'tcx> { fn visit_foreign_item(&mut self, f_item: &'tcx ForeignItem<'tcx>) { let target = Target::from_foreign_item(f_item); - self.check_attributes( - f_item.hir_id(), - &f_item.span, - target, - Some(ItemLike::ForeignItem(f_item)), - ); + self.check_attributes(f_item.hir_id(), &f_item.span, target, Some(ItemLike::ForeignItem)); intravisit::walk_foreign_item(self, f_item) } diff --git a/compiler/rustc_passes/src/dead.rs b/compiler/rustc_passes/src/dead.rs index 3b15332c678fd..e9d814cbcd1c7 100644 --- a/compiler/rustc_passes/src/dead.rs +++ b/compiler/rustc_passes/src/dead.rs @@ -41,9 +41,11 @@ struct MarkSymbolVisitor<'tcx> { maybe_typeck_results: Option<&'tcx ty::TypeckResults<'tcx>>, live_symbols: FxHashSet, repr_has_repr_c: bool, + repr_has_repr_simd: bool, in_pat: bool, inherited_pub_visibility: bool, pub_visibility: bool, + allow_dead_field: bool, ignore_variant_stack: Vec, // maps from tuple struct constructors to tuple struct items struct_constructors: FxHashMap, @@ -221,6 +223,32 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { } } + fn handle_tuple_field_pattern_match( + &mut self, + lhs: &hir::Pat<'_>, + res: Res, + pats: &[hir::Pat<'_>], + dotdot: Option, + ) { + let variant = match self.typeck_results().node_type(lhs.hir_id).kind() { + ty::Adt(adt, _) => adt.variant_of_res(res), + _ => span_bug!(lhs.span, "non-ADT in tuple struct pattern"), + }; + let first_n = pats.iter().enumerate().take(dotdot.unwrap_or(pats.len())); + let missing = variant.fields.len() - pats.len(); + let last_n = pats + .iter() + .enumerate() + .skip(dotdot.unwrap_or(pats.len())) + .map(|(idx, pat)| (idx + missing, pat)); + for (idx, pat) in first_n.chain(last_n) { + if let PatKind::Wild = pat.kind { + continue; + } + self.insert_def_id(variant.fields[idx].did); + } + } + fn mark_live_symbols(&mut self) { let mut scanned = FxHashSet::default(); while let Some(id) = self.worklist.pop() { @@ -269,19 +297,38 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { } let had_repr_c = self.repr_has_repr_c; + let had_repr_simd = self.repr_has_repr_simd; let had_inherited_pub_visibility = self.inherited_pub_visibility; let had_pub_visibility = self.pub_visibility; + let had_allow_dead_field = self.allow_dead_field; self.repr_has_repr_c = false; + self.repr_has_repr_simd = false; self.inherited_pub_visibility = false; self.pub_visibility = false; + self.allow_dead_field = false; match node { Node::Item(item) => { self.pub_visibility = item.vis.node.is_pub(); - match item.kind { - hir::ItemKind::Struct(..) | hir::ItemKind::Union(..) => { + match &item.kind { + hir::ItemKind::Struct(vd, ..) | hir::ItemKind::Union(vd, ..) => { let def = self.tcx.adt_def(item.def_id); self.repr_has_repr_c = def.repr.c(); + self.repr_has_repr_simd = def.repr.simd(); + + // A single non-public field of unit type in a public tuple struct + // can be used to make the tuple struct constructor private. This + // is allowed and shouldn't yield a "field is never read" warning. + if let hir::VariantData::Tuple([field_def], _) = vd { + match field_def.vis.node { + hir::VisibilityKind::Public => {} + _ => { + if let hir::TyKind::Tup([]) = field_def.ty.kind { + self.allow_dead_field = true; + } + } + } + } intravisit::walk_item(self, &item); } @@ -307,8 +354,10 @@ impl<'tcx> MarkSymbolVisitor<'tcx> { } _ => {} } + self.allow_dead_field = had_allow_dead_field; self.pub_visibility = had_pub_visibility; self.inherited_pub_visibility = had_inherited_pub_visibility; + self.repr_has_repr_simd = had_repr_simd; self.repr_has_repr_c = had_repr_c; } @@ -346,10 +395,15 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { _: rustc_span::Span, ) { let has_repr_c = self.repr_has_repr_c; + let has_repr_simd = self.repr_has_repr_simd; let inherited_pub_visibility = self.inherited_pub_visibility; let pub_visibility = self.pub_visibility; + let allow_dead_field = self.allow_dead_field; let live_fields = def.fields().iter().filter(|f| { - has_repr_c || (pub_visibility && (inherited_pub_visibility || f.vis.node.is_pub())) + has_repr_c + || (pub_visibility && (inherited_pub_visibility || f.vis.node.is_pub())) + || (f.is_positional() && has_repr_simd) + || allow_dead_field }); let hir = self.tcx.hir(); self.live_symbols.extend(live_fields.map(|f| hir.local_def_id(f.hir_id))); @@ -403,6 +457,10 @@ impl<'tcx> Visitor<'tcx> for MarkSymbolVisitor<'tcx> { let res = self.typeck_results().qpath_res(qpath, pat.hir_id); self.handle_res(res); } + PatKind::TupleStruct(ref qpath, ref fields, dotdot) => { + let res = self.typeck_results().qpath_res(qpath, pat.hir_id); + self.handle_tuple_field_pattern_match(pat, res, fields, dotdot); + } _ => (), } @@ -585,9 +643,11 @@ fn find_live<'tcx>( maybe_typeck_results: None, live_symbols: Default::default(), repr_has_repr_c: false, + repr_has_repr_simd: false, in_pat: false, inherited_pub_visibility: false, pub_visibility: false, + allow_dead_field: false, ignore_variant_stack: vec![], struct_constructors, }; @@ -618,8 +678,7 @@ impl<'tcx> DeadVisitor<'tcx> { fn should_warn_about_field(&mut self, field: &hir::FieldDef<'_>) -> bool { let def_id = self.tcx.hir().local_def_id(field.hir_id); let field_type = self.tcx.type_of(def_id); - !field.is_positional() - && !self.symbol_is_live(def_id) + !self.symbol_is_live(def_id) && !field_type.is_phantom_data() && !has_allow_dead_code_or_lang_attr(self.tcx, field.hir_id) } diff --git a/compiler/rustc_resolve/src/build_reduced_graph.rs b/compiler/rustc_resolve/src/build_reduced_graph.rs index 052770b201a5b..8112e0a22ef8c 100644 --- a/compiler/rustc_resolve/src/build_reduced_graph.rs +++ b/compiler/rustc_resolve/src/build_reduced_graph.rs @@ -515,7 +515,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { let crate_root = self.r.resolve_crate_root(source.ident); let crate_name = match crate_root.kind { ModuleKind::Def(.., name) => name, - ModuleKind::Block(..) => unreachable!(), + ModuleKind::Block => unreachable!(), }; // HACK(eddyb) unclear how good this is, but keeping `$crate` // in `source` breaks `src/test/ui/imports/import-crate-var.rs`, @@ -927,7 +927,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> { if self.block_needs_anonymous_module(block) { let module = self.r.new_module( Some(parent), - ModuleKind::Block(block.id), + ModuleKind::Block, expansion.to_expn_id(), block.span, parent.no_implicit_prelude, diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 4cd1b34bedc95..ec68d1410dcf4 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1307,7 +1307,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { // Items from this module self.r.add_module_candidates(module, &mut names, &filter_fn); - if let ModuleKind::Block(..) = module.kind { + if let ModuleKind::Block = module.kind { // We can see through blocks } else { // Items from the prelude diff --git a/compiler/rustc_resolve/src/lib.rs b/compiler/rustc_resolve/src/lib.rs index 25137c6eda763..de50cd7103ece 100644 --- a/compiler/rustc_resolve/src/lib.rs +++ b/compiler/rustc_resolve/src/lib.rs @@ -465,7 +465,7 @@ enum ModuleKind { /// f(); // Resolves to (1) /// } /// ``` - Block(NodeId), + Block, /// Any module with a name. /// /// This could be: @@ -482,7 +482,7 @@ impl ModuleKind { /// Get name of the module. pub fn name(&self) -> Option { match self { - ModuleKind::Block(..) => None, + ModuleKind::Block => None, ModuleKind::Def(.., name) => Some(*name), } } @@ -558,7 +558,7 @@ impl<'a> ModuleData<'a> { ) -> Self { let is_foreign = match kind { ModuleKind::Def(_, def_id, _) => !def_id.is_local(), - ModuleKind::Block(_) => false, + ModuleKind::Block => false, }; ModuleData { parent, @@ -1987,7 +1987,7 @@ impl<'a> Resolver<'a> { }; match module.kind { - ModuleKind::Block(..) => {} // We can see through blocks + ModuleKind::Block => {} // We can see through blocks _ => break, } @@ -2026,7 +2026,7 @@ impl<'a> Resolver<'a> { return Some((self.expn_def_scope(ctxt.remove_mark()), None)); } - if let ModuleKind::Block(..) = module.kind { + if let ModuleKind::Block = module.kind { return Some((module.parent.unwrap().nearest_item_scope(), None)); } @@ -3029,7 +3029,7 @@ impl<'a> Resolver<'a> { let container = match parent.kind { ModuleKind::Def(kind, _, _) => kind.descr(parent.def_id()), - ModuleKind::Block(..) => "block", + ModuleKind::Block => "block", }; let old_noun = match old_binding.is_import() { diff --git a/compiler/rustc_serialize/tests/json.rs b/compiler/rustc_serialize/tests/json.rs index a759fa1bf1a75..54e4e7e25a440 100644 --- a/compiler/rustc_serialize/tests/json.rs +++ b/compiler/rustc_serialize/tests/json.rs @@ -627,8 +627,8 @@ struct DecodeStruct { } #[derive(Decodable)] enum DecodeEnum { - A(f64), - B(string::String), + A(#[allow(dead_code)] f64), + B(#[allow(dead_code)] string::String), } fn check_err>(to_parse: &'static str, expected: DecoderError) { let res: DecodeResult = match from_str(to_parse) { diff --git a/library/alloc/src/boxed.rs b/library/alloc/src/boxed.rs index aa7344ba405a9..54fbb5144b0a9 100644 --- a/library/alloc/src/boxed.rs +++ b/library/alloc/src/boxed.rs @@ -25,6 +25,7 @@ //! //! ``` //! #[derive(Debug)] +//! # #[allow(dead_code)] //! enum List { //! Cons(T, Box>), //! Nil, diff --git a/library/alloc/src/collections/btree/set/tests.rs b/library/alloc/src/collections/btree/set/tests.rs index 7390ff5a59c8c..51ece7fae2601 100644 --- a/library/alloc/src/collections/btree/set/tests.rs +++ b/library/alloc/src/collections/btree/set/tests.rs @@ -469,7 +469,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 2be83f68f017f..021848a48a644 100644 --- a/library/alloc/src/collections/vec_deque/tests.rs +++ b/library/alloc/src/collections/vec_deque/tests.rs @@ -630,7 +630,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/vec.rs b/library/alloc/tests/vec.rs index 705914b44971c..15cb735fde8a1 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs @@ -492,7 +492,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 { @@ -1077,7 +1077,7 @@ fn test_from_iter_specialization_panic_during_drop_leaks() { #[derive(Debug)] enum Droppable { - DroppedTwice(Box), + DroppedTwice(#[allow(dead_code)] Box), PanicOnDrop, } @@ -2251,7 +2251,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 04efa52078778..bef9ddebe4071 100644 --- a/library/core/benches/slice.rs +++ b/library/core/benches/slice.rs @@ -105,6 +105,7 @@ macro_rules! rotate { } #[derive(Clone)] +#[allow(dead_code)] struct Rgb(u8, u8, u8); rotate!(rotate_u8, 32, |i| i as u8); @@ -118,7 +119,7 @@ rotate!(rotate_64_usize_5, 64, |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/src/ptr/mod.rs b/library/core/src/ptr/mod.rs index 8ab72e6aeeafa..92746d6e75f03 100644 --- a/library/core/src/ptr/mod.rs +++ b/library/core/src/ptr/mod.rs @@ -469,7 +469,9 @@ const unsafe fn swap_nonoverlapping_bytes(x: *mut u8, y: *mut u8, len: usize) { // // FIXME repr(simd) broken on emscripten and redox #[cfg_attr(not(any(target_os = "emscripten", target_os = "redox")), repr(simd))] + #[allow(dead_code)] struct Block(u64, u64, u64, u64); + #[allow(dead_code)] struct UnalignedBlock(u64, u64, u64, u64); let block_size = mem::size_of::(); diff --git a/library/core/tests/any.rs b/library/core/tests/any.rs index b36d6f0d40405..b26e9fb312de7 100644 --- a/library/core/tests/any.rs +++ b/library/core/tests/any.rs @@ -119,6 +119,7 @@ fn any_unsized() { fn distinct_type_names() { // https://github.com/rust-lang/rust/issues/84666 + #[allow(dead_code)] struct Velocity(f32, f32); fn type_name_of_val(_: T) -> &'static str { diff --git a/library/core/tests/array.rs b/library/core/tests/array.rs index a778779c0fd88..a018ba1670b93 100644 --- a/library/core/tests/array.rs +++ b/library/core/tests/array.rs @@ -268,7 +268,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/intrinsics.rs b/library/core/tests/intrinsics.rs index 7a2e4e2906557..c50e21bac2a9a 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 b9c0d75b702e5..abcfe4ab30c83 100644 --- a/library/core/tests/ptr.rs +++ b/library/core/tests/ptr.rs @@ -354,19 +354,27 @@ fn align_offset_stride1() { #[test] fn align_offset_weird_strides() { #[repr(packed)] + #[allow(dead_code)] struct A3(u16, u8); + #[allow(dead_code)] struct A4(u32); #[repr(packed)] + #[allow(dead_code)] struct A5(u32, u8); #[repr(packed)] + #[allow(dead_code)] struct A6(u32, u16); #[repr(packed)] + #[allow(dead_code)] struct A7(u32, u16, u8); #[repr(packed)] + #[allow(dead_code)] struct A8(u32, u32); #[repr(packed)] + #[allow(dead_code)] struct A9(u32, u32, u8); #[repr(packed)] + #[allow(dead_code)] struct A10(u32, u32, u16); unsafe fn test_weird_stride(ptr: *const T, align: usize) -> bool { @@ -434,7 +442,7 @@ fn offset_from() { #[test] fn ptr_metadata() { struct Unit; - struct Pair(A, B); + struct Pair(#[allow(dead_code)] A, B); extern "C" { type Extern; } @@ -524,7 +532,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 20e2d8d47c0f5..14007888f7f6f 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs @@ -1942,8 +1942,10 @@ fn test_align_to_zst() { #[test] fn test_align_to_non_trivial() { #[repr(align(8))] + #[allow(dead_code)] struct U64(u64, u64); #[repr(align(8))] + #[allow(dead_code)] struct U64U64U32(u64, u64, u32); let data = [ U64(1, 2), @@ -2029,7 +2031,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 6a625e6243c21..a0a708fef0c1e 100644 --- a/library/std/src/collections/hash/set/tests.rs +++ b/library/std/src/collections/hash/set/tests.rs @@ -351,7 +351,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 { diff --git a/library/std/src/io/cursor/tests.rs b/library/std/src/io/cursor/tests.rs index 5da31ce0ba761..ebe7f52706425 100644 --- a/library/std/src/io/cursor/tests.rs +++ b/library/std/src/io/cursor/tests.rs @@ -510,7 +510,7 @@ fn test_partial_eq() { #[test] fn test_eq() { - struct AssertEq(pub T); + struct AssertEq(#[allow(dead_code)] pub T); let _: AssertEq>> = AssertEq(Cursor::new(Vec::new())); } diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index 5d1e9d6754e93..be507505613e4 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -1315,9 +1315,8 @@ fn maybe_expand_private_type_alias(cx: &mut DocContext<'_>, path: &hir::Path<'_> } _ => None, }); - if let Some(ct) = const_ { - substs - .insert(const_param_def_id.to_def_id(), SubstParam::Constant(ct.clean(cx))); + if let Some(_) = const_ { + substs.insert(const_param_def_id.to_def_id(), SubstParam::Constant); } // FIXME(const_generics_defaults) indices.consts += 1; diff --git a/src/librustdoc/clean/types.rs b/src/librustdoc/clean/types.rs index 00c6e38839f54..fafa0a925828d 100644 --- a/src/librustdoc/clean/types.rs +++ b/src/librustdoc/clean/types.rs @@ -685,7 +685,7 @@ crate enum ItemKind { AssocTypeItem(Vec, Option), /// An item that has been stripped by a rustdoc pass StrippedItem(Box), - KeywordItem(Symbol), + KeywordItem, } impl ItemKind { @@ -722,7 +722,7 @@ impl ItemKind { | AssocConstItem(_, _) | AssocTypeItem(_, _) | StrippedItem(_) - | KeywordItem(_) => [].iter(), + | KeywordItem => [].iter(), } } } @@ -2312,7 +2312,7 @@ impl TypeBinding { crate enum SubstParam { Type(Type), Lifetime(Lifetime), - Constant(Constant), + Constant, } impl SubstParam { diff --git a/src/librustdoc/clean/utils.rs b/src/librustdoc/clean/utils.rs index b14430d10e9fc..e056e02b78995 100644 --- a/src/librustdoc/clean/utils.rs +++ b/src/librustdoc/clean/utils.rs @@ -71,7 +71,7 @@ crate fn krate(cx: &mut DocContext<'_>) -> Crate { ) })); m.items.extend(keywords.into_iter().map(|(def_id, kw)| { - Item::from_def_id_and_parts(def_id, Some(kw), ItemKind::KeywordItem(kw), cx) + Item::from_def_id_and_parts(def_id, Some(kw), ItemKind::KeywordItem, cx) })); } diff --git a/src/librustdoc/fold.rs b/src/librustdoc/fold.rs index cd0f44e5696fe..9fd7e1c648429 100644 --- a/src/librustdoc/fold.rs +++ b/src/librustdoc/fold.rs @@ -87,7 +87,7 @@ crate trait DocFolder: Sized { | PrimitiveItem(_) | AssocConstItem(_, _) | AssocTypeItem(_, _) - | KeywordItem(_) => kind, + | KeywordItem => kind, } } diff --git a/src/librustdoc/formats/cache.rs b/src/librustdoc/formats/cache.rs index a8fef4a317802..ae1d99fdf98b8 100644 --- a/src/librustdoc/formats/cache.rs +++ b/src/librustdoc/formats/cache.rs @@ -376,7 +376,7 @@ impl<'a, 'tcx> DocFolder for CacheBuilder<'a, 'tcx> { | clean::AssocConstItem(..) | clean::AssocTypeItem(..) | clean::StrippedItem(..) - | clean::KeywordItem(..) => { + | clean::KeywordItem => { // FIXME: Do these need handling? // The person writing this comment doesn't know. // So would rather leave them to an expert, diff --git a/src/librustdoc/formats/item_type.rs b/src/librustdoc/formats/item_type.rs index 3979d29b673fd..c095526aaea7e 100644 --- a/src/librustdoc/formats/item_type.rs +++ b/src/librustdoc/formats/item_type.rs @@ -92,7 +92,7 @@ impl<'a> From<&'a clean::Item> for ItemType { clean::AssocConstItem(..) => ItemType::AssocConst, clean::AssocTypeItem(..) => ItemType::AssocType, clean::ForeignTypeItem => ItemType::ForeignType, - clean::KeywordItem(..) => ItemType::Keyword, + clean::KeywordItem => ItemType::Keyword, clean::TraitAliasItem(..) => ItemType::TraitAlias, clean::ProcMacroItem(ref mac) => match mac.kind { MacroKind::Bang => ItemType::Macro, diff --git a/src/librustdoc/html/render/print_item.rs b/src/librustdoc/html/render/print_item.rs index 67821f19a23f6..60009683d710c 100644 --- a/src/librustdoc/html/render/print_item.rs +++ b/src/librustdoc/html/render/print_item.rs @@ -86,7 +86,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, clean::StaticItem(..) | clean::ForeignStaticItem(..) => "Static ", clean::ConstantItem(..) => "Constant ", clean::ForeignTypeItem => "Foreign Type ", - clean::KeywordItem(..) => "Keyword ", + clean::KeywordItem => "Keyword ", clean::OpaqueTyItem(..) => "Opaque Type ", clean::TraitAliasItem(..) => "Trait Alias ", _ => { @@ -158,7 +158,7 @@ pub(super) fn print_item(cx: &Context<'_>, item: &clean::Item, buf: &mut Buffer, clean::StaticItem(ref i) | clean::ForeignStaticItem(ref i) => item_static(buf, cx, item, i), clean::ConstantItem(ref c) => item_constant(buf, cx, item, c), clean::ForeignTypeItem => item_foreign_type(buf, cx, item), - clean::KeywordItem(_) => item_keyword(buf, cx, item), + clean::KeywordItem => item_keyword(buf, cx, item), clean::OpaqueTyItem(ref e) => item_opaque_ty(buf, cx, item, e), clean::TraitAliasItem(ref ta) => item_trait_alias(buf, cx, item, ta), _ => { diff --git a/src/librustdoc/json/conversions.rs b/src/librustdoc/json/conversions.rs index c8efa4bbbcc30..75ec7557f3903 100644 --- a/src/librustdoc/json/conversions.rs +++ b/src/librustdoc/json/conversions.rs @@ -228,7 +228,7 @@ fn from_clean_item(item: clean::Item, tcx: TyCtxt<'_>) -> ItemEnum { }, // `convert_item` early returns `None` for striped items StrippedItem(_) => unreachable!(), - KeywordItem(_) => { + KeywordItem => { panic!("{:?} is not supported for JSON output", item) } ExternCrateItem { ref src } => ItemEnum::ExternCrate { diff --git a/src/librustdoc/passes/check_doc_test_visibility.rs b/src/librustdoc/passes/check_doc_test_visibility.rs index e8f8ff988c1f0..b5c0429738934 100644 --- a/src/librustdoc/passes/check_doc_test_visibility.rs +++ b/src/librustdoc/passes/check_doc_test_visibility.rs @@ -69,7 +69,7 @@ crate fn should_have_doc_example(cx: &DocContext<'_>, item: &clean::Item) -> boo | clean::ExternCrateItem { .. } | clean::ImportItem(_) | clean::PrimitiveItem(_) - | clean::KeywordItem(_) + | clean::KeywordItem // check for trait impl | clean::ImplItem(clean::Impl { trait_: Some(_), .. }) ) diff --git a/src/librustdoc/passes/stripper.rs b/src/librustdoc/passes/stripper.rs index 7b07974ae01c6..44ccd95952e92 100644 --- a/src/librustdoc/passes/stripper.rs +++ b/src/librustdoc/passes/stripper.rs @@ -84,7 +84,7 @@ impl<'a> DocFolder for Stripper<'a> { clean::AssocTypeItem(..) => {} // Keywords are never stripped - clean::KeywordItem(..) => {} + clean::KeywordItem => {} } let fastreturn = match *i.kind { diff --git a/src/librustdoc/visit.rs b/src/librustdoc/visit.rs index df4d1558ebdf4..377c5e6c898f4 100644 --- a/src/librustdoc/visit.rs +++ b/src/librustdoc/visit.rs @@ -42,7 +42,7 @@ crate trait DocVisitor: Sized { | PrimitiveItem(_) | AssocConstItem(_, _) | AssocTypeItem(_, _) - | KeywordItem(_) => {} + | KeywordItem => {} } } diff --git a/src/test/codegen-units/item-collection/generic-drop-glue.rs b/src/test/codegen-units/item-collection/generic-drop-glue.rs index 25cf5dad61403..ca477d0661090 100644 --- a/src/test/codegen-units/item-collection/generic-drop-glue.rs +++ b/src/test/codegen-units/item-collection/generic-drop-glue.rs @@ -34,9 +34,9 @@ enum EnumNoDrop { } -struct NonGenericNoDrop(i32); +struct NonGenericNoDrop(#[allow(dead_code)] i32); -struct NonGenericWithDrop(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/src/test/codegen-units/item-collection/transitive-drop-glue.rs b/src/test/codegen-units/item-collection/transitive-drop-glue.rs index 8249e7cba946b..5f20637b40faf 100644 --- a/src/test/codegen-units/item-collection/transitive-drop-glue.rs +++ b/src/test/codegen-units/item-collection/transitive-drop-glue.rs @@ -6,9 +6,9 @@ #![feature(start)] //~ MONO_ITEM fn std::ptr::drop_in_place:: - shim(Some(Root)) @@ transitive_drop_glue-cgu.0[Internal] -struct Root(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(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(IntermediateGen); -struct IntermediateGen(LeafGen); -struct LeafGen(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/src/test/codegen-units/item-collection/unsizing.rs b/src/test/codegen-units/item-collection/unsizing.rs index 1b963a24ce8be..cda49b2cedb39 100644 --- a/src/test/codegen-units/item-collection/unsizing.rs +++ b/src/test/codegen-units/item-collection/unsizing.rs @@ -39,7 +39,7 @@ impl Trait for u32 { } #[derive(Clone, Copy)] -struct Wrapper(*const T); +struct Wrapper(#[allow(dead_code)] *const T); impl, U: ?Sized> CoerceUnsized> for Wrapper {} diff --git a/src/test/run-make-fulldeps/issues-41478-43796/a.rs b/src/test/run-make-fulldeps/issues-41478-43796/a.rs index fd67221144a38..bdce6abe8e381 100644 --- a/src/test/run-make-fulldeps/issues-41478-43796/a.rs +++ b/src/test/run-make-fulldeps/issues-41478-43796/a.rs @@ -1,5 +1,5 @@ #![crate_type = "lib"] -pub struct V(S); +pub struct V(#[allow(dead_code)] S); pub trait An { type U; } diff --git a/src/test/ui/align-with-extern-c-fn.rs b/src/test/ui/align-with-extern-c-fn.rs index f77f40998de01..659ef88fce69c 100644 --- a/src/test/ui/align-with-extern-c-fn.rs +++ b/src/test/ui/align-with-extern-c-fn.rs @@ -8,7 +8,7 @@ #![feature(repr_align)] #[repr(align(16))] -pub struct A(i64); +pub struct A(#[allow(dead_code)] i64); #[allow(improper_ctypes_definitions)] pub extern "C" fn foo(x: A) {} diff --git a/src/test/ui/allocator/no_std-alloc-error-handler-custom.rs b/src/test/ui/allocator/no_std-alloc-error-handler-custom.rs index c9b4abbfd3fd3..088a886b04861 100644 --- a/src/test/ui/allocator/no_std-alloc-error-handler-custom.rs +++ b/src/test/ui/allocator/no_std-alloc-error-handler-custom.rs @@ -92,7 +92,7 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! { extern fn rust_eh_personality() {} #[derive(Debug)] -struct Page([[u64; 32]; 16]); +struct Page(#[allow(dead_code)] [[u64; 32]; 16]); #[start] pub fn main(_argc: isize, _argv: *const *const u8) -> isize { diff --git a/src/test/ui/allocator/no_std-alloc-error-handler-default.rs b/src/test/ui/allocator/no_std-alloc-error-handler-default.rs index d6cd4a6af855f..59ac286c33a7d 100644 --- a/src/test/ui/allocator/no_std-alloc-error-handler-default.rs +++ b/src/test/ui/allocator/no_std-alloc-error-handler-default.rs @@ -79,7 +79,7 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! { extern fn rust_eh_personality() {} #[derive(Debug)] -struct Page([[u64; 32]; 16]); +struct Page(#[allow(dead_code)] [[u64; 32]; 16]); #[start] pub fn main(_argc: isize, _argv: *const *const u8) -> isize { diff --git a/src/test/ui/array-slice-vec/show-boxed-slice.rs b/src/test/ui/array-slice-vec/show-boxed-slice.rs index dfa4c720bb09a..3ae3686e423fe 100644 --- a/src/test/ui/array-slice-vec/show-boxed-slice.rs +++ b/src/test/ui/array-slice-vec/show-boxed-slice.rs @@ -1,7 +1,7 @@ // run-pass #[derive(Debug)] -struct Foo(Box<[u8]>); +struct Foo(#[allow(dead_code)] Box<[u8]>); pub fn main() { println!("{:?}", Foo(Box::new([0, 1, 2]))); diff --git a/src/test/ui/associated-consts/associated-const-type-parameters.rs b/src/test/ui/associated-consts/associated-const-type-parameters.rs index 47c3313ec2847..b62d47458be5e 100644 --- a/src/test/ui/associated-consts/associated-const-type-parameters.rs +++ b/src/test/ui/associated-consts/associated-const-type-parameters.rs @@ -17,7 +17,7 @@ impl Foo for Def { const X: i32 = 97; } -struct Proxy(T); +struct Proxy(#[allow(dead_code)] T); impl Foo for Proxy { const X: i32 = T::X; diff --git a/src/test/ui/associated-type-bounds/enum-bounds.rs b/src/test/ui/associated-type-bounds/enum-bounds.rs index a6b0bb7070b7a..193f2efe19929 100644 --- a/src/test/ui/associated-type-bounds/enum-bounds.rs +++ b/src/test/ui/associated-type-bounds/enum-bounds.rs @@ -1,6 +1,7 @@ // run-pass #![feature(associated_type_bounds)] +#![allow(dead_code)] trait Tr1 { type As1; } trait Tr2 { type As2; } diff --git a/src/test/ui/associated-types/associated-types-method.rs b/src/test/ui/associated-types/associated-types-method.rs index 64132cfeed7d2..6a6456cbbecdc 100644 --- a/src/test/ui/associated-types/associated-types-method.rs +++ b/src/test/ui/associated-types/associated-types-method.rs @@ -5,6 +5,7 @@ trait Device { type Resources; } +#[allow(dead_code)] struct Foo(D, R); trait Tr { diff --git a/src/test/ui/associated-types/associated-types-struct-field-numbered.rs b/src/test/ui/associated-types/associated-types-struct-field-numbered.rs index fa59060629ddf..b71b71b25f55f 100644 --- a/src/test/ui/associated-types/associated-types-struct-field-numbered.rs +++ b/src/test/ui/associated-types/associated-types-struct-field-numbered.rs @@ -9,7 +9,7 @@ pub trait UnifyKey { fn dummy(&self) { } } -pub struct Node(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/src/test/ui/async-await/async-fn-size-moved-locals.rs b/src/test/ui/async-await/async-fn-size-moved-locals.rs index a603ebd6e8547..a370c30c70283 100644 --- a/src/test/ui/async-await/async-fn-size-moved-locals.rs +++ b/src/test/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([u8; BIG_FUT_SIZE]); +struct BigFut(#[allow(dead_code)] [u8; BIG_FUT_SIZE]); impl BigFut { fn new() -> Self { diff --git a/src/test/ui/async-await/async-fn-size-uninit-locals.rs b/src/test/ui/async-await/async-fn-size-uninit-locals.rs index d5d7b3fc3f0bd..b89b7bb62bdf7 100644 --- a/src/test/ui/async-await/async-fn-size-uninit-locals.rs +++ b/src/test/ui/async-await/async-fn-size-uninit-locals.rs @@ -16,7 +16,7 @@ use std::pin::Pin; use std::task::{Context, Poll}; const BIG_FUT_SIZE: usize = 1024; -struct Big([u8; BIG_FUT_SIZE]); +struct Big(#[allow(dead_code)] [u8; BIG_FUT_SIZE]); impl Big { fn new() -> Self { diff --git a/src/test/ui/auto-traits/auto-traits.rs b/src/test/ui/auto-traits/auto-traits.rs index 567b86c276274..6d8e1a52ec129 100644 --- a/src/test/ui/auto-traits/auto-traits.rs +++ b/src/test/ui/auto-traits/auto-traits.rs @@ -9,7 +9,7 @@ unsafe auto trait AutoUnsafe {} impl !Auto for bool {} impl !AutoUnsafe for bool {} -struct AutoBool(bool); +struct AutoBool(#[allow(dead_code)] bool); impl Auto for AutoBool {} unsafe impl AutoUnsafe for AutoBool {} diff --git a/src/test/ui/bench/issue-32062.rs b/src/test/ui/bench/issue-32062.rs index dc45061da5b50..99b8b7c6012c5 100644 --- a/src/test/ui/bench/issue-32062.rs +++ b/src/test/ui/bench/issue-32062.rs @@ -15,7 +15,7 @@ trait Parser { } } -struct Token(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(L, 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/src/test/ui/binding/match-tag.rs b/src/test/ui/binding/match-tag.rs index eceb646778493..6914a1c6b6d12 100644 --- a/src/test/ui/binding/match-tag.rs +++ b/src/test/ui/binding/match-tag.rs @@ -3,7 +3,7 @@ #![allow(non_camel_case_types)] - +#[allow(dead_code)] enum color { rgb(isize, isize, isize), rgba(isize, isize, isize, isize), diff --git a/src/test/ui/binding/or-pattern.rs b/src/test/ui/binding/or-pattern.rs index 2ab44a96c3a4b..07559e414dcf5 100644 --- a/src/test/ui/binding/or-pattern.rs +++ b/src/test/ui/binding/or-pattern.rs @@ -1,7 +1,7 @@ // run-pass #![allow(non_camel_case_types)] -enum blah { a(isize, isize, 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/src/test/ui/binding/simple-generic-match.rs b/src/test/ui/binding/simple-generic-match.rs index 50cfe19fef48d..acac32b8231b8 100644 --- a/src/test/ui/binding/simple-generic-match.rs +++ b/src/test/ui/binding/simple-generic-match.rs @@ -3,6 +3,6 @@ // pretty-expanded FIXME #23616 -enum clam { a(T), } +enum clam { a(#[allow(dead_code)] T), } pub fn main() { let c = clam::a(2); match c { clam::a::(_) => { } } } diff --git a/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs b/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs index 117014b44ee11..2edc52c6f55f0 100644 --- a/src/test/ui/builtin-superkinds/builtin-superkinds-in-metadata2.rs +++ b/src/test/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(T); +struct X(#[allow(dead_code)] T); impl RequiresShare for X { } diff --git a/src/test/ui/chalkify/builtin-copy-clone.rs b/src/test/ui/chalkify/builtin-copy-clone.rs index 4323e87b08de7..c10406738b806 100644 --- a/src/test/ui/chalkify/builtin-copy-clone.rs +++ b/src/test/ui/chalkify/builtin-copy-clone.rs @@ -4,7 +4,7 @@ // Test that `Clone` is correctly implemented for builtin types. #[derive(Copy, Clone)] -struct S(i32); +struct S(#[allow(dead_code)] i32); fn test_clone(arg: T) { let _ = arg.clone(); diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed index 26703fbf81193..6aea2b5db3a29 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.fixed +++ b/src/test/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 T(i32); +struct S(#[allow(dead_code)] Foo); +struct T(#[allow(dead_code)] i32); -struct U(S, T); +struct U(#[allow(dead_code)] S, T); impl Clone for U { fn clone(&self) -> Self { diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs b/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs index 932db51d43713..002d7d471d361 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/auto_traits.rs +++ b/src/test/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 T(i32); +struct S(#[allow(dead_code)] Foo); +struct T(#[allow(dead_code)] i32); -struct U(S, T); +struct U(#[allow(dead_code)] S, T); impl Clone for U { fn clone(&self) -> Self { diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed index 2b86b0ddade23..18261391ac31a 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.fixed @@ -18,10 +18,10 @@ impl Foo { } } -struct S(Foo); +struct S(#[allow(dead_code)] Foo); #[derive(Clone)] -struct T(i32); +struct T(#[allow(dead_code)] i32); struct U(S, T); diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs index 3cac4abfad7c2..bc2d8b4d19558 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/multi_diagnostics.rs @@ -18,10 +18,10 @@ impl Foo { } } -struct S(Foo); +struct S(#[allow(dead_code)] Foo); #[derive(Clone)] -struct T(i32); +struct T(#[allow(dead_code)] i32); struct U(S, T); diff --git a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed index 63e4000e833eb..672aa4be686ae 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed +++ b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.fixed @@ -13,7 +13,7 @@ impl Drop for Foo { } #[derive(Debug)] -struct ConstainsDropField(Foo, 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/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs index 9d9c54298cf11..9c751064688c4 100644 --- a/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs +++ b/src/test/ui/closures/2229_closure_analysis/migrations/significant_drop.rs @@ -13,7 +13,7 @@ impl Drop for Foo { } #[derive(Debug)] -struct ConstainsDropField(Foo, 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/src/test/ui/coercion/issue-14589.rs b/src/test/ui/coercion/issue-14589.rs index 5d8aab2ce74ce..f92385f8d7275 100644 --- a/src/test/ui/coercion/issue-14589.rs +++ b/src/test/ui/coercion/issue-14589.rs @@ -20,5 +20,5 @@ impl Test { } trait Foo { fn dummy(&self) { }} -struct Output(isize); +struct Output(#[allow(dead_code)] isize); impl Foo for Output {} diff --git a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-1.rs b/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-1.rs index aa0f9131aa7f5..b7dc537a4336e 100644 --- a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-1.rs +++ b/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-1.rs @@ -9,6 +9,7 @@ trait Foo { const ASSOC: usize = 1; } +#[allow(dead_code)] struct Iced(T, [(); T::ASSOC]) where [(); T::ASSOC]: ; diff --git a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-2.rs b/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-2.rs index d0864414cc1fd..21aa8c9df76e2 100644 --- a/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-2.rs +++ b/src/test/ui/const-generics/conservative_is_privately_uninhabited_uses_correct_param_env-2.rs @@ -9,6 +9,7 @@ trait Foo { const ASSOC: usize = 1; } +#[allow(dead_code)] struct Iced(T, [(); T::ASSOC]) where [(); T::ASSOC]: ; diff --git a/src/test/ui/const-generics/const-argument-cross-crate.rs b/src/test/ui/const-generics/const-argument-cross-crate.rs index fda3ec3eef799..ff9cebdf7ec9b 100644 --- a/src/test/ui/const-generics/const-argument-cross-crate.rs +++ b/src/test/ui/const-generics/const-argument-cross-crate.rs @@ -4,7 +4,7 @@ extern crate const_generic_lib; -struct Container(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/src/test/ui/const-generics/generic_const_exprs/associated-consts.rs b/src/test/ui/const-generics/generic_const_exprs/associated-consts.rs index 4d89f188ad777..3bc72fe7faa1a 100644 --- a/src/test/ui/const-generics/generic_const_exprs/associated-consts.rs +++ b/src/test/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(C); +pub struct Block(#[allow(dead_code)] C); pub fn test() where diff --git a/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs index 926e807feb0b4..11251651e99fc 100644 --- a/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs +++ b/src/test/ui/const-generics/transparent-maybeunit-array-wrapper.rs @@ -7,6 +7,6 @@ use std::mem::MaybeUninit; #[repr(transparent)] -pub struct MaybeUninitWrapper(MaybeUninit<[u64; N]>); +pub struct MaybeUninitWrapper(#[allow(dead_code)] MaybeUninit<[u64; N]>); fn main() {} diff --git a/src/test/ui/consts/assoc-const.rs b/src/test/ui/consts/assoc-const.rs index b70479d255b5f..021bcb401022a 100644 --- a/src/test/ui/consts/assoc-const.rs +++ b/src/test/ui/consts/assoc-const.rs @@ -6,7 +6,7 @@ trait Nat { } struct Zero; -struct Succ(N); +struct Succ(#[allow(dead_code)] N); impl Nat for Zero { const VALUE: usize = 0; diff --git a/src/test/ui/consts/const-needs_drop.rs b/src/test/ui/consts/const-needs_drop.rs index 58e801164428f..bf622e3893984 100644 --- a/src/test/ui/consts/const-needs_drop.rs +++ b/src/test/ui/consts/const-needs_drop.rs @@ -2,8 +2,10 @@ use std::mem; +#[allow(dead_code)] struct Trivial(u8, f32); +#[allow(dead_code)] struct NonTrivial(u8, String); const CONST_U8: bool = mem::needs_drop::(); diff --git a/src/test/ui/consts/const-size_of_val-align_of_val.rs b/src/test/ui/consts/const-size_of_val-align_of_val.rs index 5c0d7d94d64f1..572729a1da431 100644 --- a/src/test/ui/consts/const-size_of_val-align_of_val.rs +++ b/src/test/ui/consts/const-size_of_val-align_of_val.rs @@ -5,7 +5,7 @@ use std::mem; -struct Foo(u32); +struct Foo(#[allow(dead_code)] u32); #[derive(Clone, Copy)] struct Bar { diff --git a/src/test/ui/consts/const_in_pattern/warn_corner_cases.rs b/src/test/ui/consts/const_in_pattern/warn_corner_cases.rs index 51e1af359cdcc..d23d85335f898 100644 --- a/src/test/ui/consts/const_in_pattern/warn_corner_cases.rs +++ b/src/test/ui/consts/const_in_pattern/warn_corner_cases.rs @@ -15,7 +15,7 @@ #![warn(indirect_structural_match)] #[derive(Copy, Clone, Debug)] -struct NoDerive(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/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs b/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs index 9d44aa1361cfc..f82ec005a01e1 100644 --- a/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs +++ b/src/test/ui/consts/issue-70773-mir-typeck-lt-norm.rs @@ -1,7 +1,7 @@ // run-pass const HASH_LEN: usize = 20; -struct Hash([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/src/test/ui/consts/rvalue-static-promotion.rs b/src/test/ui/consts/rvalue-static-promotion.rs index 2d7e4ab39893d..f42e8b7059312 100644 --- a/src/test/ui/consts/rvalue-static-promotion.rs +++ b/src/test/ui/consts/rvalue-static-promotion.rs @@ -4,7 +4,7 @@ use std::cell::Cell; const NONE_CELL_STRING: Option> = None; -struct Foo(T); +struct Foo(#[allow(dead_code)] T); impl Foo { const FOO: Option> = None; } diff --git a/src/test/ui/consts/transmute-const.rs b/src/test/ui/consts/transmute-const.rs index 5044d99ec5183..65e5700d083f6 100644 --- a/src/test/ui/consts/transmute-const.rs +++ b/src/test/ui/consts/transmute-const.rs @@ -3,7 +3,7 @@ use std::mem; #[repr(transparent)] -struct Foo(u32); +struct Foo(#[allow(dead_code)] u32); const TRANSMUTED_U32: u32 = unsafe { mem::transmute(Foo(3)) }; diff --git a/src/test/ui/derive-uninhabited-enum-38885.rs b/src/test/ui/derive-uninhabited-enum-38885.rs index 35c3065ea8150..c4255a64adea8 100644 --- a/src/test/ui/derive-uninhabited-enum-38885.rs +++ b/src/test/ui/derive-uninhabited-enum-38885.rs @@ -9,8 +9,8 @@ enum Void {} #[derive(Debug)] enum Foo { - Bar(u8), - Void(Void), //~ WARN never constructed + Bar(#[allow(dead_code)] u8), + Void(#[allow(dead_code)] Void), //~ WARN never constructed } fn main() { diff --git a/src/test/ui/derive-uninhabited-enum-38885.stderr b/src/test/ui/derive-uninhabited-enum-38885.stderr index 72607629d3c10..fdbad3fc54bdb 100644 --- a/src/test/ui/derive-uninhabited-enum-38885.stderr +++ b/src/test/ui/derive-uninhabited-enum-38885.stderr @@ -1,8 +1,8 @@ warning: variant is never constructed: `Void` --> $DIR/derive-uninhabited-enum-38885.rs:13:5 | -LL | Void(Void), - | ^^^^^^^^^^ +LL | Void(#[allow(dead_code)] Void), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-W dead-code` implied by `-W unused` diff --git a/src/test/ui/deriving/deriving-clone-generic-tuple-struct.rs b/src/test/ui/deriving/deriving-clone-generic-tuple-struct.rs index 8b9840de172da..331d72982169d 100644 --- a/src/test/ui/deriving/deriving-clone-generic-tuple-struct.rs +++ b/src/test/ui/deriving/deriving-clone-generic-tuple-struct.rs @@ -2,6 +2,7 @@ // pretty-expanded FIXME #23616 #[derive(Clone)] +#[allow(dead_code)] struct S(T, ()); pub fn main() { diff --git a/src/test/ui/deriving/deriving-copyclone.rs b/src/test/ui/deriving/deriving-copyclone.rs index 78d74a11ffc8b..099feceae81e8 100644 --- a/src/test/ui/deriving/deriving-copyclone.rs +++ b/src/test/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(Liar); +struct Innocent(#[allow(dead_code)] Liar); impl Innocent { fn new() -> Self { diff --git a/src/test/ui/deriving/issue-58319.rs b/src/test/ui/deriving/issue-58319.rs index 757307d944f18..754f5032d1621 100644 --- a/src/test/ui/deriving/issue-58319.rs +++ b/src/test/ui/deriving/issue-58319.rs @@ -3,6 +3,7 @@ fn main() {} #[derive(Clone)] pub struct Little; #[derive(Clone)] +#[allow(dead_code)] pub struct Big( Little, Little, diff --git a/src/test/ui/drop/dropck-eyepatch-reorder.rs b/src/test/ui/drop/dropck-eyepatch-reorder.rs index b4605878a54e3..4a56c45aa92b4 100644 --- a/src/test/ui/drop/dropck-eyepatch-reorder.rs +++ b/src/test/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, A, B); -struct Pr<'a, 'b, B:'a+'b+Foo>(&'static str, &'a B, &'b B); -struct St(&'static str, A); -struct Sr<'a, B:'a+Foo>(&'static str, &'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/src/test/ui/drop/dropck-eyepatch.rs b/src/test/ui/drop/dropck-eyepatch.rs index 9255391e41206..ff5a52b906bfa 100644 --- a/src/test/ui/drop/dropck-eyepatch.rs +++ b/src/test/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, A, B); -struct Pr<'a, 'b, B:'a+'b+Foo>(&'static str, &'a B, &'b B); -struct St(&'static str, A); -struct Sr<'a, B:'a+Foo>(&'static str, &'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/src/test/ui/drop/dynamic-drop.rs b/src/test/ui/drop/dynamic-drop.rs index 736123ed1198f..b33b9da876ef9 100644 --- a/src/test/ui/drop/dynamic-drop.rs +++ b/src/test/ui/drop/dynamic-drop.rs @@ -103,7 +103,7 @@ fn dynamic_drop(a: &Allocator, c: bool) { }; } -struct TwoPtrs<'a>(Ptr<'a>, 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/src/test/ui/dropck/issue-28498-ugeh-with-passed-to-fn.rs b/src/test/ui/dropck/issue-28498-ugeh-with-passed-to-fn.rs index 23fd86a093b59..d2b620f6940bb 100644 --- a/src/test/ui/dropck/issue-28498-ugeh-with-passed-to-fn.rs +++ b/src/test/ui/dropck/issue-28498-ugeh-with-passed-to-fn.rs @@ -21,7 +21,7 @@ impl Drop for ScribbleOnDrop { } } -struct Foo(u32, T, 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/src/test/ui/enum-discriminant/discriminant_value-wrapper.rs b/src/test/ui/enum-discriminant/discriminant_value-wrapper.rs index 65dc9166330d1..1f6bb0cdc3a6f 100644 --- a/src/test/ui/enum-discriminant/discriminant_value-wrapper.rs +++ b/src/test/ui/enum-discriminant/discriminant_value-wrapper.rs @@ -4,6 +4,7 @@ use std::mem; +#[allow(dead_code)] enum ADT { First(u32, u32), Second(u64) diff --git a/src/test/ui/enum-discriminant/discriminant_value.rs b/src/test/ui/enum-discriminant/discriminant_value.rs index eb60aaf4b2d04..d0b361cf19082 100644 --- a/src/test/ui/enum-discriminant/discriminant_value.rs +++ b/src/test/ui/enum-discriminant/discriminant_value.rs @@ -27,13 +27,14 @@ enum CLike3 { D } +#[allow(dead_code)] enum ADT { First(u32, u32), Second(u64) } enum NullablePointer { - Something(&'static u32), + Something(#[allow(dead_code)] &'static u32), Nothing } diff --git a/src/test/ui/generator/size-moved-locals.rs b/src/test/ui/generator/size-moved-locals.rs index 74c60d98154dd..7ce4e84027860 100644 --- a/src/test/ui/generator/size-moved-locals.rs +++ b/src/test/ui/generator/size-moved-locals.rs @@ -18,7 +18,7 @@ use std::ops::Generator; const FOO_SIZE: usize = 1024; -struct Foo([u8; FOO_SIZE]); +struct Foo(#[allow(dead_code)] [u8; FOO_SIZE]); impl Drop for Foo { fn drop(&mut self) {} diff --git a/src/test/ui/generics/generic-default-type-params-cross-crate.rs b/src/test/ui/generics/generic-default-type-params-cross-crate.rs index 9e5eaa72c152f..f798901132bea 100644 --- a/src/test/ui/generics/generic-default-type-params-cross-crate.rs +++ b/src/test/ui/generics/generic-default-type-params-cross-crate.rs @@ -5,7 +5,7 @@ extern crate default_type_params_xc; -struct Vec(Option<(T,A)>); +struct Vec(#[allow(dead_code)] Option<(T,A)>); struct Foo; diff --git a/src/test/ui/generics/generic-ivec-leak.rs b/src/test/ui/generics/generic-ivec-leak.rs index a8ea1d5069bcf..7a1d10a646dfc 100644 --- a/src/test/ui/generics/generic-ivec-leak.rs +++ b/src/test/ui/generics/generic-ivec-leak.rs @@ -1,5 +1,5 @@ // run-pass #![allow(non_camel_case_types)] -enum wrapper { wrapped(T), } +enum wrapper { wrapped(#[allow(dead_code)] T), } pub fn main() { let _w = wrapper::wrapped(vec![1, 2, 3, 4, 5]); } diff --git a/src/test/ui/generics/generic-newtype-struct.rs b/src/test/ui/generics/generic-newtype-struct.rs index 570c982cc8700..92523b76f98d6 100644 --- a/src/test/ui/generics/generic-newtype-struct.rs +++ b/src/test/ui/generics/generic-newtype-struct.rs @@ -1,7 +1,7 @@ // run-pass // pretty-expanded FIXME #23616 -struct S(T); +struct S(#[allow(dead_code)] T); pub fn main() { let _s = S(2); diff --git a/src/test/ui/generics/generic-no-mangle.fixed b/src/test/ui/generics/generic-no-mangle.fixed index 9126ac167cf2a..aa6d6310f5fe3 100644 --- a/src/test/ui/generics/generic-no-mangle.fixed +++ b/src/test/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(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>(&'a i32); +pub struct Baz<'a>(#[allow(dead_code)] &'a i32); impl<'a> Baz<'a> { #[no_mangle] diff --git a/src/test/ui/generics/generic-no-mangle.rs b/src/test/ui/generics/generic-no-mangle.rs index e283cf4bfe544..8a59ca75aafd2 100644 --- a/src/test/ui/generics/generic-no-mangle.rs +++ b/src/test/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(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>(&'a i32); +pub struct Baz<'a>(#[allow(dead_code)] &'a i32); impl<'a> Baz<'a> { #[no_mangle] diff --git a/src/test/ui/generics/generic-recursive-tag.rs b/src/test/ui/generics/generic-recursive-tag.rs index 74f5b701d98a5..5490822975a79 100644 --- a/src/test/ui/generics/generic-recursive-tag.rs +++ b/src/test/ui/generics/generic-recursive-tag.rs @@ -1,7 +1,7 @@ // run-pass #![allow(non_camel_case_types)] -enum list { cons(Box, Box>), nil, } +enum list { #[allow(dead_code)] cons(Box, Box>), nil, } pub fn main() { let _a: list = diff --git a/src/test/ui/generics/generic-tag-corruption.rs b/src/test/ui/generics/generic-tag-corruption.rs index aa26183a0d491..ae20a94d9fde6 100644 --- a/src/test/ui/generics/generic-tag-corruption.rs +++ b/src/test/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(K), } +enum thing { some(#[allow(dead_code)] K), } pub fn main() { let _x = thing::some("hi".to_string()); } diff --git a/src/test/ui/generics/generic-tag-local.rs b/src/test/ui/generics/generic-tag-local.rs index cc85e6e0f0a8d..121ec74f8b72d 100644 --- a/src/test/ui/generics/generic-tag-local.rs +++ b/src/test/ui/generics/generic-tag-local.rs @@ -3,6 +3,6 @@ // pretty-expanded FIXME #23616 -enum clam { a(T), } +enum clam { a(#[allow(dead_code)] T), } pub fn main() { let _c = clam::a(3); } diff --git a/src/test/ui/generics/generic-tag.rs b/src/test/ui/generics/generic-tag.rs index 67f2ccdde34a1..9e844c72552b3 100644 --- a/src/test/ui/generics/generic-tag.rs +++ b/src/test/ui/generics/generic-tag.rs @@ -6,7 +6,7 @@ #![allow(unused_variables)] -enum option { some(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/src/test/ui/impl-trait/bounds_regression.rs b/src/test/ui/impl-trait/bounds_regression.rs index 0fdeb6bdee1cb..763ee5da07004 100644 --- a/src/test/ui/impl-trait/bounds_regression.rs +++ b/src/test/ui/impl-trait/bounds_regression.rs @@ -15,7 +15,7 @@ pub fn future_from_generator< GenFuture(x) } -struct GenFuture>(T); +struct GenFuture>(#[allow(dead_code)] T); impl> FakeFuture for GenFuture { type Output = T::Return; diff --git a/src/test/ui/inline-const/const-expr-lifetime.rs b/src/test/ui/inline-const/const-expr-lifetime.rs index d883deb2845d3..707c8ea0027d0 100644 --- a/src/test/ui/inline-const/const-expr-lifetime.rs +++ b/src/test/ui/inline-const/const-expr-lifetime.rs @@ -11,7 +11,7 @@ fn issue_78174() { assert_eq!(foo, "foo"); } -pub struct InvariantRef<'a, T: ?Sized>(&'a T, PhantomData<&'a mut &'a T>); +pub struct InvariantRef<'a, T: ?Sized>(#[allow(dead_code)] &'a T, PhantomData<&'a mut &'a T>); impl<'a, T: ?Sized> InvariantRef<'a, T> { pub const fn new(r: &'a T) -> Self { diff --git a/src/test/ui/issues/issue-13027.rs b/src/test/ui/issues/issue-13027.rs index 1bab82a543f05..ac0d1f11bd786 100644 --- a/src/test/ui/issues/issue-13027.rs +++ b/src/test/ui/issues/issue-13027.rs @@ -164,7 +164,7 @@ fn range_shadow_multi_pats() { fn misc() { enum Foo { - Bar(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/src/test/ui/issues/issue-14382.rs b/src/test/ui/issues/issue-14382.rs index 671e7a2266742..b5c2362f05c41 100644 --- a/src/test/ui/issues/issue-14382.rs +++ b/src/test/ui/issues/issue-14382.rs @@ -1,6 +1,6 @@ // run-pass #[derive(Debug)] -struct Matrix4(S); +struct Matrix4(#[allow(dead_code)] S); trait POrd {} fn translate>(s: S) -> Matrix4 { Matrix4(s) } diff --git a/src/test/ui/issues/issue-15858.rs b/src/test/ui/issues/issue-15858.rs index 41d2f13952ae0..77941c07671d6 100644 --- a/src/test/ui/issues/issue-15858.rs +++ b/src/test/ui/issues/issue-15858.rs @@ -12,7 +12,7 @@ impl Bar for BarImpl { } -struct Foo(B); +struct Foo(#[allow(dead_code)] B); impl Drop for Foo { fn drop(&mut self) { diff --git a/src/test/ui/issues/issue-16602-3.rs b/src/test/ui/issues/issue-16602-3.rs index dbfeef053daa1..2307cfb81c7dd 100644 --- a/src/test/ui/issues/issue-16602-3.rs +++ b/src/test/ui/issues/issue-16602-3.rs @@ -2,6 +2,7 @@ #![allow(unused_variables)] #![allow(unused_assignments)] #[derive(Debug)] +#[allow(dead_code)] enum Foo { Bar(u32, u32), Baz(&'static u32, &'static u32) diff --git a/src/test/ui/issues/issue-17905.rs b/src/test/ui/issues/issue-17905.rs index 95133a4584430..83cea8b439580 100644 --- a/src/test/ui/issues/issue-17905.rs +++ b/src/test/ui/issues/issue-17905.rs @@ -1,6 +1,7 @@ // run-pass #[derive(Debug)] +#[allow(dead_code)] struct Pair (T, V); impl Pair< diff --git a/src/test/ui/issues/issue-2063.rs b/src/test/ui/issues/issue-2063.rs index 9dbac6ccee1d1..b00bbc082afc5 100644 --- a/src/test/ui/issues/issue-2063.rs +++ b/src/test/ui/issues/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(Box); +struct T(#[allow(dead_code)] Box); trait ToStr2 { fn my_to_string(&self) -> String; diff --git a/src/test/ui/issues/issue-23491.rs b/src/test/ui/issues/issue-23491.rs index d2ded88aeff19..99801a94c3dfb 100644 --- a/src/test/ui/issues/issue-23491.rs +++ b/src/test/ui/issues/issue-23491.rs @@ -2,7 +2,7 @@ #![allow(unused_variables)] #![feature(box_syntax)] -struct Node(T); +struct Node(#[allow(dead_code)] T); fn main() { let x: Box> = box Node([]); diff --git a/src/test/ui/issues/issue-24308.rs b/src/test/ui/issues/issue-24308.rs index 9c39a5d22387d..40950938fc712 100644 --- a/src/test/ui/issues/issue-24308.rs +++ b/src/test/ui/issues/issue-24308.rs @@ -4,7 +4,7 @@ pub trait Foo { fn method2(); } -struct Slice<'a, T: 'a>(&'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/src/test/ui/issues/issue-24805-dropck-itemless.rs b/src/test/ui/issues/issue-24805-dropck-itemless.rs index 555eefeb3a1f8..4d71389351bfa 100644 --- a/src/test/ui/issues/issue-24805-dropck-itemless.rs +++ b/src/test/ui/issues/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(T); + struct $Id(#[allow(dead_code)] T); unsafe impl <#[may_dangle] T: $Bound> Drop for $Id { fn drop(&mut self) { } } diff --git a/src/test/ui/issues/issue-25089.rs b/src/test/ui/issues/issue-25089.rs index 0f0f78623a212..c7063b24608c2 100644 --- a/src/test/ui/issues/issue-25089.rs +++ b/src/test/ui/issues/issue-25089.rs @@ -4,7 +4,7 @@ use std::thread; -struct Foo(i32); +struct Foo(#[allow(dead_code)] i32); impl Drop for Foo { fn drop(&mut self) { diff --git a/src/test/ui/issues/issue-25679.rs b/src/test/ui/issues/issue-25679.rs index 89544c9eb88c9..8415eba887b00 100644 --- a/src/test/ui/issues/issue-25679.rs +++ b/src/test/ui/issues/issue-25679.rs @@ -2,6 +2,7 @@ trait Device { type Resources; } +#[allow(dead_code)] struct Foo(D, R); impl Foo { diff --git a/src/test/ui/issues/issue-25700-1.rs b/src/test/ui/issues/issue-25700-1.rs index 7bc9673a5be36..79652dc882b54 100644 --- a/src/test/ui/issues/issue-25700-1.rs +++ b/src/test/ui/issues/issue-25700-1.rs @@ -1,5 +1,5 @@ // run-pass -struct S(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/src/test/ui/issues/issue-25700-2.rs b/src/test/ui/issues/issue-25700-2.rs index b161e68abafd0..f745da4a5cb07 100644 --- a/src/test/ui/issues/issue-25700-2.rs +++ b/src/test/ui/issues/issue-25700-2.rs @@ -3,8 +3,9 @@ pub trait Parser { type Input; } -pub struct Iter(P, P::Input); +pub struct Iter(#[allow(dead_code)] P, P::Input); +#[allow(dead_code)] pub struct Map(P, F); impl Parser for Map where F: FnMut(P) { type Input = u8; diff --git a/src/test/ui/issues/issue-25700.rs b/src/test/ui/issues/issue-25700.rs index 45c452d618d84..a377e37349dfd 100644 --- a/src/test/ui/issues/issue-25700.rs +++ b/src/test/ui/issues/issue-25700.rs @@ -1,4 +1,4 @@ -struct S(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/src/test/ui/issues/issue-26127.rs b/src/test/ui/issues/issue-26127.rs index cb479a2308599..b76f1ba51a4c8 100644 --- a/src/test/ui/issues/issue-26127.rs +++ b/src/test/ui/issues/issue-26127.rs @@ -1,7 +1,7 @@ // run-pass trait Tr { type T; } impl Tr for u8 { type T=(); } -struct S(I::T); +struct S(#[allow(dead_code)] I::T); fn foo(i: I::T) { S::(i); diff --git a/src/test/ui/issues/issue-26641.rs b/src/test/ui/issues/issue-26641.rs index 4b6f2c2b3bc7d..3256b71660fec 100644 --- a/src/test/ui/issues/issue-26641.rs +++ b/src/test/ui/issues/issue-26641.rs @@ -1,5 +1,5 @@ // run-pass -struct Parser<'a>(Box); +struct Parser<'a>(#[allow(dead_code)] Box); fn main() { let _x = Parser(Box::new(|_|{})); diff --git a/src/test/ui/issues/issue-26709.rs b/src/test/ui/issues/issue-26709.rs index 281ae13399dd2..8a8186de5cc82 100644 --- a/src/test/ui/issues/issue-26709.rs +++ b/src/test/ui/issues/issue-26709.rs @@ -1,5 +1,5 @@ // run-pass -struct Wrapper<'a, T: ?Sized>(&'a mut i32, 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/src/test/ui/issues/issue-27240.rs b/src/test/ui/issues/issue-27240.rs index a22db76b9bc4d..b518e58d19471 100644 --- a/src/test/ui/issues/issue-27240.rs +++ b/src/test/ui/issues/issue-27240.rs @@ -2,12 +2,12 @@ #![allow(unused_assignments)] #![allow(unused_variables)] use std::fmt; -struct NoisyDrop(T); +struct NoisyDrop(#[allow(dead_code)] T); impl Drop for NoisyDrop { fn drop(&mut self) {} } -struct Bar([*const NoisyDrop; 2]); +struct Bar(#[allow(dead_code)] [*const NoisyDrop; 2]); fn fine() { let (u,b); @@ -15,6 +15,7 @@ fn fine() { b = Bar([&NoisyDrop(&u), &NoisyDrop(&u)]); } +#[allow(dead_code)] struct Bar2(*const NoisyDrop, *const NoisyDrop); fn lolwut() { diff --git a/src/test/ui/issues/issue-28498-must-work-ex1.rs b/src/test/ui/issues/issue-28498-must-work-ex1.rs index 4699d3352ad20..37234699893cd 100644 --- a/src/test/ui/issues/issue-28498-must-work-ex1.rs +++ b/src/test/ui/issues/issue-28498-must-work-ex1.rs @@ -6,7 +6,7 @@ use std::cell::Cell; -struct Concrete<'a>(u32, Cell>>); +struct Concrete<'a>(#[allow(dead_code)] u32, Cell>>); fn main() { let mut data = Vec::new(); diff --git a/src/test/ui/issues/issue-28498-must-work-ex2.rs b/src/test/ui/issues/issue-28498-must-work-ex2.rs index cadf62461fdf5..ab0b71960821a 100644 --- a/src/test/ui/issues/issue-28498-must-work-ex2.rs +++ b/src/test/ui/issues/issue-28498-must-work-ex2.rs @@ -6,7 +6,7 @@ use std::cell::Cell; -struct Concrete<'a>(u32, Cell>>); +struct Concrete<'a>(#[allow(dead_code)] u32, Cell>>); struct Foo { data: Vec } diff --git a/src/test/ui/issues/issue-28498-ugeh-ex1.rs b/src/test/ui/issues/issue-28498-ugeh-ex1.rs index 90cf2cddcf02a..ce49cf1ff991d 100644 --- a/src/test/ui/issues/issue-28498-ugeh-ex1.rs +++ b/src/test/ui/issues/issue-28498-ugeh-ex1.rs @@ -8,7 +8,7 @@ #![feature(dropck_eyepatch)] use std::cell::Cell; -struct Concrete<'a>(u32, Cell>>); +struct Concrete<'a>(#[allow(dead_code)] u32, Cell>>); struct Foo { data: Vec } diff --git a/src/test/ui/issues/issue-29147-rpass.rs b/src/test/ui/issues/issue-29147-rpass.rs index 101bca307f1ab..439f8bb5308f2 100644 --- a/src/test/ui/issues/issue-29147-rpass.rs +++ b/src/test/ui/issues/issue-29147-rpass.rs @@ -1,5 +1,6 @@ // run-pass #![recursion_limit="1024"] +#![allow(dead_code)] use std::mem; diff --git a/src/test/ui/issues/issue-29147.rs b/src/test/ui/issues/issue-29147.rs index 271bc526033d4..190ecf46009ff 100644 --- a/src/test/ui/issues/issue-29147.rs +++ b/src/test/ui/issues/issue-29147.rs @@ -1,4 +1,5 @@ #![recursion_limit="1024"] +#![allow(dead_code)] pub struct S0(T,T); pub struct S1(Option>>>,Option>>>); diff --git a/src/test/ui/issues/issue-29147.stderr b/src/test/ui/issues/issue-29147.stderr index 5570e887edce5..138d477dc6b29 100644 --- a/src/test/ui/issues/issue-29147.stderr +++ b/src/test/ui/issues/issue-29147.stderr @@ -1,11 +1,11 @@ error[E0283]: type annotations needed - --> $DIR/issue-29147.rs:21:13 + --> $DIR/issue-29147.rs:22:13 | LL | let _ = >::xxx; | ^^^^^^^^^^^^ cannot infer type for struct `S5<_>` | note: multiple `impl`s satisfying `S5<_>: Foo` found - --> $DIR/issue-29147.rs:17:1 + --> $DIR/issue-29147.rs:18:1 | LL | impl Foo for S5 { fn xxx(&self) {} } | ^^^^^^^^^^^^^^^^^^^^ diff --git a/src/test/ui/issues/issue-31267-additional.rs b/src/test/ui/issues/issue-31267-additional.rs index 70dce2c949035..c6e93533e7c51 100644 --- a/src/test/ui/issues/issue-31267-additional.rs +++ b/src/test/ui/issues/issue-31267-additional.rs @@ -6,7 +6,7 @@ struct Bar; const BAZ: Bar = Bar; #[derive(Debug)] -struct Foo([Bar; 1]); +struct Foo(#[allow(dead_code)] [Bar; 1]); struct Biz; diff --git a/src/test/ui/issues/issue-31299.rs b/src/test/ui/issues/issue-31299.rs index d93ffcb2262eb..e3c422cb97c7b 100644 --- a/src/test/ui/issues/issue-31299.rs +++ b/src/test/ui/issues/issue-31299.rs @@ -25,9 +25,9 @@ impl Front for Vec { type Back = Vec; } -struct PtrBack(Vec); +struct PtrBack(#[allow(dead_code)] Vec); -struct M(PtrBack>); +struct M(#[allow(dead_code)] PtrBack>); #[allow(unused_must_use)] fn main() { diff --git a/src/test/ui/issues/issue-34571.rs b/src/test/ui/issues/issue-34571.rs index bad1bebc69754..c392f59d8da4a 100644 --- a/src/test/ui/issues/issue-34571.rs +++ b/src/test/ui/issues/issue-34571.rs @@ -1,7 +1,7 @@ // run-pass #[repr(u8)] enum Foo { - Foo(u8), + Foo(#[allow(dead_code)] u8), } fn main() { diff --git a/src/test/ui/issues/issue-36053.rs b/src/test/ui/issues/issue-36053.rs index a61c02c0a12c9..8eee1c33b0e63 100644 --- a/src/test/ui/issues/issue-36053.rs +++ b/src/test/ui/issues/issue-36053.rs @@ -7,7 +7,7 @@ use std::iter::FusedIterator; -struct Thing<'a>(&'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/src/test/ui/issues/issue-36278-prefix-nesting.rs b/src/test/ui/issues/issue-36278-prefix-nesting.rs index 62d1f5f825886..5f476932018c5 100644 --- a/src/test/ui/issues/issue-36278-prefix-nesting.rs +++ b/src/test/ui/issues/issue-36278-prefix-nesting.rs @@ -5,6 +5,7 @@ use std::mem; const SZ: usize = 100; +#[allow(dead_code)] struct P([u8; SZ], T); type Ack = P>; diff --git a/src/test/ui/issues/issue-40003.rs b/src/test/ui/issues/issue-40003.rs index 642de6b8fe352..01a2aaffb9ef5 100644 --- a/src/test/ui/issues/issue-40003.rs +++ b/src/test/ui/issues/issue-40003.rs @@ -153,7 +153,7 @@ mod stream { } enum Slot { - Next(usize), + Next(#[allow(dead_code)] usize), _Data { _a: T }, } diff --git a/src/test/ui/issues/issue-4252.rs b/src/test/ui/issues/issue-4252.rs index 48e617fd7ebb5..9b82121baa289 100644 --- a/src/test/ui/issues/issue-4252.rs +++ b/src/test/ui/issues/issue-4252.rs @@ -7,7 +7,7 @@ trait X { } #[derive(Debug)] -struct Y(isize); +struct Y(#[allow(dead_code)] isize); #[derive(Debug)] struct Z { diff --git a/src/test/ui/issues/issue-46069.rs b/src/test/ui/issues/issue-46069.rs index 1d4f789828d8b..f80ea932001f1 100644 --- a/src/test/ui/issues/issue-46069.rs +++ b/src/test/ui/issues/issue-46069.rs @@ -2,7 +2,7 @@ use std::iter::{Fuse, Cloned}; use std::slice::Iter; -struct Foo<'a, T: 'a>(&'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/src/test/ui/issues/issue-5315.rs b/src/test/ui/issues/issue-5315.rs index 38c98254b9350..81d075a98a904 100644 --- a/src/test/ui/issues/issue-5315.rs +++ b/src/test/ui/issues/issue-5315.rs @@ -1,7 +1,7 @@ // run-pass // pretty-expanded FIXME #23616 -struct A(bool); +struct A(#[allow(dead_code)] bool); pub fn main() { let f = A; diff --git a/src/test/ui/issues/issue-61894.rs b/src/test/ui/issues/issue-61894.rs index c018ac73fb536..fe934bdeb6031 100644 --- a/src/test/ui/issues/issue-61894.rs +++ b/src/test/ui/issues/issue-61894.rs @@ -4,7 +4,7 @@ use std::any::type_name; -struct Bar(M); +struct Bar(#[allow(dead_code)] M); impl Bar { fn foo(&self) -> &'static str { diff --git a/src/test/ui/issues/issue-7911.rs b/src/test/ui/issues/issue-7911.rs index de833324bd20f..d4db3b0776bca 100644 --- a/src/test/ui/issues/issue-7911.rs +++ b/src/test/ui/issues/issue-7911.rs @@ -6,7 +6,7 @@ trait FooBar { fn dummy(&self) { } } -struct Bar(i32); +struct Bar(#[allow(dead_code)] i32); struct Foo { bar: Bar } impl FooBar for Bar {} diff --git a/src/test/ui/layout/unsafe-cell-hides-niche.rs b/src/test/ui/layout/unsafe-cell-hides-niche.rs index 4ca3f7a1aad94..d1ffa828fc5df 100644 --- a/src/test/ui/layout/unsafe-cell-hides-niche.rs +++ b/src/test/ui/layout/unsafe-cell-hides-niche.rs @@ -11,13 +11,13 @@ use std::cell::UnsafeCell; use std::mem::size_of; use std::num::NonZeroU32 as N32; -struct Wrapper(T); +struct Wrapper(#[allow(dead_code)] T); #[repr(transparent)] -struct Transparent(T); +struct Transparent(#[allow(dead_code)] T); #[repr(no_niche)] -struct NoNiche(T); +struct NoNiche(#[allow(dead_code)] T); fn main() { assert_eq!(size_of::>>(), 8); diff --git a/src/test/ui/lint/dead-code/lint-dead-code-1.rs b/src/test/ui/lint/dead-code/lint-dead-code-1.rs index 896147fcc7738..de88aeeda0afb 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-1.rs +++ b/src/test/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(isize); //~ ERROR: field is never read struct UsedStruct3; pub struct UsedStruct4; // this struct is never used directly, but its method is, so we don't want diff --git a/src/test/ui/lint/dead-code/lint-dead-code-1.stderr b/src/test/ui/lint/dead-code/lint-dead-code-1.stderr index af97ea98b2b6d..363a6d7afd6bf 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-1.stderr +++ b/src/test/ui/lint/dead-code/lint-dead-code-1.stderr @@ -28,6 +28,12 @@ error: struct is never constructed: `PrivStruct` LL | struct PrivStruct; | ^^^^^^^^^^ +error: field is never read: `0` + --> $DIR/lint-dead-code-1.rs:40:20 + | +LL | struct UsedStruct2(isize); + | ^^^^^ + error: enum is never used: `priv_enum` --> $DIR/lint-dead-code-1.rs:64:6 | @@ -64,5 +70,5 @@ error: function is never used: `baz` LL | fn baz() -> impl Copy { | ^^^ -error: aborting due to 10 previous errors +error: aborting due to 11 previous errors diff --git a/src/test/ui/lint/dead-code/lint-dead-code-5.rs b/src/test/ui/lint/dead-code/lint-dead-code-5.rs index b477c97c5457b..46dbaa32128ef 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-5.rs +++ b/src/test/ui/lint/dead-code/lint-dead-code-5.rs @@ -2,12 +2,12 @@ #![deny(dead_code)] enum Enum1 { - Variant1(isize), + Variant1(isize), //~ ERROR: field is never read Variant2 //~ ERROR: variant is never constructed } enum Enum2 { - Variant3(bool), + Variant3(bool), //~ ERROR: field is never read #[allow(dead_code)] Variant4(isize), Variant5 { _x: isize }, //~ ERROR: variant is never constructed: `Variant5` @@ -15,7 +15,7 @@ enum Enum2 { _Variant7, Variant8 { _field: bool }, Variant9, - Variant10(usize) + Variant10(usize) //~ ERROR: field is never read } impl Enum2 { diff --git a/src/test/ui/lint/dead-code/lint-dead-code-5.stderr b/src/test/ui/lint/dead-code/lint-dead-code-5.stderr index 519add826273f..d0b0d1a3bbfb9 100644 --- a/src/test/ui/lint/dead-code/lint-dead-code-5.stderr +++ b/src/test/ui/lint/dead-code/lint-dead-code-5.stderr @@ -1,8 +1,8 @@ -error: variant is never constructed: `Variant2` - --> $DIR/lint-dead-code-5.rs:6:5 +error: field is never read: `0` + --> $DIR/lint-dead-code-5.rs:5:14 | -LL | Variant2 - | ^^^^^^^^ +LL | Variant1(isize), + | ^^^^^ | note: the lint level is defined here --> $DIR/lint-dead-code-5.rs:2:9 @@ -10,6 +10,18 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ +error: variant is never constructed: `Variant2` + --> $DIR/lint-dead-code-5.rs:6:5 + | +LL | Variant2 + | ^^^^^^^^ + +error: field is never read: `0` + --> $DIR/lint-dead-code-5.rs:10:14 + | +LL | Variant3(bool), + | ^^^^ + error: variant is never constructed: `Variant5` --> $DIR/lint-dead-code-5.rs:13:5 | @@ -22,11 +34,17 @@ error: variant is never constructed: `Variant6` LL | Variant6(isize), | ^^^^^^^^^^^^^^^ +error: field is never read: `0` + --> $DIR/lint-dead-code-5.rs:18:15 + | +LL | Variant10(usize) + | ^^^^^ + error: enum is never used: `Enum3` --> $DIR/lint-dead-code-5.rs:35:6 | LL | enum Enum3 { | ^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 7 previous errors diff --git a/src/test/ui/lint/dead-code/tuple-struct-field.rs b/src/test/ui/lint/dead-code/tuple-struct-field.rs index c8fd32c64d6db..6ffdf4298b32a 100644 --- a/src/test/ui/lint/dead-code/tuple-struct-field.rs +++ b/src/test/ui/lint/dead-code/tuple-struct-field.rs @@ -1,11 +1,9 @@ -// check-pass - #![deny(dead_code)] const LEN: usize = 4; #[derive(Debug)] -struct Wrapper([u8; LEN]); +struct Wrapper([u8; LEN]); //~ ERROR field is never read fn main() { println!("{:?}", Wrapper([0, 1, 2, 3])); diff --git a/src/test/ui/lint/dead-code/tuple-struct-field.stderr b/src/test/ui/lint/dead-code/tuple-struct-field.stderr new file mode 100644 index 0000000000000..2cdf538d42a52 --- /dev/null +++ b/src/test/ui/lint/dead-code/tuple-struct-field.stderr @@ -0,0 +1,14 @@ +error: field is never read: `0` + --> $DIR/tuple-struct-field.rs:6:16 + | +LL | struct Wrapper([u8; LEN]); + | ^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/tuple-struct-field.rs:1:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to previous error + diff --git a/src/test/ui/lint/dead-code/unused-struct-variant.rs b/src/test/ui/lint/dead-code/unused-struct-variant.rs index 69ab29042e5a4..5b35059f37f5f 100644 --- a/src/test/ui/lint/dead-code/unused-struct-variant.rs +++ b/src/test/ui/lint/dead-code/unused-struct-variant.rs @@ -4,7 +4,7 @@ struct F; struct B; enum E { - Foo(F), + Foo(F), //~ ERROR field is never read Bar(B), //~ ERROR variant is never constructed } diff --git a/src/test/ui/lint/dead-code/unused-struct-variant.stderr b/src/test/ui/lint/dead-code/unused-struct-variant.stderr index b93d6d4ac1866..297b45aac0456 100644 --- a/src/test/ui/lint/dead-code/unused-struct-variant.stderr +++ b/src/test/ui/lint/dead-code/unused-struct-variant.stderr @@ -1,8 +1,8 @@ -error: variant is never constructed: `Bar` - --> $DIR/unused-struct-variant.rs:8:5 +error: field is never read: `0` + --> $DIR/unused-struct-variant.rs:7:9 | -LL | Bar(B), - | ^^^^^^ +LL | Foo(F), + | ^ | note: the lint level is defined here --> $DIR/unused-struct-variant.rs:1:9 @@ -11,5 +11,11 @@ LL | #![deny(unused)] | ^^^^^^ = note: `#[deny(dead_code)]` implied by `#[deny(unused)]` -error: aborting due to previous error +error: variant is never constructed: `Bar` + --> $DIR/unused-struct-variant.rs:8:5 + | +LL | Bar(B), + | ^^^^^^ + +error: aborting due to 2 previous errors diff --git a/src/test/ui/lint/dead-code/with-impl.rs b/src/test/ui/lint/dead-code/with-impl.rs index 84829c98e5739..147ec7b9e2e6c 100644 --- a/src/test/ui/lint/dead-code/with-impl.rs +++ b/src/test/ui/lint/dead-code/with-impl.rs @@ -2,7 +2,7 @@ #![deny(dead_code)] -pub struct GenericFoo(T); +pub struct GenericFoo(#[allow(dead_code)] T); type Foo = GenericFoo; diff --git a/src/test/ui/list.rs b/src/test/ui/list.rs index cb83d4103dced..e44c94b3219ab 100644 --- a/src/test/ui/list.rs +++ b/src/test/ui/list.rs @@ -3,7 +3,7 @@ #![allow(non_camel_case_types)] // pretty-expanded FIXME #23616 -enum list { 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/src/test/ui/macros/html-literals.rs b/src/test/ui/macros/html-literals.rs index ae45e97c8b070..e5ff425041a9c 100644 --- a/src/test/ui/macros/html-literals.rs +++ b/src/test/ui/macros/html-literals.rs @@ -88,6 +88,7 @@ pub fn main() { ); } +#[allow(dead_code)] enum HTMLFragment { tag(String, Vec ), text(String), diff --git a/src/test/ui/macros/macro-tt-followed-by-seq.rs b/src/test/ui/macros/macro-tt-followed-by-seq.rs index 90131ebd9203c..67238df85245a 100644 --- a/src/test/ui/macros/macro-tt-followed-by-seq.rs +++ b/src/test/ui/macros/macro-tt-followed-by-seq.rs @@ -5,6 +5,7 @@ use self::Join::*; #[derive(Debug)] +#[allow(dead_code)] enum Join { Keep(A,B), Skip(A,B), diff --git a/src/test/ui/methods/method-argument-inference-associated-type.rs b/src/test/ui/methods/method-argument-inference-associated-type.rs index acd4a8465b075..852747d06b550 100644 --- a/src/test/ui/methods/method-argument-inference-associated-type.rs +++ b/src/test/ui/methods/method-argument-inference-associated-type.rs @@ -7,7 +7,7 @@ pub trait Service { fn call(&self, _req: Self::Request); } -pub struct S(T); +pub struct S(#[allow(dead_code)] T); impl Service for ClientMap { type Request = S>; diff --git a/src/test/ui/methods/method-probe-no-guessing-dyn-trait.rs b/src/test/ui/methods/method-probe-no-guessing-dyn-trait.rs index af362efe15c35..787191a26fbe7 100644 --- a/src/test/ui/methods/method-probe-no-guessing-dyn-trait.rs +++ b/src/test/ui/methods/method-probe-no-guessing-dyn-trait.rs @@ -15,7 +15,7 @@ trait MyTrait1 { impl MyTrait1 for Foo {} -struct Foo(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(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/src/test/ui/mir/mir_codegen_switch.rs b/src/test/ui/mir/mir_codegen_switch.rs index d2589ae4ad297..afdcd36f4bc3e 100644 --- a/src/test/ui/mir/mir_codegen_switch.rs +++ b/src/test/ui/mir/mir_codegen_switch.rs @@ -1,7 +1,7 @@ // run-pass enum Abc { - A(u8), - B(i8), + A(#[allow(dead_code)] u8), + B(#[allow(dead_code)] i8), C, D, } diff --git a/src/test/ui/mir/mir_fat_ptr.rs b/src/test/ui/mir/mir_fat_ptr.rs index fb34de62f3113..0c07fba6e945b 100644 --- a/src/test/ui/mir/mir_fat_ptr.rs +++ b/src/test/ui/mir/mir_fat_ptr.rs @@ -1,7 +1,7 @@ // run-pass // 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/test/ui/mir/mir_raw_fat_ptr.rs b/src/test/ui/mir/mir_raw_fat_ptr.rs index aa2b499b027dc..ea66a96fd25ed 100644 --- a/src/test/ui/mir/mir_raw_fat_ptr.rs +++ b/src/test/ui/mir/mir_raw_fat_ptr.rs @@ -103,6 +103,7 @@ impl Foo for T { } } +#[allow(dead_code)] struct S(u32, T); fn main_ref() { diff --git a/src/test/ui/mir/mir_refs_correct.rs b/src/test/ui/mir/mir_refs_correct.rs index 729db2d25f5af..c5b57f52743af 100644 --- a/src/test/ui/mir/mir_refs_correct.rs +++ b/src/test/ui/mir/mir_refs_correct.rs @@ -3,7 +3,7 @@ extern crate mir_external_refs as ext; -struct S(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(u8) + U(#[allow(dead_code)] u8) } #[derive(PartialEq, Debug, Eq)] diff --git a/src/test/ui/nullable-pointer-iotareduction.rs b/src/test/ui/nullable-pointer-iotareduction.rs index f9edba6743499..3f3a962664e44 100644 --- a/src/test/ui/nullable-pointer-iotareduction.rs +++ b/src/test/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), 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/src/test/ui/optimization-fuel-0.rs b/src/test/ui/optimization-fuel-0.rs index a97c5750f94c3..77c727ad0f7be 100644 --- a/src/test/ui/optimization-fuel-0.rs +++ b/src/test/ui/optimization-fuel-0.rs @@ -6,7 +6,9 @@ use std::mem::size_of; // compile-flags: -Z fuel=foo=0 +#[allow(dead_code)] struct S1(u8, u16, u8); +#[allow(dead_code)] struct S2(u8, u16, u8); fn main() { diff --git a/src/test/ui/optimization-fuel-1.rs b/src/test/ui/optimization-fuel-1.rs index a09f91c68abe7..8b3d139201eeb 100644 --- a/src/test/ui/optimization-fuel-1.rs +++ b/src/test/ui/optimization-fuel-1.rs @@ -6,7 +6,9 @@ use std::mem::size_of; // compile-flags: -Z fuel=foo=1 +#[allow(dead_code)] struct S1(u8, u16, u8); +#[allow(dead_code)] struct S2(u8, u16, u8); fn main() { diff --git a/src/test/ui/packed/packed-struct-drop-aligned.rs b/src/test/ui/packed/packed-struct-drop-aligned.rs index b95cdbbbaad3b..b982d7adf8b64 100644 --- a/src/test/ui/packed/packed-struct-drop-aligned.rs +++ b/src/test/ui/packed/packed-struct-drop-aligned.rs @@ -24,7 +24,7 @@ impl<'a> Drop for Aligned<'a> { } #[repr(transparent)] -struct NotCopy(u8); +struct NotCopy(#[allow(dead_code)] u8); #[repr(packed)] struct Packed<'a>(NotCopy, Aligned<'a>); diff --git a/src/test/ui/packed/packed-struct-optimized-enum.rs b/src/test/ui/packed/packed-struct-optimized-enum.rs index 7ce62464ef02c..c3540f7619b15 100644 --- a/src/test/ui/packed/packed-struct-optimized-enum.rs +++ b/src/test/ui/packed/packed-struct-optimized-enum.rs @@ -1,6 +1,6 @@ // run-pass #[repr(packed)] -struct Packed(T); +struct Packed(#[allow(dead_code)] T); impl Copy for Packed {} impl Clone for Packed { diff --git a/src/test/ui/packed/packed-tuple-struct-layout.rs b/src/test/ui/packed/packed-tuple-struct-layout.rs index b88637fbe5658..879553142da3d 100644 --- a/src/test/ui/packed/packed-tuple-struct-layout.rs +++ b/src/test/ui/packed/packed-tuple-struct-layout.rs @@ -2,9 +2,11 @@ use std::mem; #[repr(packed)] +#[allow(dead_code)] struct S4(u8,[u8; 3]); #[repr(packed)] +#[allow(dead_code)] struct S5(u8,u32); pub fn main() { diff --git a/src/test/ui/parser/issues/issue-70388-without-witness.fixed b/src/test/ui/parser/issues/issue-70388-without-witness.fixed index 464e78fd03595..58721495dcd12 100644 --- a/src/test/ui/parser/issues/issue-70388-without-witness.fixed +++ b/src/test/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(i32); +pub struct Foo(#[allow(dead_code)] i32); fn main() { let Foo(..) = Foo(0); //~ ERROR unexpected `...` diff --git a/src/test/ui/parser/issues/issue-70388-without-witness.rs b/src/test/ui/parser/issues/issue-70388-without-witness.rs index 9e35e4c38aa87..2e679db546476 100644 --- a/src/test/ui/parser/issues/issue-70388-without-witness.rs +++ b/src/test/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(i32); +pub struct Foo(#[allow(dead_code)] i32); fn main() { let Foo(...) = Foo(0); //~ ERROR unexpected `...` diff --git a/src/test/ui/range_inclusive.rs b/src/test/ui/range_inclusive.rs index 7e7a15924b765..2425113b904ad 100644 --- a/src/test/ui/range_inclusive.rs +++ b/src/test/ui/range_inclusive.rs @@ -11,7 +11,7 @@ fn foo() -> isize { 42 } pub fn return_range_to() -> RangeToInclusive { return ..=1; } #[derive(Debug)] -struct P(u8); +struct P(#[allow(dead_code)] u8); pub fn main() { let mut count = 0; diff --git a/src/test/ui/repr/repr-no-niche.rs b/src/test/ui/repr/repr-no-niche.rs index 2e6064aeb0074..3e241e6235846 100644 --- a/src/test/ui/repr/repr-no-niche.rs +++ b/src/test/ui/repr/repr-no-niche.rs @@ -22,29 +22,29 @@ use std::num::{NonZeroU8, NonZeroU16}; mod struct_inline { use std::num::NonZeroU16 as N16; - #[derive(Debug)] pub struct Visible(N16); + #[derive(Debug)] pub struct Visible(#[allow(dead_code)] N16); #[repr(no_niche)] - #[derive(Debug)] pub struct Cloaked(N16); + #[derive(Debug)] pub struct Cloaked(#[allow(dead_code)] N16); #[repr(transparent)] - #[derive(Debug)] pub struct Transparent(N16); + #[derive(Debug)] pub struct Transparent(#[allow(dead_code)] N16); #[repr(transparent, no_niche)] - #[derive(Debug)] pub struct Shadowy(N16); + #[derive(Debug)] pub struct Shadowy(#[allow(dead_code)] N16); } mod struct_param { - #[derive(Debug)] pub struct Visible(T); + #[derive(Debug)] pub struct Visible(#[allow(dead_code)] T); #[repr(no_niche)] - #[derive(Debug)] pub struct Cloaked(T); + #[derive(Debug)] pub struct Cloaked(#[allow(dead_code)] T); #[repr(transparent)] - #[derive(Debug)] pub struct Transparent(T); + #[derive(Debug)] pub struct Transparent(#[allow(dead_code)] T); #[repr(transparent, no_niche)] - #[derive(Debug)] pub struct Shadowy(T); + #[derive(Debug)] pub struct Shadowy(#[allow(dead_code)] T); } mod enum_inline { diff --git a/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs index c6d7166e74065..c95777b0ef197 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs +++ b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-embedded.rs @@ -5,7 +5,7 @@ #![warn(pointer_structural_match)] -struct NoDerive(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/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs index cc7ea6cde8d7f..3f663fd09f884 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs +++ b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-direct-unsafe-ptr-param.rs @@ -5,7 +5,7 @@ #![warn(pointer_structural_match)] -struct NoDerive(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/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs index 86db09cc08fc8..56b7988e0e4e5 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs +++ b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-embedded.rs @@ -5,7 +5,7 @@ #![warn(pointer_structural_match)] -struct NoDerive(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/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs index 99c574d078045..3ebe3225437a0 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs +++ b/src/test/ui/rfc-1445-restrict-constants-in-patterns/allow-hide-behind-indirect-unsafe-ptr-param.rs @@ -5,7 +5,7 @@ #![warn(pointer_structural_match)] -struct NoDerive(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/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs index 4a8a09493798e..bb5e243d93433 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.rs +++ b/src/test/ui/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(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/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs index fe62774d220d4..e3abb47cf7338 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.rs +++ b/src/test/ui/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(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/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs index c3a30674ea387..2d3788eea8a89 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.rs +++ b/src/test/ui/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(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/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs index 4d0e80d5af312..65df7788d907e 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.rs +++ b/src/test/ui/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(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/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs b/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs index 432f196ec8127..88260fd10814d 100644 --- a/src/test/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.rs +++ b/src/test/ui/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(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/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs b/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs index 292017a1de24d..3e7385fd9a8ab 100644 --- a/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs +++ b/src/test/ui/rfc-2632-const-trait-impl/const-drop.rs @@ -64,7 +64,7 @@ implements_const_drop! { } fn main() { - struct HasDropGlue(Box); + struct HasDropGlue(#[allow(dead_code)] Box); struct HasDropImpl; impl Drop for HasDropImpl { fn drop(&mut self) { diff --git a/src/test/ui/rfcs/rfc-2151-raw-identifiers/attr.rs b/src/test/ui/rfcs/rfc-2151-raw-identifiers/attr.rs index 2fe1e05e509f8..0deb8c7f119e9 100644 --- a/src/test/ui/rfcs/rfc-2151-raw-identifiers/attr.rs +++ b/src/test/ui/rfcs/rfc-2151-raw-identifiers/attr.rs @@ -7,7 +7,7 @@ struct Test { } #[r#derive(r#Debug)] -struct Test2(u32); +struct Test2(#[allow(dead_code)] u32); pub fn main() { assert_eq!(mem::size_of::(), 9); diff --git a/src/test/ui/specialization/specialization-cross-crate.rs b/src/test/ui/specialization/specialization-cross-crate.rs index 4171505aa374c..4b2ac07378d87 100644 --- a/src/test/ui/specialization/specialization-cross-crate.rs +++ b/src/test/ui/specialization/specialization-cross-crate.rs @@ -14,7 +14,7 @@ struct NotClone; struct MarkedAndClone; impl MyMarker for MarkedAndClone {} -struct MyType(T); +struct MyType(#[allow(dead_code)] T); impl Foo for MyType { default fn foo(&self) -> &'static str { "generic MyType" diff --git a/src/test/ui/specialization/specialization-translate-projections-with-lifetimes.rs b/src/test/ui/specialization/specialization-translate-projections-with-lifetimes.rs index 5c2781a9c63a6..f06afc8ba4144 100644 --- a/src/test/ui/specialization/specialization-translate-projections-with-lifetimes.rs +++ b/src/test/ui/specialization/specialization-translate-projections-with-lifetimes.rs @@ -14,7 +14,7 @@ impl<'a> WithAssoc for &'a () { type Item = &'a u32; } -struct Cloned(I); +struct Cloned(#[allow(dead_code)] I); impl<'a, I, T: 'a> Iterator for Cloned where I: WithAssoc, T: Clone diff --git a/src/test/ui/stdlib-unit-tests/raw-fat-ptr.rs b/src/test/ui/stdlib-unit-tests/raw-fat-ptr.rs index 9f50659ed60d0..0f535523dcc06 100644 --- a/src/test/ui/stdlib-unit-tests/raw-fat-ptr.rs +++ b/src/test/ui/stdlib-unit-tests/raw-fat-ptr.rs @@ -39,6 +39,7 @@ impl Foo for T { } } +#[allow(dead_code)] struct S(u32, T); fn main() { diff --git a/src/test/ui/struct-ctor-mangling.rs b/src/test/ui/struct-ctor-mangling.rs index f242cb8457f99..159e21d28635b 100644 --- a/src/test/ui/struct-ctor-mangling.rs +++ b/src/test/ui/struct-ctor-mangling.rs @@ -4,7 +4,7 @@ fn size_of_val(_: &T) -> usize { std::mem::size_of::() } -struct Foo(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/src/test/ui/structs-enums/enum-null-pointer-opt.rs b/src/test/ui/structs-enums/enum-null-pointer-opt.rs index 32fdbf620a98d..356f8a6dd36f6 100644 --- a/src/test/ui/structs-enums/enum-null-pointer-opt.rs +++ b/src/test/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(T); -struct AssocTypeStruct(::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(Box); + struct Bar(#[allow(dead_code)] Box); // Should apply through structs assert_eq!(size_of::(), size_of::>()); diff --git a/src/test/ui/structs-enums/enum-nullable-simplifycfg-misopt.rs b/src/test/ui/structs-enums/enum-nullable-simplifycfg-misopt.rs index 53892a4e0aeb4..4bd7ee45dfee4 100644 --- a/src/test/ui/structs-enums/enum-nullable-simplifycfg-misopt.rs +++ b/src/test/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, 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/src/test/ui/structs-enums/resource-in-struct.rs b/src/test/ui/structs-enums/resource-in-struct.rs index 35a4b14bc3f87..267ad6b4a867a 100644 --- a/src/test/ui/structs-enums/resource-in-struct.rs +++ b/src/test/ui/structs-enums/resource-in-struct.rs @@ -25,7 +25,7 @@ fn close_res(i: closable) -> close_res { } } -enum option { none, some(T), } +enum option { none, some(#[allow(dead_code)] T), } fn sink(_res: option) { } diff --git a/src/test/ui/structs-enums/tuple-struct-construct.rs b/src/test/ui/structs-enums/tuple-struct-construct.rs index 972fc9dc04a90..dc7cbaffddb48 100644 --- a/src/test/ui/structs-enums/tuple-struct-construct.rs +++ b/src/test/ui/structs-enums/tuple-struct-construct.rs @@ -1,4 +1,5 @@ // run-pass +#[allow(dead_code)] #[derive(Debug)] struct Foo(isize, isize); diff --git a/src/test/ui/structs-enums/uninstantiable-struct.rs b/src/test/ui/structs-enums/uninstantiable-struct.rs index b1ef525614ea5..15f2fc424bb86 100644 --- a/src/test/ui/structs-enums/uninstantiable-struct.rs +++ b/src/test/ui/structs-enums/uninstantiable-struct.rs @@ -1,4 +1,4 @@ // run-pass -pub struct Z(&'static Z); +pub struct Z(#[allow(dead_code)] &'static Z); pub fn main() {} diff --git a/src/test/ui/trailing-comma.rs b/src/test/ui/trailing-comma.rs index 97006ae50a0bf..3109139850889 100644 --- a/src/test/ui/trailing-comma.rs +++ b/src/test/ui/trailing-comma.rs @@ -3,7 +3,7 @@ fn f(_: T,) {} -struct Foo(T); +struct Foo(#[allow(dead_code)] T); struct Bar; @@ -14,7 +14,7 @@ impl Bar { } enum Baz { - Qux(isize,), + Qux(#[allow(dead_code)] isize,), } #[allow(unused,)] diff --git a/src/test/ui/traits/augmented-assignments-trait.rs b/src/test/ui/traits/augmented-assignments-trait.rs index 8c418daffdf5e..75168c4f1e546 100644 --- a/src/test/ui/traits/augmented-assignments-trait.rs +++ b/src/test/ui/traits/augmented-assignments-trait.rs @@ -1,7 +1,7 @@ // run-pass use std::ops::AddAssign; -struct Int(i32); +struct Int(#[allow(dead_code)] i32); impl AddAssign for Int { fn add_assign(&mut self, _: Int) { diff --git a/src/test/ui/traits/negative-impls/negated-auto-traits-rpass.rs b/src/test/ui/traits/negative-impls/negated-auto-traits-rpass.rs index 010dbf2466403..ab184d74f9e00 100644 --- a/src/test/ui/traits/negative-impls/negated-auto-traits-rpass.rs +++ b/src/test/ui/traits/negative-impls/negated-auto-traits-rpass.rs @@ -7,7 +7,7 @@ use std::marker::Send; pub struct WaitToken; impl !Send for WaitToken {} -pub struct Test(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/src/test/ui/traits/object/exclusion.rs b/src/test/ui/traits/object/exclusion.rs index 0b8b0e2f5ef4d..3abd3bbfccf1f 100644 --- a/src/test/ui/traits/object/exclusion.rs +++ b/src/test/ui/traits/object/exclusion.rs @@ -8,7 +8,7 @@ trait Future: 'static { } } -struct Map(A); +struct Map(#[allow(dead_code)] A); impl Future for Map {} pub struct Promise; diff --git a/src/test/ui/traits/object/generics.rs b/src/test/ui/traits/object/generics.rs index e5a96af3810de..e2e70d43ab848 100644 --- a/src/test/ui/traits/object/generics.rs +++ b/src/test/ui/traits/object/generics.rs @@ -25,7 +25,7 @@ impl Impl { // test for #8601 -enum Type { Constant(T) } +enum Type { Constant(#[allow(dead_code)] T) } trait Trait { fn method(&self, _: Type<(K,V)>) -> isize; diff --git a/src/test/ui/traits/pointee-deduction.rs b/src/test/ui/traits/pointee-deduction.rs index f888246967d3d..82e3aa1ae892e 100644 --- a/src/test/ui/traits/pointee-deduction.rs +++ b/src/test/ui/traits/pointee-deduction.rs @@ -13,8 +13,8 @@ impl Foo for () { type Bar = (); } -struct Wrapper1(::Bar); -struct Wrapper2( 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/src/test/ui/traits/principal-less-objects.rs b/src/test/ui/traits/principal-less-objects.rs index 82c76eb693a0d..5fe01efa4f886 100644 --- a/src/test/ui/traits/principal-less-objects.rs +++ b/src/test/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, [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/src/test/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs index 19fcc78721ab1..d869794ec0ac6 100644 --- a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs +++ b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args-pass.rs @@ -9,7 +9,7 @@ #![allow(irrefutable_let_patterns)] -enum Enum { TSVariant(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/src/test/ui/unboxed-closures/type-id-higher-rank.rs b/src/test/ui/unboxed-closures/type-id-higher-rank.rs index 355d11099419c..a9db71a0399bb 100644 --- a/src/test/ui/unboxed-closures/type-id-higher-rank.rs +++ b/src/test/ui/unboxed-closures/type-id-higher-rank.rs @@ -4,7 +4,7 @@ use std::any::{Any, TypeId}; -struct Struct<'a>(&'a ()); +struct Struct<'a>(#[allow(dead_code)] &'a ()); trait Trait<'a> {} fn main() { diff --git a/src/test/ui/unsized-locals/unsized-exprs-rpass.rs b/src/test/ui/unsized-locals/unsized-exprs-rpass.rs index 8fcb6d93d391c..83d3680f72ff0 100644 --- a/src/test/ui/unsized-locals/unsized-exprs-rpass.rs +++ b/src/test/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(X); +struct A(#[allow(dead_code)] X); fn udrop(_x: T) {} fn foo() -> Box<[u8]> { diff --git a/src/test/ui/unsized/unchanged-param.rs b/src/test/ui/unsized/unchanged-param.rs index 93c7af68ac388..8aa2ed1534450 100644 --- a/src/test/ui/unsized/unchanged-param.rs +++ b/src/test/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(T, B); -struct B(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])); 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 2289f7875f04c..6ea573c894196 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 @@ -6,11 +6,11 @@ use std::sync::atomic::AtomicUsize; enum Private { - ToBeUnfrozen(T), - Frozen(usize), + ToBeUnfrozen(#[allow(dead_code)] T), + Frozen(#[allow(dead_code)] usize), } -pub struct Wrapper(Private); +pub struct Wrapper(#[allow(dead_code)] Private); pub const WRAPPED_PRIVATE_UNFROZEN_VARIANT: Wrapper = Wrapper(Private::ToBeUnfrozen(AtomicUsize::new(6))); pub const WRAPPED_PRIVATE_FROZEN_VARIANT: Wrapper = Wrapper(Private::Frozen(7)); diff --git a/src/tools/clippy/tests/ui/format.fixed b/src/tools/clippy/tests/ui/format.fixed index 64cb7b1cfb80f..fc91ebff49d11 100644 --- a/src/tools/clippy/tests/ui/format.fixed +++ b/src/tools/clippy/tests/ui/format.fixed @@ -3,7 +3,7 @@ #![allow(clippy::print_literal, clippy::redundant_clone, clippy::to_string_in_format_args)] #![warn(clippy::useless_format)] -struct Foo(pub String); +struct Foo(#[allow(dead_code)] pub String); macro_rules! foo { ($($t:tt)*) => (Foo(format!($($t)*))) diff --git a/src/tools/clippy/tests/ui/format.rs b/src/tools/clippy/tests/ui/format.rs index a065b1b5683c1..ba78b722c86e6 100644 --- a/src/tools/clippy/tests/ui/format.rs +++ b/src/tools/clippy/tests/ui/format.rs @@ -3,7 +3,7 @@ #![allow(clippy::print_literal, clippy::redundant_clone, clippy::to_string_in_format_args)] #![warn(clippy::useless_format)] -struct Foo(pub String); +struct Foo(#[allow(dead_code)] pub String); macro_rules! foo { ($($t:tt)*) => (Foo(format!($($t)*))) 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 12db43b534361..2980468828aaa 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 @@ -6,7 +6,7 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque}; use std::iter::FromIterator; -struct Foo(Vec); +struct Foo(#[allow(dead_code)] Vec); impl FromIterator for Foo { fn from_iter>(_: T) -> Self { 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 f5ec190e0cdc5..676bd0dc8835c 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 @@ -6,7 +6,7 @@ use std::collections::{BTreeMap, BTreeSet, HashMap, VecDeque}; use std::iter::FromIterator; -struct Foo(Vec); +struct Foo(#[allow(dead_code)] Vec); impl FromIterator for Foo { fn from_iter>(_: T) -> Self { diff --git a/src/tools/clippy/tests/ui/must_use_candidates.fixed b/src/tools/clippy/tests/ui/must_use_candidates.fixed index 9556f6f82cc63..451139fad9865 100644 --- a/src/tools/clippy/tests/ui/must_use_candidates.fixed +++ b/src/tools/clippy/tests/ui/must_use_candidates.fixed @@ -6,7 +6,7 @@ use std::rc::Rc; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -pub struct MyAtomic(AtomicBool); +pub struct MyAtomic(#[allow(dead_code)] AtomicBool); pub struct MyPure; #[must_use] pub fn pure(i: u8) -> u8 { diff --git a/src/tools/clippy/tests/ui/must_use_candidates.rs b/src/tools/clippy/tests/ui/must_use_candidates.rs index 3732422017104..a254034b7a93b 100644 --- a/src/tools/clippy/tests/ui/must_use_candidates.rs +++ b/src/tools/clippy/tests/ui/must_use_candidates.rs @@ -6,7 +6,7 @@ use std::rc::Rc; use std::sync::atomic::{AtomicBool, Ordering}; use std::sync::Arc; -pub struct MyAtomic(AtomicBool); +pub struct MyAtomic(#[allow(dead_code)] AtomicBool); pub struct MyPure; pub fn pure(i: u8) -> u8 { diff --git a/src/tools/clippy/tests/ui/numbered_fields.fixed b/src/tools/clippy/tests/ui/numbered_fields.fixed index 1da97e9687988..2edb2675cc646 100644 --- a/src/tools/clippy/tests/ui/numbered_fields.fixed +++ b/src/tools/clippy/tests/ui/numbered_fields.fixed @@ -2,6 +2,7 @@ #![warn(clippy::init_numbered_fields)] #[derive(Default)] +#[allow(dead_code)] struct TupleStruct(u32, u32, u8); // This shouldn't lint because it's in a macro diff --git a/src/tools/clippy/tests/ui/numbered_fields.rs b/src/tools/clippy/tests/ui/numbered_fields.rs index 08ec405a5606e..7a154a9d9081c 100644 --- a/src/tools/clippy/tests/ui/numbered_fields.rs +++ b/src/tools/clippy/tests/ui/numbered_fields.rs @@ -2,6 +2,7 @@ #![warn(clippy::init_numbered_fields)] #[derive(Default)] +#[allow(dead_code)] struct TupleStruct(u32, u32, u8); // This shouldn't lint because it's in a macro diff --git a/src/tools/clippy/tests/ui/numbered_fields.stderr b/src/tools/clippy/tests/ui/numbered_fields.stderr index 01691c8b141e8..60c0d7898063f 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:19:13 | LL | let _ = TupleStruct { | _____________^ @@ -12,7 +12,7 @@ LL | | }; = note: `-D clippy::init-numbered-fields` implied by `-D warnings` error: used a field initializer for a tuple struct - --> $DIR/numbered_fields.rs:25:13 + --> $DIR/numbered_fields.rs:26: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 7790c816481d1..567bc957568b6 100644 --- a/src/tools/clippy/tests/ui/option_if_let_else.fixed +++ b/src/tools/clippy/tests/ui/option_if_let_else.fixed @@ -87,7 +87,7 @@ fn pattern_to_vec(pattern: &str) -> Vec { } enum DummyEnum { - One(u8), + One(#[allow(dead_code)] u8), Two, } 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 3d9f76ee4a6b5..3730c683be473 100644 --- a/src/tools/clippy/tests/ui/option_if_let_else.rs +++ b/src/tools/clippy/tests/ui/option_if_let_else.rs @@ -110,7 +110,7 @@ fn pattern_to_vec(pattern: &str) -> Vec { } enum DummyEnum { - One(u8), + One(#[allow(dead_code)] u8), Two, } diff --git a/src/tools/clippy/tests/ui/unreadable_literal.fixed b/src/tools/clippy/tests/ui/unreadable_literal.fixed index e726b652ef1ed..02a72b011152d 100644 --- a/src/tools/clippy/tests/ui/unreadable_literal.fixed +++ b/src/tools/clippy/tests/ui/unreadable_literal.fixed @@ -2,7 +2,7 @@ #![warn(clippy::unreadable_literal)] -struct Foo(u64); +struct Foo(#[allow(dead_code)] u64); macro_rules! foo { () => { @@ -10,7 +10,7 @@ macro_rules! foo { }; } -struct Bar(f32); +struct Bar(#[allow(dead_code)] f32); macro_rules! bar { () => { diff --git a/src/tools/clippy/tests/ui/unreadable_literal.rs b/src/tools/clippy/tests/ui/unreadable_literal.rs index 5bbb2fc9dc137..dc3710d411f36 100644 --- a/src/tools/clippy/tests/ui/unreadable_literal.rs +++ b/src/tools/clippy/tests/ui/unreadable_literal.rs @@ -2,7 +2,7 @@ #![warn(clippy::unreadable_literal)] -struct Foo(u64); +struct Foo(#[allow(dead_code)] u64); macro_rules! foo { () => { @@ -10,7 +10,7 @@ macro_rules! foo { }; } -struct Bar(f32); +struct Bar(#[allow(dead_code)] f32); macro_rules! bar { () => { diff --git a/src/tools/rustfmt/src/expr.rs b/src/tools/rustfmt/src/expr.rs index c9c8852cd3b56..0e8e386737d4a 100644 --- a/src/tools/rustfmt/src/expr.rs +++ b/src/tools/rustfmt/src/expr.rs @@ -841,7 +841,7 @@ impl<'a> ControlFlow<'a> { &format!("{}{}{}", matcher, pat_string, self.connector), expr, cond_shape, - &RhsAssignKind::Expr(&expr.kind, expr.span), + &RhsAssignKind::Expr(&expr.kind), RhsTactics::Default, comments_span, true, @@ -1854,7 +1854,7 @@ fn rewrite_unary_op( } pub(crate) enum RhsAssignKind<'ast> { - Expr(&'ast ast::ExprKind, Span), + Expr(&'ast ast::ExprKind), Bounds, Ty, } @@ -1867,7 +1867,7 @@ impl<'ast> RhsAssignKind<'ast> { #[allow(dead_code)] fn is_chain(&self) -> bool { match self { - RhsAssignKind::Expr(kind, _) => { + RhsAssignKind::Expr(kind) => { matches!( kind, ast::ExprKind::Try(..) @@ -1901,7 +1901,7 @@ fn rewrite_assignment( context, lhs_str, rhs, - &RhsAssignKind::Expr(&rhs.kind, rhs.span), + &RhsAssignKind::Expr(&rhs.kind), shape, ) } diff --git a/src/tools/rustfmt/src/items.rs b/src/tools/rustfmt/src/items.rs index babc56f86edc6..82d51b34ca41d 100644 --- a/src/tools/rustfmt/src/items.rs +++ b/src/tools/rustfmt/src/items.rs @@ -120,7 +120,7 @@ impl Rewrite for ast::Local { context, result, init, - &RhsAssignKind::Expr(&init.kind, init.span), + &RhsAssignKind::Expr(&init.kind), nested_shape, )?; // todo else @@ -576,7 +576,7 @@ impl<'a> FmtVisitor<'a> { lhs, ex, shape, - &RhsAssignKind::Expr(&ex.kind, ex.span), + &RhsAssignKind::Expr(&ex.kind), RhsTactics::AllowOverflow, )? } else { @@ -1866,7 +1866,7 @@ fn rewrite_static( &lhs, &**expr, Shape::legacy(remaining_width, offset.block_only()), - &RhsAssignKind::Expr(&expr.kind, expr.span), + &RhsAssignKind::Expr(&expr.kind), RhsTactics::Default, comments_span, true, diff --git a/src/tools/rustfmt/src/macros.rs b/src/tools/rustfmt/src/macros.rs index f29552caf8d87..e2e9fef617df3 100644 --- a/src/tools/rustfmt/src/macros.rs +++ b/src/tools/rustfmt/src/macros.rs @@ -1320,7 +1320,7 @@ fn format_lazy_static( context, stmt, &*expr, - &RhsAssignKind::Expr(&expr.kind, expr.span), + &RhsAssignKind::Expr(&expr.kind), nested_shape.sub_width(1)?, )?); result.push(';');