@@ -19,8 +19,8 @@ use super::DerivedObligationCause;
1919use super :: Selection ;
2020use super :: SelectionResult ;
2121use super :: TraitNotObjectSafe ;
22+ use super :: TraitQueryMode ;
2223use super :: { BuiltinDerivedObligation , ImplDerivedObligation , ObligationCauseCode } ;
23- use super :: { IntercrateMode , TraitQueryMode } ;
2424use super :: { ObjectCastObligation , Obligation } ;
2525use super :: { ObligationCause , PredicateObligation , TraitObligation } ;
2626use super :: { OutputTypeParameterMismatch , Overflow , SelectionError , Unimplemented } ;
@@ -80,7 +80,7 @@ pub struct SelectionContext<'cx, 'tcx> {
8080 /// other words, we consider `$0: Bar` to be unimplemented if
8181 /// there is no type that the user could *actually name* that
8282 /// would satisfy it. This avoids crippling inference, basically.
83- intercrate : Option < IntercrateMode > ,
83+ intercrate : bool ,
8484
8585 intercrate_ambiguity_causes : Option < Vec < IntercrateAmbiguityCause > > ,
8686
@@ -218,22 +218,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
218218 SelectionContext {
219219 infcx,
220220 freshener : infcx. freshener ( ) ,
221- intercrate : None ,
221+ intercrate : false ,
222222 intercrate_ambiguity_causes : None ,
223223 allow_negative_impls : false ,
224224 query_mode : TraitQueryMode :: Standard ,
225225 }
226226 }
227227
228- pub fn intercrate (
229- infcx : & ' cx InferCtxt < ' cx , ' tcx > ,
230- mode : IntercrateMode ,
231- ) -> SelectionContext < ' cx , ' tcx > {
232- debug ! ( "intercrate({:?})" , mode) ;
228+ pub fn intercrate ( infcx : & ' cx InferCtxt < ' cx , ' tcx > ) -> SelectionContext < ' cx , ' tcx > {
233229 SelectionContext {
234230 infcx,
235231 freshener : infcx. freshener ( ) ,
236- intercrate : Some ( mode ) ,
232+ intercrate : true ,
237233 intercrate_ambiguity_causes : None ,
238234 allow_negative_impls : false ,
239235 query_mode : TraitQueryMode :: Standard ,
@@ -248,7 +244,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
248244 SelectionContext {
249245 infcx,
250246 freshener : infcx. freshener ( ) ,
251- intercrate : None ,
247+ intercrate : false ,
252248 intercrate_ambiguity_causes : None ,
253249 allow_negative_impls,
254250 query_mode : TraitQueryMode :: Standard ,
@@ -263,7 +259,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
263259 SelectionContext {
264260 infcx,
265261 freshener : infcx. freshener ( ) ,
266- intercrate : None ,
262+ intercrate : false ,
267263 intercrate_ambiguity_causes : None ,
268264 allow_negative_impls : false ,
269265 query_mode,
@@ -276,7 +272,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
276272 /// false overflow results (#47139) and because it costs
277273 /// computation time.
278274 pub fn enable_tracking_intercrate_ambiguity_causes ( & mut self ) {
279- assert ! ( self . intercrate. is_some ( ) ) ;
275+ assert ! ( self . intercrate) ;
280276 assert ! ( self . intercrate_ambiguity_causes. is_none( ) ) ;
281277 self . intercrate_ambiguity_causes = Some ( vec ! [ ] ) ;
282278 debug ! ( "selcx: enable_tracking_intercrate_ambiguity_causes" ) ;
@@ -286,7 +282,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
286282 /// was enabled and disables tracking at the same time. If
287283 /// tracking is not enabled, just returns an empty vector.
288284 pub fn take_intercrate_ambiguity_causes ( & mut self ) -> Vec < IntercrateAmbiguityCause > {
289- assert ! ( self . intercrate. is_some ( ) ) ;
285+ assert ! ( self . intercrate) ;
290286 self . intercrate_ambiguity_causes . take ( ) . unwrap_or ( vec ! [ ] )
291287 }
292288
@@ -562,7 +558,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
562558 ) -> Result < EvaluationResult , OverflowError > {
563559 debug ! ( "evaluate_trait_predicate_recursively({:?})" , obligation) ;
564560
565- if self . intercrate . is_none ( )
561+ if ! self . intercrate
566562 && obligation. is_global ( )
567563 && obligation. param_env . caller_bounds . iter ( ) . all ( |bound| bound. needs_subst ( ) )
568564 {
@@ -727,7 +723,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
727723 stack. fresh_trait_ref . skip_binder ( ) . input_types ( ) . any ( |ty| ty. is_fresh ( ) ) ;
728724 // This check was an imperfect workaround for a bug in the old
729725 // intercrate mode; it should be removed when that goes away.
730- if unbound_input_types && self . intercrate == Some ( IntercrateMode :: Issue43355 ) {
726+ if unbound_input_types && self . intercrate {
731727 debug ! (
732728 "evaluate_stack({:?}) --> unbound argument, intercrate --> ambiguous" ,
733729 stack. fresh_trait_ref
@@ -1206,7 +1202,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12061202 fn is_knowable < ' o > ( & mut self , stack : & TraitObligationStack < ' o , ' tcx > ) -> Option < Conflict > {
12071203 debug ! ( "is_knowable(intercrate={:?})" , self . intercrate) ;
12081204
1209- if !self . intercrate . is_some ( ) {
1205+ if !self . intercrate {
12101206 return None ;
12111207 }
12121208
@@ -1218,17 +1214,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12181214 // bound regions.
12191215 let trait_ref = predicate. skip_binder ( ) . trait_ref ;
12201216
1221- let result = coherence:: trait_ref_is_knowable ( self . tcx ( ) , trait_ref) ;
1222- if let (
1223- Some ( Conflict :: Downstream { used_to_be_broken : true } ) ,
1224- Some ( IntercrateMode :: Issue43355 ) ,
1225- ) = ( result, self . intercrate )
1226- {
1227- debug ! ( "is_knowable: IGNORING conflict to be bug-compatible with #43355" ) ;
1228- None
1229- } else {
1230- result
1231- }
1217+ coherence:: trait_ref_is_knowable ( self . tcx ( ) , trait_ref)
12321218 }
12331219
12341220 /// Returns `true` if the global caches can be used.
@@ -1249,7 +1235,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
12491235 // the master cache. Since coherence executes pretty quickly,
12501236 // it's not worth going to more trouble to increase the
12511237 // hit-rate, I don't think.
1252- if self . intercrate . is_some ( ) {
1238+ if self . intercrate {
12531239 return false ;
12541240 }
12551241
@@ -3305,7 +3291,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
33053291 return Err ( ( ) ) ;
33063292 }
33073293
3308- if self . intercrate . is_none ( )
3294+ if ! self . intercrate
33093295 && self . tcx ( ) . impl_polarity ( impl_def_id) == ty:: ImplPolarity :: Reservation
33103296 {
33113297 debug ! ( "match_impl: reservation impls only apply in intercrate mode" ) ;
0 commit comments