about summary refs log tree commit diff
diff options
context:
space:
mode:
authorjumbatm <fungjys@gmail.com>2020-08-16 17:14:09 +1000
committerjumbatm <30644300+jumbatm@users.noreply.github.com>2020-08-18 02:01:04 +1000
commit7708abbbef679d208041bff57aa9ad50e9419895 (patch)
treeefa5553b7f12930772e0862a27a08aedbfbb1b70
parent6c57de1166d36725a689cef17e0dab8b9abcd00b (diff)
downloadrust-7708abbbef679d208041bff57aa9ad50e9419895.tar.gz
rust-7708abbbef679d208041bff57aa9ad50e9419895.zip
Avoid double hashset lookup.
Co-authored-by: Bastian Kauschke <bastian_kauschke@hotmail.de>
-rw-r--r--src/librustc_lint/builtin.rs3
1 files changed, 1 insertions, 2 deletions
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs
index 781ebb67167..8625dc096d5 100644
--- a/src/librustc_lint/builtin.rs
+++ b/src/librustc_lint/builtin.rs
@@ -2161,12 +2161,11 @@ impl ClashingExternDeclarations {
             ckind: CItemKind,
         ) -> bool {
             debug!("structurally_same_type_impl(cx, a = {:?}, b = {:?})", a, b);
-            if seen_types.contains(&(a, b)) {
+            if !seen_types.insert((a, b)) {
                 // We've encountered a cycle. There's no point going any further -- the types are
                 // structurally the same.
                 return true;
             }
-            seen_types.insert((a, b));
             let tcx = cx.tcx;
             if a == b || rustc_middle::ty::TyS::same_type(a, b) {
                 // All nominally-same types are structurally same, too.