- 
                Notifications
    You must be signed in to change notification settings 
- Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
box_default fires in the Default impl of Box-like types in a #![no_std] crate
Lint Name
box_default
Reproducer
I tried this code: (Playground link)
#![no_std]
pub struct NotBox<T> {
    _value: T,
}
impl<T> NotBox<T> {
    pub fn new(value: T) -> Self {
        Self { 
            _value: value,
        }
    }
}
impl<T: Default> Default for NotBox<T> {
    fn default() -> Self {
        Self::new(T::default())
    }
}I saw this happen:
    Checking playground v0.0.1 (/playground)
warning: `Box::new(_)` of default value
  --> src/lib.rs:17:9
   |
17 |         Self::new(T::default())
   |         ^^^^^^^^^^^^^^^^^^^^^^^
   |
   = help: use `Box::default()` instead
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#box_default
   = note: `#[warn(clippy::box_default)]` on by default
warning: `playground` (lib) generated 1 warning
    Finished dev [unoptimized + debuginfo] target(s) in 0.97s
I expected to see this happen:
no output
Version
rustc 1.66.0-nightly (bf15a9e52 2022-10-14)
binary: rustc
commit-hash: bf15a9e5263fcea065a7ae9c179b2d24c2deb670
commit-date: 2022-10-14
host: x86_64-unknown-linux-gnu
release: 1.66.0-nightly
LLVM version: 15.0.2
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have