]> git.lizzy.rs Git - rust.git/commitdiff
Avoid double hashset lookup.
authorjumbatm <fungjys@gmail.com>
Sun, 16 Aug 2020 07:14:09 +0000 (17:14 +1000)
committerjumbatm <30644300+jumbatm@users.noreply.github.com>
Mon, 17 Aug 2020 16:01:04 +0000 (02:01 +1000)
Co-authored-by: Bastian Kauschke <bastian_kauschke@hotmail.de>
src/librustc_lint/builtin.rs

index 781ebb6716758bf05c8a75c7bb1d557a22438cc8..8625dc096d500674e36ecf768bd62b38da069122 100644 (file)
@@ -2161,12 +2161,11 @@ fn structurally_same_type_impl<'tcx>(
             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.