diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/tools/clippy/tests/ui/entry_with_else.stderr | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/tools/clippy/tests/ui/entry_with_else.stderr')
-rw-r--r-- | src/tools/clippy/tests/ui/entry_with_else.stderr | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/entry_with_else.stderr b/src/tools/clippy/tests/ui/entry_with_else.stderr new file mode 100644 index 000000000..e0f6671b4 --- /dev/null +++ b/src/tools/clippy/tests/ui/entry_with_else.stderr @@ -0,0 +1,151 @@ +error: usage of `contains_key` followed by `insert` on a `HashMap` + --> $DIR/entry_with_else.rs:16:5 + | +LL | / if !m.contains_key(&k) { +LL | | m.insert(k, v); +LL | | } else { +LL | | m.insert(k, v2); +LL | | } + | |_____^ + | + = note: `-D clippy::map-entry` implied by `-D warnings` +help: try this + | +LL ~ match m.entry(k) { +LL + std::collections::hash_map::Entry::Vacant(e) => { +LL + e.insert(v); +LL + } +LL + std::collections::hash_map::Entry::Occupied(mut e) => { +LL + e.insert(v2); +LL + } +LL + } + | + +error: usage of `contains_key` followed by `insert` on a `HashMap` + --> $DIR/entry_with_else.rs:22:5 + | +LL | / if m.contains_key(&k) { +LL | | m.insert(k, v); +LL | | } else { +LL | | m.insert(k, v2); +LL | | } + | |_____^ + | +help: try this + | +LL ~ match m.entry(k) { +LL + std::collections::hash_map::Entry::Occupied(mut e) => { +LL + e.insert(v); +LL + } +LL + std::collections::hash_map::Entry::Vacant(e) => { +LL + e.insert(v2); +LL + } +LL + } + | + +error: usage of `contains_key` followed by `insert` on a `HashMap` + --> $DIR/entry_with_else.rs:28:5 + | +LL | / if !m.contains_key(&k) { +LL | | m.insert(k, v); +LL | | } else { +LL | | foo(); +LL | | } + | |_____^ + | +help: try this + | +LL ~ if let std::collections::hash_map::Entry::Vacant(e) = m.entry(k) { +LL + e.insert(v); +LL + } else { +LL + foo(); +LL + } + | + +error: usage of `contains_key` followed by `insert` on a `HashMap` + --> $DIR/entry_with_else.rs:34:5 + | +LL | / if !m.contains_key(&k) { +LL | | foo(); +LL | | } else { +LL | | m.insert(k, v); +LL | | } + | |_____^ + | +help: try this + | +LL ~ if let std::collections::hash_map::Entry::Occupied(mut e) = m.entry(k) { +LL + e.insert(v); +LL + } else { +LL + foo(); +LL + } + | + +error: usage of `contains_key` followed by `insert` on a `HashMap` + --> $DIR/entry_with_else.rs:40:5 + | +LL | / if !m.contains_key(&k) { +LL | | m.insert(k, v); +LL | | } else { +LL | | m.insert(k, v2); +LL | | } + | |_____^ + | +help: try this + | +LL ~ match m.entry(k) { +LL + std::collections::hash_map::Entry::Vacant(e) => { +LL + e.insert(v); +LL + } +LL + std::collections::hash_map::Entry::Occupied(mut e) => { +LL + e.insert(v2); +LL + } +LL + } + | + +error: usage of `contains_key` followed by `insert` on a `HashMap` + --> $DIR/entry_with_else.rs:46:5 + | +LL | / if m.contains_key(&k) { +LL | | if true { m.insert(k, v) } else { m.insert(k, v2) } +LL | | } else { +LL | | m.insert(k, v) +LL | | }; + | |_____^ + | +help: try this + | +LL ~ match m.entry(k) { +LL + std::collections::hash_map::Entry::Occupied(mut e) => { +LL + if true { Some(e.insert(v)) } else { Some(e.insert(v2)) } +LL + } +LL + std::collections::hash_map::Entry::Vacant(e) => { +LL + e.insert(v); +LL + None +LL + } +LL ~ }; + | + +error: usage of `contains_key` followed by `insert` on a `HashMap` + --> $DIR/entry_with_else.rs:52:5 + | +LL | / if m.contains_key(&k) { +LL | | foo(); +LL | | m.insert(k, v) +LL | | } else { +LL | | None +LL | | }; + | |_____^ + | +help: try this + | +LL ~ if let std::collections::hash_map::Entry::Occupied(mut e) = m.entry(k) { +LL + foo(); +LL + Some(e.insert(v)) +LL + } else { +LL + None +LL ~ }; + | + +error: aborting due to 7 previous errors + |