Skip to content

Use correct lint #119269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions compiler/rustc_passes/src/dead.rs
Original file line number Diff line number Diff line change
Expand Up @@ -805,11 +805,17 @@ impl<'tcx> DeadVisitor<'tcx> {
};
let tcx = self.tcx;

let lint = if is_positional {
lint::builtin::UNUSED_TUPLE_STRUCT_FIELDS
} else {
lint::builtin::DEAD_CODE
};

let first_hir_id = tcx.local_def_id_to_hir_id(first_id);
let first_lint_level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, first_hir_id).0;
let first_lint_level = tcx.lint_level_at_node(lint, first_hir_id).0;
assert!(dead_codes.iter().skip(1).all(|id| {
let hir_id = tcx.local_def_id_to_hir_id(*id);
let level = tcx.lint_level_at_node(lint::builtin::DEAD_CODE, hir_id).0;
let level = tcx.lint_level_at_node(lint, hir_id).0;
level == first_lint_level
}));

Expand All @@ -835,12 +841,6 @@ impl<'tcx> DeadVisitor<'tcx> {
let multiple = num > 6;
let name_list = names.into();

let lint = if is_positional {
lint::builtin::UNUSED_TUPLE_STRUCT_FIELDS
} else {
lint::builtin::DEAD_CODE
};

let parent_info = if let Some(parent_item) = parent_item {
let parent_descr = tcx.def_descr(parent_item.to_def_id());
let span = if let DefKind::Impl { .. } = tcx.def_kind(parent_item) {
Expand Down
9 changes: 9 additions & 0 deletions tests/ui/lint/dead-code/issue-119267.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// run-pass

#[derive(Debug)]
struct Foo(i32);

#[derive(Debug)]
struct ConstainsDropField(Foo, #[allow(unused)] Foo);

fn main() {}