@@ -17,8 +17,8 @@ use super::DerivedObligationCause;
1717use super :: Selection ;
1818use super :: SelectionResult ;
1919use super :: TraitNotObjectSafe ;
20+ use super :: TraitQueryMode ;
2021use super :: { BuiltinDerivedObligation , ImplDerivedObligation , ObligationCauseCode } ;
21- use super :: { IntercrateMode , TraitQueryMode } ;
2222use super :: { ObjectCastObligation , Obligation } ;
2323use super :: { ObligationCause , PredicateObligation , TraitObligation } ;
2424use super :: { OutputTypeParameterMismatch , Overflow , SelectionError , Unimplemented } ;
@@ -78,7 +78,7 @@ pub struct SelectionContext<'cx, 'tcx> {
7878 /// other words, we consider `$0: Bar` to be unimplemented if
7979 /// there is no type that the user could *actually name* that
8080 /// would satisfy it. This avoids crippling inference, basically.
81- intercrate : Option < IntercrateMode > ,
81+ intercrate : bool ,
8282
8383 intercrate_ambiguity_causes : Option < Vec < IntercrateAmbiguityCause > > ,
8484
@@ -216,22 +216,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
216216 SelectionContext {
217217 infcx,
218218 freshener : infcx. freshener ( ) ,
219- intercrate : None ,
219+ intercrate : false ,
220220 intercrate_ambiguity_causes : None ,
221221 allow_negative_impls : false ,
222222 query_mode : TraitQueryMode :: Standard ,
223223 }
224224 }
225225
226- pub fn intercrate (
227- infcx : & ' cx InferCtxt < ' cx , ' tcx > ,
228- mode : IntercrateMode ,
229- ) -> SelectionContext < ' cx , ' tcx > {
230- debug ! ( "intercrate({:?})" , mode) ;
226+ pub fn intercrate ( infcx : & ' cx InferCtxt < ' cx , ' tcx > ) -> SelectionContext < ' cx , ' tcx > {
231227 SelectionContext {
232228 infcx,
233229 freshener : infcx. freshener ( ) ,
234- intercrate : Some ( mode ) ,
230+ intercrate : true ,
235231 intercrate_ambiguity_causes : None ,
236232 allow_negative_impls : false ,
237233 query_mode : TraitQueryMode :: Standard ,
@@ -246,7 +242,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
246242 SelectionContext {
247243 infcx,
248244 freshener : infcx. freshener ( ) ,
249- intercrate : None ,
245+ intercrate : false ,
250246 intercrate_ambiguity_causes : None ,
251247 allow_negative_impls,
252248 query_mode : TraitQueryMode :: Standard ,
@@ -261,7 +257,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
261257 SelectionContext {
262258 infcx,
263259 freshener : infcx. freshener ( ) ,
264- intercrate : None ,
260+ intercrate : false ,
265261 intercrate_ambiguity_causes : None ,
266262 allow_negative_impls : false ,
267263 query_mode,
@@ -274,7 +270,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
274270 /// false overflow results (#47139) and because it costs
275271 /// computation time.
276272 pub fn enable_tracking_intercrate_ambiguity_causes ( & mut self ) {
277- assert ! ( self . intercrate. is_some ( ) ) ;
273+ assert ! ( self . intercrate) ;
278274 assert ! ( self . intercrate_ambiguity_causes. is_none( ) ) ;
279275 self . intercrate_ambiguity_causes = Some ( vec ! [ ] ) ;
280276 debug ! ( "selcx: enable_tracking_intercrate_ambiguity_causes" ) ;
@@ -284,7 +280,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
284280 /// was enabled and disables tracking at the same time. If
285281 /// tracking is not enabled, just returns an empty vector.
286282 pub fn take_intercrate_ambiguity_causes ( & mut self ) -> Vec < IntercrateAmbiguityCause > {
287- assert ! ( self . intercrate. is_some ( ) ) ;
283+ assert ! ( self . intercrate) ;
288284 self . intercrate_ambiguity_causes . take ( ) . unwrap_or ( vec ! [ ] )
289285 }
290286
@@ -560,7 +556,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
560556 ) -> Result < EvaluationResult , OverflowError > {
561557 debug ! ( "evaluate_trait_predicate_recursively({:?})" , obligation) ;
562558
563- if self . intercrate . is_none ( )
559+ if ! self . intercrate
564560 && obligation. is_global ( )
565561 && obligation. param_env . caller_bounds . iter ( ) . all ( |bound| bound. needs_subst ( ) )
566562 {
@@ -725,7 +721,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
725721 stack. fresh_trait_ref . skip_binder ( ) . input_types ( ) . any ( |ty| ty. is_fresh ( ) ) ;
726722 // This check was an imperfect workaround for a bug in the old
727723 // intercrate mode; it should be removed when that goes away.
728- if unbound_input_types && self . intercrate == Some ( IntercrateMode :: Issue43355 ) {
724+ if unbound_input_types && self . intercrate {
729725 debug ! (
730726 "evaluate_stack({:?}) --> unbound argument, intercrate --> ambiguous" ,
731727 stack. fresh_trait_ref
@@ -1204,7 +1200,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12041200 fn is_knowable < ' o > ( & mut self , stack : & TraitObligationStack < ' o , ' tcx > ) -> Option < Conflict > {
12051201 debug ! ( "is_knowable(intercrate={:?})" , self . intercrate) ;
12061202
1207- if !self . intercrate . is_some ( ) {
1203+ if !self . intercrate {
12081204 return None ;
12091205 }
12101206
@@ -1216,17 +1212,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12161212 // bound regions.
12171213 let trait_ref = predicate. skip_binder ( ) . trait_ref ;
12181214
1219- let result = coherence:: trait_ref_is_knowable ( self . tcx ( ) , trait_ref) ;
1220- if let (
1221- Some ( Conflict :: Downstream { used_to_be_broken : true } ) ,
1222- Some ( IntercrateMode :: Issue43355 ) ,
1223- ) = ( result, self . intercrate )
1224- {
1225- debug ! ( "is_knowable: IGNORING conflict to be bug-compatible with #43355" ) ;
1226- None
1227- } else {
1228- result
1229- }
1215+ coherence:: trait_ref_is_knowable ( self . tcx ( ) , trait_ref)
12301216 }
12311217
12321218 /// Returns `true` if the global caches can be used.
@@ -1247,7 +1233,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12471233 // the master cache. Since coherence executes pretty quickly,
12481234 // it's not worth going to more trouble to increase the
12491235 // hit-rate, I don't think.
1250- if self . intercrate . is_some ( ) {
1236+ if self . intercrate {
12511237 return false ;
12521238 }
12531239
@@ -3303,7 +3289,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
33033289 return Err ( ( ) ) ;
33043290 }
33053291
3306- if self . intercrate . is_none ( )
3292+ if ! self . intercrate
33073293 && self . tcx ( ) . impl_polarity ( impl_def_id) == ty:: ImplPolarity :: Reservation
33083294 {
33093295 debug ! ( "match_impl: reservation impls only apply in intercrate mode" ) ;
0 commit comments