@@ -24,7 +24,6 @@ use rustc_middle::traits::DefiningAnchor;
24
24
use rustc_middle:: ty:: fast_reject:: { DeepRejectCtxt , TreatParams } ;
25
25
use rustc_middle:: ty:: visit:: { TypeVisitable , TypeVisitableExt } ;
26
26
use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeVisitor } ;
27
- use rustc_session:: lint:: builtin:: COINDUCTIVE_OVERLAP_IN_COHERENCE ;
28
27
use rustc_span:: symbol:: sym;
29
28
use rustc_span:: DUMMY_SP ;
30
29
use std:: fmt:: Debug ;
@@ -191,7 +190,8 @@ fn overlap<'tcx>(
191
190
. intercrate ( true )
192
191
. with_next_trait_solver ( tcx. next_trait_solver_in_coherence ( ) )
193
192
. build ( ) ;
194
- let selcx = & mut SelectionContext :: new ( & infcx) ;
193
+ let selcx =
194
+ & mut SelectionContext :: with_treat_inductive_cycle_as ( & infcx, TreatInductiveCycleAs :: Ambig ) ;
195
195
if track_ambiguity_causes. is_yes ( ) {
196
196
selcx. enable_tracking_intercrate_ambiguity_causes ( ) ;
197
197
}
@@ -211,74 +211,14 @@ fn overlap<'tcx>(
211
211
debug ! ( "overlap: unification check succeeded" ) ;
212
212
213
213
if overlap_mode. use_implicit_negative ( ) {
214
- for mode in [ TreatInductiveCycleAs :: Ambig , TreatInductiveCycleAs :: Recur ] {
215
- if let Some ( failing_obligation) = selcx. with_treat_inductive_cycle_as ( mode, |selcx| {
216
- impl_intersection_has_impossible_obligation (
217
- selcx,
218
- param_env,
219
- & impl1_header,
220
- & impl2_header,
221
- & equate_obligations,
222
- )
223
- } ) {
224
- if matches ! ( mode, TreatInductiveCycleAs :: Recur ) {
225
- let first_local_impl = impl1_header
226
- . impl_def_id
227
- . as_local ( )
228
- . or ( impl2_header. impl_def_id . as_local ( ) )
229
- . expect ( "expected one of the impls to be local" ) ;
230
- infcx. tcx . struct_span_lint_hir (
231
- COINDUCTIVE_OVERLAP_IN_COHERENCE ,
232
- infcx. tcx . local_def_id_to_hir_id ( first_local_impl) ,
233
- infcx. tcx . def_span ( first_local_impl) ,
234
- format ! (
235
- "implementations {} will conflict in the future" ,
236
- match impl1_header. trait_ref {
237
- Some ( trait_ref) => {
238
- let trait_ref = infcx. resolve_vars_if_possible( trait_ref) ;
239
- format!(
240
- "of `{}` for `{}`" ,
241
- trait_ref. print_only_trait_path( ) ,
242
- trait_ref. self_ty( )
243
- )
244
- }
245
- None => format!(
246
- "for `{}`" ,
247
- infcx. resolve_vars_if_possible( impl1_header. self_ty)
248
- ) ,
249
- } ,
250
- ) ,
251
- |lint| {
252
- lint. note (
253
- "impls that are not considered to overlap may be considered to \
254
- overlap in the future",
255
- )
256
- . span_label (
257
- infcx. tcx . def_span ( impl1_header. impl_def_id ) ,
258
- "the first impl is here" ,
259
- )
260
- . span_label (
261
- infcx. tcx . def_span ( impl2_header. impl_def_id ) ,
262
- "the second impl is here" ,
263
- ) ;
264
- if !failing_obligation. cause . span . is_dummy ( ) {
265
- lint. span_label (
266
- failing_obligation. cause . span ,
267
- format ! (
268
- "`{}` may be considered to hold in future releases, \
269
- causing the impls to overlap",
270
- infcx
271
- . resolve_vars_if_possible( failing_obligation. predicate)
272
- ) ,
273
- ) ;
274
- }
275
- lint
276
- } ,
277
- ) ;
278
- }
279
-
280
- return None ;
281
- }
214
+ if let Some ( _failing_obligation) = impl_intersection_has_impossible_obligation (
215
+ selcx,
216
+ param_env,
217
+ & impl1_header,
218
+ & impl2_header,
219
+ & equate_obligations,
220
+ ) {
221
+ return None ;
282
222
}
283
223
}
284
224
0 commit comments