]>
git.proxmox.com Git - rustc.git/blob - src/tools/clippy/tests/ui/entry.rs
d972a201ad76460e401c6a0ff613eab5e4f53af9
3 #![allow(unused, clippy::needless_pass_by_value, clippy::collapsible_if)]
4 #![warn(clippy::map_entry)]
7 use std
::collections
::HashMap
;
11 ($e
:expr
) => {{ $e }
};
15 ($map
:expr
, $key
:expr
, $val
:expr
) => {
16 $map
.insert($key
, $val
)
22 fn hash_map
<K
: Eq
+ Hash
+ Copy
, V
: Copy
>(m
: &mut HashMap
<K
, V
>, m2
: &mut HashMap
<K
, V
>, k
: K
, k2
: K
, v
: V
, v2
: V
) {
24 if !m
.contains_key(&k
) {
28 // semicolon on insert, use or_insert_with(..)
29 if !m
.contains_key(&k
) {
37 // semicolon on if, use or_insert_with(..)
38 if !m
.contains_key(&k
) {
46 // early return, use if let
47 if !m
.contains_key(&k
) {
56 // use or_insert_with(..)
57 if !m
.contains_key(&k
) {
62 // semicolon on insert and match, use or_insert_with(..)
63 if !m
.contains_key(&k
) {
74 // one branch doesn't insert, use if let
75 if !m
.contains_key(&k
) {
85 if !m
.contains_key(&k
) {
111 // ok, insert in loop
112 if !m
.contains_key(&k
) {
118 // macro_expansion test, use or_insert(..)
119 if !m
.contains_key(&m
!(k
)) {
120 m
.insert(m
!(k
), m
!(v
));
123 // ok, map used before insertion
124 if !m
.contains_key(&k
) {
130 if !m
.contains_key(&k
) {
131 unsafe { asm!("nop") }
135 // ok, different keys.
136 if !m
.contains_key(&k
) {
140 // ok, different maps
141 if !m
.contains_key(&k
) {
145 // ok, insert in macro
146 if !m
.contains_key(&k
) {
150 // or_insert_with. Partial move of a local declared in the closure is ok.
151 if !m
.contains_key(&k
) {
152 let x
= (String
::new(), String
::new());