- Notifications
You must be signed in to change notification settings - Fork 13.8k
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.L-dead_codeLint: dead_codeLint: dead_codeP-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
#![deny(warnings)] #[repr(u8)] #[derive(Copy, Clone, Debug)] pub enum RecordField { Target = 1, Level, Module, File, Line, NumArgs, } unsafe trait Pod {} #[repr(transparent)] struct RecordFieldWrapper(RecordField); unsafe impl Pod for RecordFieldWrapper {} fn try_read<T: Pod>(buf: &[u8]) -> T { unsafe { std::ptr::read_unaligned(buf.as_ptr() as *const T) } } pub fn foo(buf: &[u8]) -> RecordField { let RecordFieldWrapper(tag) = try_read(buf); tag }
This code compiles on stable (and nightlies before 2024-02-07) but now produces:
error: struct `RecordFieldWrapper` is never constructed --> aya-log/src/lib.rs:79:8 | 79 | struct RecordFieldWrapper(RecordField); | ^^^^^^^^^^^^^^^^^^ | = note: `RecordFieldWrapper` has a derived impl for the trait `Clone`, but this is intentionally ignored during dead code analysis = note: `-D dead-code` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(dead_code)]`
NOTE: playground's nightly is not new enough
playground
hvenev-insait
Metadata
Metadata
Assignees
Labels
A-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.Area: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.Category: This is a bug.C-discussionCategory: Discussion or questions that doesn't represent real issues.Category: Discussion or questions that doesn't represent real issues.L-dead_codeLint: dead_codeLint: dead_codeP-lowLow priorityLow priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.