@@ -19,8 +19,8 @@ use super::DerivedObligationCause;
19
19
use super :: Selection ;
20
20
use super :: SelectionResult ;
21
21
use super :: TraitNotObjectSafe ;
22
+ use super :: TraitQueryMode ;
22
23
use super :: { BuiltinDerivedObligation , ImplDerivedObligation , ObligationCauseCode } ;
23
- use super :: { IntercrateMode , TraitQueryMode } ;
24
24
use super :: { ObjectCastObligation , Obligation } ;
25
25
use super :: { ObligationCause , PredicateObligation , TraitObligation } ;
26
26
use super :: { OutputTypeParameterMismatch , Overflow , SelectionError , Unimplemented } ;
@@ -80,7 +80,7 @@ pub struct SelectionContext<'cx, 'tcx> {
80
80
/// other words, we consider `$0: Bar` to be unimplemented if
81
81
/// there is no type that the user could *actually name* that
82
82
/// would satisfy it. This avoids crippling inference, basically.
83
- intercrate : Option < IntercrateMode > ,
83
+ intercrate : bool ,
84
84
85
85
intercrate_ambiguity_causes : Option < Vec < IntercrateAmbiguityCause > > ,
86
86
@@ -218,22 +218,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
218
218
SelectionContext {
219
219
infcx,
220
220
freshener : infcx. freshener ( ) ,
221
- intercrate : None ,
221
+ intercrate : false ,
222
222
intercrate_ambiguity_causes : None ,
223
223
allow_negative_impls : false ,
224
224
query_mode : TraitQueryMode :: Standard ,
225
225
}
226
226
}
227
227
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 > {
233
229
SelectionContext {
234
230
infcx,
235
231
freshener : infcx. freshener ( ) ,
236
- intercrate : Some ( mode ) ,
232
+ intercrate : true ,
237
233
intercrate_ambiguity_causes : None ,
238
234
allow_negative_impls : false ,
239
235
query_mode : TraitQueryMode :: Standard ,
@@ -248,7 +244,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
248
244
SelectionContext {
249
245
infcx,
250
246
freshener : infcx. freshener ( ) ,
251
- intercrate : None ,
247
+ intercrate : false ,
252
248
intercrate_ambiguity_causes : None ,
253
249
allow_negative_impls,
254
250
query_mode : TraitQueryMode :: Standard ,
@@ -263,7 +259,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
263
259
SelectionContext {
264
260
infcx,
265
261
freshener : infcx. freshener ( ) ,
266
- intercrate : None ,
262
+ intercrate : false ,
267
263
intercrate_ambiguity_causes : None ,
268
264
allow_negative_impls : false ,
269
265
query_mode,
@@ -276,7 +272,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
276
272
/// false overflow results (#47139) and because it costs
277
273
/// computation time.
278
274
pub fn enable_tracking_intercrate_ambiguity_causes ( & mut self ) {
279
- assert ! ( self . intercrate. is_some ( ) ) ;
275
+ assert ! ( self . intercrate) ;
280
276
assert ! ( self . intercrate_ambiguity_causes. is_none( ) ) ;
281
277
self . intercrate_ambiguity_causes = Some ( vec ! [ ] ) ;
282
278
debug ! ( "selcx: enable_tracking_intercrate_ambiguity_causes" ) ;
@@ -286,7 +282,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
286
282
/// was enabled and disables tracking at the same time. If
287
283
/// tracking is not enabled, just returns an empty vector.
288
284
pub fn take_intercrate_ambiguity_causes ( & mut self ) -> Vec < IntercrateAmbiguityCause > {
289
- assert ! ( self . intercrate. is_some ( ) ) ;
285
+ assert ! ( self . intercrate) ;
290
286
self . intercrate_ambiguity_causes . take ( ) . unwrap_or ( vec ! [ ] )
291
287
}
292
288
@@ -562,7 +558,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
562
558
) -> Result < EvaluationResult , OverflowError > {
563
559
debug ! ( "evaluate_trait_predicate_recursively({:?})" , obligation) ;
564
560
565
- if self . intercrate . is_none ( )
561
+ if ! self . intercrate
566
562
&& obligation. is_global ( )
567
563
&& obligation. param_env . caller_bounds . iter ( ) . all ( |bound| bound. needs_subst ( ) )
568
564
{
@@ -727,7 +723,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
727
723
stack. fresh_trait_ref . skip_binder ( ) . input_types ( ) . any ( |ty| ty. is_fresh ( ) ) ;
728
724
// This check was an imperfect workaround for a bug in the old
729
725
// 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 {
731
727
debug ! (
732
728
"evaluate_stack({:?}) --> unbound argument, intercrate --> ambiguous" ,
733
729
stack. fresh_trait_ref
@@ -1206,7 +1202,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1206
1202
fn is_knowable < ' o > ( & mut self , stack : & TraitObligationStack < ' o , ' tcx > ) -> Option < Conflict > {
1207
1203
debug ! ( "is_knowable(intercrate={:?})" , self . intercrate) ;
1208
1204
1209
- if !self . intercrate . is_some ( ) {
1205
+ if !self . intercrate {
1210
1206
return None ;
1211
1207
}
1212
1208
@@ -1218,17 +1214,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1218
1214
// bound regions.
1219
1215
let trait_ref = predicate. skip_binder ( ) . trait_ref ;
1220
1216
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)
1232
1218
}
1233
1219
1234
1220
/// Returns `true` if the global caches can be used.
@@ -1249,7 +1235,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
1249
1235
// the master cache. Since coherence executes pretty quickly,
1250
1236
// it's not worth going to more trouble to increase the
1251
1237
// hit-rate, I don't think.
1252
- if self . intercrate . is_some ( ) {
1238
+ if self . intercrate {
1253
1239
return false ;
1254
1240
}
1255
1241
@@ -3305,7 +3291,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
3305
3291
return Err ( ( ) ) ;
3306
3292
}
3307
3293
3308
- if self . intercrate . is_none ( )
3294
+ if ! self . intercrate
3309
3295
&& self . tcx ( ) . impl_polarity ( impl_def_id) == ty:: ImplPolarity :: Reservation
3310
3296
{
3311
3297
debug ! ( "match_impl: reservation impls only apply in intercrate mode" ) ;
0 commit comments