Skip to content

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

Closed

Description

@KisaragiEffective

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

Activity

  1. added
    C-bugCategory: Clippy is not doing the correct thing
    I-false-positiveIssue: The lint was triggered on code it shouldn't have
    on Apr 9, 2023
  2. 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`[/+] on Apr 10, 2023
  3. KisaragiEffective commented on Apr 12, 2023

    @KisaragiEffective
    ContributorAuthor

    @rustbot label +I-suggestion-causes-error

  4. added
    I-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied
    on Apr 12, 2023
  5. added a commit that references this issue on Jun 13, 2023
    eefc2a0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions