Skip to content

[missing_const_for_fn] does not take into account whether receiver is ~const Destruct #10617

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
KisaragiEffective opened this issue Apr 9, 2023 · 1 comment · Fixed by #10891
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied

Comments

@KisaragiEffective
Copy link
Contributor

Summary

missing_const_for_fn does not taike into account whether receiver is ~const Destruct.

Lint Name

missing_const_for_fn

Reproducer

I tried this code:

#![warn(clippy::missing_const_for_fn)]

pub struct Identifier(String);

impl Identifier {
    #[must_use = "If you don't use it, it will drop entire String"]
    pub fn name(self) -> String {
        self.0
    }
}

I saw this happen:

warning: this could be a `const fn`
 --> src/lib.rs:7:5
  |
7 | /     pub fn name(self) -> String {
8 | |         self.0
9 | |     }
  | |_____^
  |
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#missing_const_for_fn

I expected to the lint does not fire.

Version

rustc 1.70.0-nightly (1459b3128 2023-03-23)
binary: rustc
commit-hash: 1459b3128e288a85fcc4dd1fee7ada2cdcf28794
commit-date: 2023-03-23
host: x86_64-unknown-linux-gnu
release: 1.70.0-nightly
LLVM version: 15.0.7

Additional Labels

No response

@KisaragiEffective KisaragiEffective added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Apr 9, 2023
@KisaragiEffective KisaragiEffective changed the title [missing_const_for_fn] does not taike into account whether receiver is ~const Destruct [missing_const_for_fn] does not take into account whether receiver is ~const Destruct Apr 10, 2023
@KisaragiEffective
Copy link
Contributor Author

KisaragiEffective commented Apr 12, 2023

@rustbot label +I-suggestion-causes-error

@rustbot rustbot added the I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied label Apr 12, 2023
@bors bors closed this as completed in eefc2a0 Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have I-suggestion-causes-error Issue: The suggestions provided by this Lint cause an ICE/error when applied
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants