diff options
| author | Alex Macleod <alex@macleod.io> | 2025-04-09 12:14:18 +0000 |
|---|---|---|
| committer | Pietro Albini <pietro@pietroalbini.org> | 2025-05-09 17:41:11 +0200 |
| commit | 79df6ac1a738d6cd9d8ef6ccaa04fef558c71196 (patch) | |
| tree | f5257894efe0c4b87abe3e1ddc753571275e8bf6 /src/tools/clippy/tests/ui/entry.rs | |
| parent | 7d83c8c543d7c6a394c0c5f5235e63d3da01e0c8 (diff) | |
| download | rust-79df6ac1a738d6cd9d8ef6ccaa04fef558c71196.tar.gz rust-79df6ac1a738d6cd9d8ef6ccaa04fef558c71196.zip | |
fix: map_entry: don't emit lint before checks have been performed (#14568)
Fixes rust-lang/rust-clippy#14449, introduced in #14314 changelog: [`map_entry`]: fix a false positive where the lint would trigger without any insert calls present
Diffstat (limited to 'src/tools/clippy/tests/ui/entry.rs')
| -rw-r--r-- | src/tools/clippy/tests/ui/entry.rs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/entry.rs b/src/tools/clippy/tests/ui/entry.rs index 3578324f01c..166eea417ac 100644 --- a/src/tools/clippy/tests/ui/entry.rs +++ b/src/tools/clippy/tests/ui/entry.rs @@ -232,4 +232,26 @@ fn issue11976() { } } +mod issue14449 { + use std::collections::BTreeMap; + + pub struct Meow { + map: BTreeMap<String, String>, + } + + impl Meow { + fn pet(&self, _key: &str, _v: u32) -> u32 { + 42 + } + } + + pub fn f(meow: &Meow, x: String) { + if meow.map.contains_key(&x) { + let _ = meow.pet(&x, 1); + } else { + let _ = meow.pet(&x, 0); + } + } +} + fn main() {} |
