@@ -10,7 +10,7 @@ use crate::solve::inspect::{InspectGoal, ProofTreeInferCtxtExt, ProofTreeVisitor
1010use crate :: solve:: { deeply_normalize_for_diagnostics, inspect} ;
1111use crate :: traits:: engine:: TraitEngineExt ;
1212use crate :: traits:: query:: evaluate_obligation:: InferCtxtExt ;
13- use crate :: traits:: select:: { IntercrateAmbiguityCause , TreatInductiveCycleAs } ;
13+ use crate :: traits:: select:: IntercrateAmbiguityCause ;
1414use crate :: traits:: structural_normalize:: StructurallyNormalizeExt ;
1515use crate :: traits:: NormalizeExt ;
1616use crate :: traits:: SkipLeakCheck ;
@@ -31,7 +31,6 @@ use rustc_middle::traits::DefiningAnchor;
3131use rustc_middle:: ty:: fast_reject:: { DeepRejectCtxt , TreatParams } ;
3232use rustc_middle:: ty:: visit:: { TypeVisitable , TypeVisitableExt } ;
3333use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeSuperVisitable , TypeVisitor } ;
34- use rustc_session:: lint:: builtin:: COINDUCTIVE_OVERLAP_IN_COHERENCE ;
3534use rustc_span:: symbol:: sym;
3635use rustc_span:: DUMMY_SP ;
3736use std:: fmt:: Debug ;
@@ -197,7 +196,7 @@ fn overlap<'tcx>(
197196 . intercrate ( true )
198197 . with_next_trait_solver ( tcx. next_trait_solver_in_coherence ( ) )
199198 . build ( ) ;
200- let selcx = & mut SelectionContext :: new ( & infcx) ;
199+ let selcx = & mut SelectionContext :: with_treat_inductive_cycle_as_ambig ( & infcx) ;
201200 if track_ambiguity_causes. is_yes ( ) {
202201 selcx. enable_tracking_intercrate_ambiguity_causes ( ) ;
203202 }
@@ -224,61 +223,10 @@ fn overlap<'tcx>(
224223 ) ;
225224
226225 if overlap_mode. use_implicit_negative ( ) {
227- for mode in [ TreatInductiveCycleAs :: Ambig , TreatInductiveCycleAs :: Recur ] {
228- if let Some ( failing_obligation) = selcx. with_treat_inductive_cycle_as ( mode, |selcx| {
229- impl_intersection_has_impossible_obligation ( selcx, & obligations)
230- } ) {
231- if matches ! ( mode, TreatInductiveCycleAs :: Recur ) {
232- let first_local_impl = impl1_header
233- . impl_def_id
234- . as_local ( )
235- . or ( impl2_header. impl_def_id . as_local ( ) )
236- . expect ( "expected one of the impls to be local" ) ;
237- infcx. tcx . struct_span_lint_hir (
238- COINDUCTIVE_OVERLAP_IN_COHERENCE ,
239- infcx. tcx . local_def_id_to_hir_id ( first_local_impl) ,
240- infcx. tcx . def_span ( first_local_impl) ,
241- format ! (
242- "implementations {} will conflict in the future" ,
243- match impl1_header. trait_ref {
244- Some ( trait_ref) => {
245- let trait_ref = infcx. resolve_vars_if_possible( trait_ref) ;
246- format!(
247- "of `{}` for `{}`" ,
248- trait_ref. print_trait_sugared( ) ,
249- trait_ref. self_ty( )
250- )
251- }
252- None => format!(
253- "for `{}`" ,
254- infcx. resolve_vars_if_possible( impl1_header. self_ty)
255- ) ,
256- } ,
257- ) ,
258- |lint| {
259- lint. note (
260- "impls that are not considered to overlap may be considered to \
261- overlap in the future",
262- )
263- . span_label (
264- infcx. tcx . def_span ( impl1_header. impl_def_id ) ,
265- "the first impl is here" ,
266- )
267- . span_label (
268- infcx. tcx . def_span ( impl2_header. impl_def_id ) ,
269- "the second impl is here" ,
270- ) ;
271- lint. note ( format ! (
272- "`{}` may be considered to hold in future releases, \
273- causing the impls to overlap",
274- infcx. resolve_vars_if_possible( failing_obligation. predicate)
275- ) ) ;
276- } ,
277- ) ;
278- }
279-
280- return None ;
281- }
226+ if let Some ( _failing_obligation) =
227+ impl_intersection_has_impossible_obligation ( selcx, & obligations)
228+ {
229+ return None ;
282230 }
283231 }
284232
0 commit comments