Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5113ed2

Browse files
committedJan 5, 2024
Auto merge of rust-lang#118297 - shepmaster:warn-dead-tuple-fields, r=WaffleLapkin
Merge `unused_tuple_struct_fields` into `dead_code` This implicitly upgrades the lint from `allow` to `warn` and places it into the `unused` lint group. [Discussion on Zulip](https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/Moving.20.60unused_tuple_struct_fields.60.20from.20allow.20to.20warn)
2 parents a59a980 + 26194a3 commit 5113ed2

File tree

227 files changed

+406
-412
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

227 files changed

+406
-412
lines changed
 

‎compiler/rustc_lint/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ fn register_builtins(store: &mut LintStore) {
328328
store.register_renamed("disjoint_capture_migration", "rust_2021_incompatible_closure_captures");
329329
store.register_renamed("or_patterns_back_compat", "rust_2021_incompatible_or_patterns");
330330
store.register_renamed("non_fmt_panic", "non_fmt_panics");
331+
store.register_renamed("unused_tuple_struct_fields", "dead_code");
331332

332333
// These were moved to tool lints, but rustc still sees them when compiling normally, before
333334
// tool lints are registered, so `check_tool_name_for_backwards_compat` doesn't work. Use

‎compiler/rustc_lint_defs/src/builtin.rs

Lines changed: 7 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ declare_lint_pass! {
125125
UNUSED_MACROS,
126126
UNUSED_MUT,
127127
UNUSED_QUALIFICATIONS,
128-
UNUSED_TUPLE_STRUCT_FIELDS,
129128
UNUSED_UNSAFE,
130129
UNUSED_VARIABLES,
131130
USELESS_DEPRECATED,
@@ -697,8 +696,13 @@ declare_lint! {
697696
/// Dead code may signal a mistake or unfinished code. To silence the
698697
/// warning for individual items, prefix the name with an underscore such
699698
/// as `_foo`. If it was intended to expose the item outside of the crate,
700-
/// consider adding a visibility modifier like `pub`. Otherwise consider
701-
/// removing the unused code.
699+
/// consider adding a visibility modifier like `pub`.
700+
///
701+
/// To preserve the numbering of tuple structs with unused fields,
702+
/// change the unused fields to have unit type or use
703+
/// `PhantomData`.
704+
///
705+
/// Otherwise consider removing the unused code.
702706
pub DEAD_CODE,
703707
Warn,
704708
"detect unused, unexported items"
@@ -732,32 +736,6 @@ declare_lint! {
732736
"detects attributes that were not used by the compiler"
733737
}
734738

735-
declare_lint! {
736-
/// The `unused_tuple_struct_fields` lint detects fields of tuple structs
737-
/// that are never read.
738-
///
739-
/// ### Example
740-
///
741-
/// ```rust
742-
/// #[warn(unused_tuple_struct_fields)]
743-
/// struct S(i32, i32, i32);
744-
/// let s = S(1, 2, 3);
745-
/// let _ = (s.0, s.2);
746-
/// ```
747-
///
748-
/// {{produces}}
749-
///
750-
/// ### Explanation
751-
///
752-
/// Tuple struct fields that are never read anywhere may indicate a
753-
/// mistake or unfinished code. To silence this warning, consider
754-
/// removing the unused field(s) or, to preserve the numbering of the
755-
/// remaining fields, change the unused field(s) to have unit type.
756-
pub UNUSED_TUPLE_STRUCT_FIELDS,
757-
Allow,
758-
"detects tuple struct fields that are never read"
759-
}
760-
761739
declare_lint! {
762740
/// The `unreachable_code` lint detects unreachable code paths.
763741
///

0 commit comments

Comments
 (0)
This repository has been archived.