Skip to content

missing_const_for_fn not triggered for functions using as_bytes() with slice pattern matching #17119

@mi2ebi

Description

@mi2ebi

Summary

basically the title

Lint Name

missing_const_for_fn

Reproducer

I tried this code: (minimal reproducer)

#[warn(clippy::missing_const_for_fn)]
pub fn is_one_byte(s: &str) -> bool {
    let [_] = s.as_bytes() else { return false };
    true
}

I expected to see this happen: clippy would emit the warning

Instead, this happened: clippy did not warn about it

Version

rustc 1.96.0 (ac68faa20 2026-05-25)
binary: rustc
commit-hash: ac68faa20c58cbccd01ee7208bf3b6e93a7d7f96
commit-date: 2026-05-25
host: x86_64-unknown-linux-gnu
release: 1.96.0
LLVM version: 22.1.2

Metadata

Metadata

Assignees

Labels

C-bugCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn't

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions