about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAriel Ben-Yehuda <ariel.byd@gmail.com>2018-12-04 00:37:06 +0200
committerAriel Ben-Yehuda <ariel.byd@gmail.com>2018-12-14 19:14:22 +0200
commit6e4b2b3ae79770c7ccfcdbfc90dc34fe47ec5f09 (patch)
treea74ba4d5eae62500eb3d754109c51e9f05de5c4a /src
parent760639635facb6c9a0926ac9278bcba71880b0b3 (diff)
downloadrust-6e4b2b3ae79770c7ccfcdbfc90dc34fe47ec5f09.tar.gz
rust-6e4b2b3ae79770c7ccfcdbfc90dc34fe47ec5f09.zip
fix stupid bug
Diffstat (limited to 'src')
-rw-r--r--src/librustc_typeck/coherence/inherent_impls_overlap.rs86
1 files changed, 48 insertions, 38 deletions
diff --git a/src/librustc_typeck/coherence/inherent_impls_overlap.rs b/src/librustc_typeck/coherence/inherent_impls_overlap.rs
index 8051056e4ba..c273c8f6456 100644
--- a/src/librustc_typeck/coherence/inherent_impls_overlap.rs
+++ b/src/librustc_typeck/coherence/inherent_impls_overlap.rs
@@ -94,7 +94,9 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
 
         for (i, &impl1_def_id) in impls.iter().enumerate() {
             for &impl2_def_id in &impls[(i + 1)..] {
-                let mut used_to_be_allowed = traits::overlapping_impls(
+                // First, check if the impl was forbidden under the
+                // old rules. In that case, just have an error.
+                let used_to_be_allowed = traits::overlapping_impls(
                     self.tcx,
                     impl1_def_id,
                     impl2_def_id,
@@ -105,52 +107,60 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
                             impl1_def_id,
                             impl2_def_id,
                             overlap,
-                            Some(FutureCompatOverlapErrorKind::Issue43355),
+                            None,
                         );
                         false
                     },
                     || true,
                 );
 
-                if used_to_be_allowed {
-                    used_to_be_allowed = traits::overlapping_impls(
-                        self.tcx,
-                        impl1_def_id,
-                        impl2_def_id,
-                        IntercrateMode::Fixed,
-                        TraitObjectMode::NoSquash,
-                        |overlap| {
-                            self.check_for_common_items_in_impls(
-                                impl1_def_id,
-                                impl2_def_id,
-                                overlap,
-                                None,
-                            );
-                            false
-                        },
-                        || true,
-                    );
+                if !used_to_be_allowed {
+                    continue;
                 }
 
-                if used_to_be_allowed {
-                    traits::overlapping_impls(
-                        self.tcx,
-                        impl1_def_id,
-                        impl2_def_id,
-                        IntercrateMode::Fixed,
-                        TraitObjectMode::SquashAutoTraitsIssue33140,
-                        |overlap| {
-                            self.check_for_common_items_in_impls(
-                                impl1_def_id,
-                                impl2_def_id,
-                                overlap,
-                                Some(FutureCompatOverlapErrorKind::Issue33140),
-                            );
-                            false
-                        },
-                        || true,
-                    );
+                // Then, check if the impl was forbidden under only
+                // #43355. In that case, emit an #43355 error.
+                let used_to_be_allowed = traits::overlapping_impls(
+                    self.tcx,
+                    impl1_def_id,
+                    impl2_def_id,
+                    IntercrateMode::Fixed,
+                    TraitObjectMode::NoSquash,
+                    |overlap| {
+                        self.check_for_common_items_in_impls(
+                            impl1_def_id,
+                            impl2_def_id,
+                            overlap,
+                            Some(FutureCompatOverlapErrorKind::Issue43355),
+                        );
+                        false
+                    },
+                    || true,
+                );
+
+                if !used_to_be_allowed {
+                    continue;
                 }
+
+                // Then, check if the impl was forbidden under
+                // #33140. In that case, emit a #33140 error.
+                traits::overlapping_impls(
+                    self.tcx,
+                    impl1_def_id,
+                    impl2_def_id,
+                    IntercrateMode::Fixed,
+                    TraitObjectMode::SquashAutoTraitsIssue33140,
+                    |overlap| {
+                        self.check_for_common_items_in_impls(
+                            impl1_def_id,
+                            impl2_def_id,
+                            overlap,
+                            Some(FutureCompatOverlapErrorKind::Issue33140),
+                        );
+                        false
+                    },
+                    || true,
+                );
             }
         }
     }