-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
Triggers on pub fn new() -> Self
but not pub const fn new() -> Self
Lint Name
new_without_default
Reproducer
I tried this code:
pub struct Foo;
impl Foo {
pub const fn new() -> {
Self
}
}
I expected to see this happen: lint triggers
Instead, this happened: lint doesn't trigger
Version
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=256edf22e6afcae3a1f23322a19851de
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
Centri3 commentedon Jun 3, 2023
Default::default
is not const so afaict this is correct behavior, same withunsafe fn new
robertbastian commentedon Jun 4, 2023
Default::default
can callconst fn new
though. It can't callunsafe fn new
without being unsafe itself, so that's different.Centri3 commentedon Jun 4, 2023
Yeah that's fair actually, this is still intentionally done by the lint's author but this should probably be changed at some point. @rustbot claim
new_without_default
]: Now emits on const fns #10903Auto merge of #10903 - Centri3:new_without_default, r=llogiq
Auto merge of #10903 - Centri3:new_without_default, r=llogiq