Closed
Description
Code
pub struct Foo;
#[cfg(test)]
mod tests_common {
/// A marker trait that can be used to assert a type is `Send`.
pub trait AssertSend: Send {}
}
#[cfg(test)]
mod tests {
use super::*;
use crate::tests_common::AssertSend;
impl AssertSend for Foo {}
}
Current output
warning: trait `AssertSend` is never used
--> src/lib.rs:5:15
|
5 | pub trait AssertSend: Send {}
| ^^^^^^^^^^
|
= note: `#[warn(dead_code)]` on by default
warning: `test_trait_reproducer` (lib test) generated 1 warning
Desired output
no warning (like in stable)
Rationale and extra context
For the given code, the rust compiler emits a dead_code
warning in nightly, but not in stable.
Usually the trait was supposed to be used for multiple modules to ensure Send
on certain types. For the sake of simplicity, I put it in the same file. But the issue is also visible across different files.
Other cases
No response
Rust Version
stable version:
rustc 1.76.0 (07dca489a 2024-02-04)
binary: rustc
commit-hash: 07dca489ac2d933c78d3c5158e3f43beefeb02ce
commit-date: 2024-02-04
host: x86_64-unknown-linux-gnu
release: 1.76.0
LLVM version: 17.0.6
nightly version:
rustc 1.78.0-nightly (b381d3ab2 2024-02-12)
binary: rustc
commit-hash: b381d3ab27f788f990551100c4425bb782d26d76
commit-date: 2024-02-12
host: x86_64-unknown-linux-gnu
release: 1.78.0-nightly
LLVM version: 17.0.6
Anything else?
No response