@@ -94,7 +94,9 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
9494
9595 for ( i, & impl1_def_id) in impls. iter ( ) . enumerate ( ) {
9696 for & impl2_def_id in & impls[ ( i + 1 ) ..] {
97- let mut used_to_be_allowed = traits:: overlapping_impls (
97+ // First, check if the impl was forbidden under the
98+ // old rules. In that case, just have an error.
99+ let used_to_be_allowed = traits:: overlapping_impls (
98100 self . tcx ,
99101 impl1_def_id,
100102 impl2_def_id,
@@ -105,52 +107,60 @@ impl<'a, 'tcx> InherentOverlapChecker<'a, 'tcx> {
105107 impl1_def_id,
106108 impl2_def_id,
107109 overlap,
108- Some ( FutureCompatOverlapErrorKind :: Issue43355 ) ,
110+ None ,
109111 ) ;
110112 false
111113 } ,
112114 || true ,
113115 ) ;
114116
115- if used_to_be_allowed {
116- used_to_be_allowed = traits:: overlapping_impls (
117- self . tcx ,
118- impl1_def_id,
119- impl2_def_id,
120- IntercrateMode :: Fixed ,
121- TraitObjectMode :: NoSquash ,
122- |overlap| {
123- self . check_for_common_items_in_impls (
124- impl1_def_id,
125- impl2_def_id,
126- overlap,
127- None ,
128- ) ;
129- false
130- } ,
131- || true ,
132- ) ;
117+ if !used_to_be_allowed {
118+ continue ;
133119 }
134120
135- if used_to_be_allowed {
136- traits:: overlapping_impls (
137- self . tcx ,
138- impl1_def_id,
139- impl2_def_id,
140- IntercrateMode :: Fixed ,
141- TraitObjectMode :: SquashAutoTraitsIssue33140 ,
142- |overlap| {
143- self . check_for_common_items_in_impls (
144- impl1_def_id,
145- impl2_def_id,
146- overlap,
147- Some ( FutureCompatOverlapErrorKind :: Issue33140 ) ,
148- ) ;
149- false
150- } ,
151- || true ,
152- ) ;
121+ // Then, check if the impl was forbidden under only
122+ // #43355. In that case, emit an #43355 error.
123+ let used_to_be_allowed = traits:: overlapping_impls (
124+ self . tcx ,
125+ impl1_def_id,
126+ impl2_def_id,
127+ IntercrateMode :: Fixed ,
128+ TraitObjectMode :: NoSquash ,
129+ |overlap| {
130+ self . check_for_common_items_in_impls (
131+ impl1_def_id,
132+ impl2_def_id,
133+ overlap,
134+ Some ( FutureCompatOverlapErrorKind :: Issue43355 ) ,
135+ ) ;
136+ false
137+ } ,
138+ || true ,
139+ ) ;
140+
141+ if !used_to_be_allowed {
142+ continue ;
153143 }
144+
145+ // Then, check if the impl was forbidden under
146+ // #33140. In that case, emit a #33140 error.
147+ traits:: overlapping_impls (
148+ self . tcx ,
149+ impl1_def_id,
150+ impl2_def_id,
151+ IntercrateMode :: Fixed ,
152+ TraitObjectMode :: SquashAutoTraitsIssue33140 ,
153+ |overlap| {
154+ self . check_for_common_items_in_impls (
155+ impl1_def_id,
156+ impl2_def_id,
157+ overlap,
158+ Some ( FutureCompatOverlapErrorKind :: Issue33140 ) ,
159+ ) ;
160+ false
161+ } ,
162+ || true ,
163+ ) ;
154164 }
155165 }
156166 }
0 commit comments