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