Skip to content

Commit d753aba

Browse files
Get rid of a_is_expected from ToTrace
1 parent 4fb097a commit d753aba

File tree

2 files changed

+36
-112
lines changed
  • compiler
    • rustc_infer/src/infer
    • rustc_trait_selection/src/traits/select

2 files changed

+36
-112
lines changed

Diff for: compiler/rustc_infer/src/infer/at.rs

+36-109
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,7 @@ impl<'tcx> InferCtxt<'tcx> {
9292
}
9393

9494
pub trait ToTrace<'tcx>: Relate<TyCtxt<'tcx>> + Copy {
95-
fn to_trace(
96-
cause: &ObligationCause<'tcx>,
97-
a_is_expected: bool,
98-
a: Self,
99-
b: Self,
100-
) -> TypeTrace<'tcx>;
95+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx>;
10196
}
10297

10398
impl<'a, 'tcx> At<'a, 'tcx> {
@@ -116,7 +111,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
116111
{
117112
let mut fields = CombineFields::new(
118113
self.infcx,
119-
ToTrace::to_trace(self.cause, true, expected, actual),
114+
ToTrace::to_trace(self.cause, expected, actual),
120115
self.param_env,
121116
define_opaque_types,
122117
);
@@ -136,7 +131,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
136131
{
137132
let mut fields = CombineFields::new(
138133
self.infcx,
139-
ToTrace::to_trace(self.cause, true, expected, actual),
134+
ToTrace::to_trace(self.cause, expected, actual),
140135
self.param_env,
141136
define_opaque_types,
142137
);
@@ -154,10 +149,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
154149
where
155150
T: ToTrace<'tcx>,
156151
{
157-
let mut fields = CombineFields::new(
158-
self.infcx,
159-
ToTrace::to_trace(self.cause, true, expected, actual),
160-
self.param_env,
152+
self.eq_trace(
161153
define_opaque_types,
162154
ToTrace::to_trace(self.cause, expected, actual),
163155
expected,
@@ -209,7 +201,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
209201
assert!(self.infcx.next_trait_solver());
210202
let mut fields = CombineFields::new(
211203
self.infcx,
212-
ToTrace::to_trace(self.cause, true, expected, actual),
204+
ToTrace::to_trace(self.cause, expected, actual),
213205
self.param_env,
214206
DefineOpaqueTypes::Yes,
215207
);
@@ -301,7 +293,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
301293
{
302294
let mut fields = CombineFields::new(
303295
self.infcx,
304-
ToTrace::to_trace(self.cause, true, expected, actual),
296+
ToTrace::to_trace(self.cause, expected, actual),
305297
self.param_env,
306298
define_opaque_types,
307299
);
@@ -323,7 +315,7 @@ impl<'a, 'tcx> At<'a, 'tcx> {
323315
{
324316
let mut fields = CombineFields::new(
325317
self.infcx,
326-
ToTrace::to_trace(self.cause, true, expected, actual),
318+
ToTrace::to_trace(self.cause, expected, actual),
327319
self.param_env,
328320
define_opaque_types,
329321
);
@@ -333,18 +325,13 @@ impl<'a, 'tcx> At<'a, 'tcx> {
333325
}
334326

335327
impl<'tcx> ToTrace<'tcx> for ImplSubject<'tcx> {
336-
fn to_trace(
337-
cause: &ObligationCause<'tcx>,
338-
a_is_expected: bool,
339-
a: Self,
340-
b: Self,
341-
) -> TypeTrace<'tcx> {
328+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
342329
match (a, b) {
343330
(ImplSubject::Trait(trait_ref_a), ImplSubject::Trait(trait_ref_b)) => {
344-
ToTrace::to_trace(cause, a_is_expected, trait_ref_a, trait_ref_b)
331+
ToTrace::to_trace(cause, trait_ref_a, trait_ref_b)
345332
}
346333
(ImplSubject::Inherent(ty_a), ImplSubject::Inherent(ty_b)) => {
347-
ToTrace::to_trace(cause, a_is_expected, ty_a, ty_b)
334+
ToTrace::to_trace(cause, ty_a, ty_b)
348335
}
349336
(ImplSubject::Trait(_), ImplSubject::Inherent(_))
350337
| (ImplSubject::Inherent(_), ImplSubject::Trait(_)) => {
@@ -355,65 +342,45 @@ impl<'tcx> ToTrace<'tcx> for ImplSubject<'tcx> {
355342
}
356343

357344
impl<'tcx> ToTrace<'tcx> for Ty<'tcx> {
358-
fn to_trace(
359-
cause: &ObligationCause<'tcx>,
360-
a_is_expected: bool,
361-
a: Self,
362-
b: Self,
363-
) -> TypeTrace<'tcx> {
345+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
364346
TypeTrace {
365347
cause: cause.clone(),
366-
values: ValuePairs::Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
348+
values: ValuePairs::Terms(ExpectedFound::new(true, a.into(), b.into())),
367349
}
368350
}
369351
}
370352

371353
impl<'tcx> ToTrace<'tcx> for ty::Region<'tcx> {
372-
fn to_trace(
373-
cause: &ObligationCause<'tcx>,
374-
a_is_expected: bool,
375-
a: Self,
376-
b: Self,
377-
) -> TypeTrace<'tcx> {
354+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
378355
TypeTrace {
379356
cause: cause.clone(),
380-
values: ValuePairs::Regions(ExpectedFound::new(a_is_expected, a, b)),
357+
values: ValuePairs::Regions(ExpectedFound::new(true, a, b)),
381358
}
382359
}
383360
}
384361

385362
impl<'tcx> ToTrace<'tcx> for Const<'tcx> {
386-
fn to_trace(
387-
cause: &ObligationCause<'tcx>,
388-
a_is_expected: bool,
389-
a: Self,
390-
b: Self,
391-
) -> TypeTrace<'tcx> {
363+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
392364
TypeTrace {
393365
cause: cause.clone(),
394-
values: ValuePairs::Terms(ExpectedFound::new(a_is_expected, a.into(), b.into())),
366+
values: ValuePairs::Terms(ExpectedFound::new(true, a.into(), b.into())),
395367
}
396368
}
397369
}
398370

399371
impl<'tcx> ToTrace<'tcx> for ty::GenericArg<'tcx> {
400-
fn to_trace(
401-
cause: &ObligationCause<'tcx>,
402-
a_is_expected: bool,
403-
a: Self,
404-
b: Self,
405-
) -> TypeTrace<'tcx> {
372+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
406373
TypeTrace {
407374
cause: cause.clone(),
408375
values: match (a.unpack(), b.unpack()) {
409376
(GenericArgKind::Lifetime(a), GenericArgKind::Lifetime(b)) => {
410-
ValuePairs::Regions(ExpectedFound::new(a_is_expected, a, b))
377+
ValuePairs::Regions(ExpectedFound::new(true, a, b))
411378
}
412379
(GenericArgKind::Type(a), GenericArgKind::Type(b)) => {
413-
ValuePairs::Terms(ExpectedFound::new(a_is_expected, a.into(), b.into()))
380+
ValuePairs::Terms(ExpectedFound::new(true, a.into(), b.into()))
414381
}
415382
(GenericArgKind::Const(a), GenericArgKind::Const(b)) => {
416-
ValuePairs::Terms(ExpectedFound::new(a_is_expected, a.into(), b.into()))
383+
ValuePairs::Terms(ExpectedFound::new(true, a.into(), b.into()))
417384
}
418385

419386
(
@@ -436,72 +403,47 @@ impl<'tcx> ToTrace<'tcx> for ty::GenericArg<'tcx> {
436403
}
437404

438405
impl<'tcx> ToTrace<'tcx> for ty::Term<'tcx> {
439-
fn to_trace(
440-
cause: &ObligationCause<'tcx>,
441-
a_is_expected: bool,
442-
a: Self,
443-
b: Self,
444-
) -> TypeTrace<'tcx> {
406+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
445407
TypeTrace {
446408
cause: cause.clone(),
447-
values: ValuePairs::Terms(ExpectedFound::new(a_is_expected, a, b)),
409+
values: ValuePairs::Terms(ExpectedFound::new(true, a, b)),
448410
}
449411
}
450412
}
451413

452414
impl<'tcx> ToTrace<'tcx> for ty::TraitRef<'tcx> {
453-
fn to_trace(
454-
cause: &ObligationCause<'tcx>,
455-
a_is_expected: bool,
456-
a: Self,
457-
b: Self,
458-
) -> TypeTrace<'tcx> {
415+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
459416
TypeTrace {
460417
cause: cause.clone(),
461-
values: ValuePairs::TraitRefs(ExpectedFound::new(a_is_expected, a, b)),
418+
values: ValuePairs::TraitRefs(ExpectedFound::new(true, a, b)),
462419
}
463420
}
464421
}
465422

466423
impl<'tcx> ToTrace<'tcx> for ty::AliasTy<'tcx> {
467-
fn to_trace(
468-
cause: &ObligationCause<'tcx>,
469-
a_is_expected: bool,
470-
a: Self,
471-
b: Self,
472-
) -> TypeTrace<'tcx> {
424+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
473425
TypeTrace {
474426
cause: cause.clone(),
475-
values: ValuePairs::Aliases(ExpectedFound::new(a_is_expected, a.into(), b.into())),
427+
values: ValuePairs::Aliases(ExpectedFound::new(true, a.into(), b.into())),
476428
}
477429
}
478430
}
479431

480432
impl<'tcx> ToTrace<'tcx> for ty::AliasTerm<'tcx> {
481-
fn to_trace(
482-
cause: &ObligationCause<'tcx>,
483-
a_is_expected: bool,
484-
a: Self,
485-
b: Self,
486-
) -> TypeTrace<'tcx> {
433+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
487434
TypeTrace {
488435
cause: cause.clone(),
489-
values: ValuePairs::Aliases(ExpectedFound::new(a_is_expected, a, b)),
436+
values: ValuePairs::Aliases(ExpectedFound::new(true, a, b)),
490437
}
491438
}
492439
}
493440

494441
impl<'tcx> ToTrace<'tcx> for ty::FnSig<'tcx> {
495-
fn to_trace(
496-
cause: &ObligationCause<'tcx>,
497-
a_is_expected: bool,
498-
a: Self,
499-
b: Self,
500-
) -> TypeTrace<'tcx> {
442+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
501443
TypeTrace {
502444
cause: cause.clone(),
503445
values: ValuePairs::PolySigs(ExpectedFound::new(
504-
a_is_expected,
446+
true,
505447
ty::Binder::dummy(a),
506448
ty::Binder::dummy(b),
507449
)),
@@ -510,43 +452,28 @@ impl<'tcx> ToTrace<'tcx> for ty::FnSig<'tcx> {
510452
}
511453

512454
impl<'tcx> ToTrace<'tcx> for ty::PolyFnSig<'tcx> {
513-
fn to_trace(
514-
cause: &ObligationCause<'tcx>,
515-
a_is_expected: bool,
516-
a: Self,
517-
b: Self,
518-
) -> TypeTrace<'tcx> {
455+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
519456
TypeTrace {
520457
cause: cause.clone(),
521-
values: ValuePairs::PolySigs(ExpectedFound::new(a_is_expected, a, b)),
458+
values: ValuePairs::PolySigs(ExpectedFound::new(true, a, b)),
522459
}
523460
}
524461
}
525462

526463
impl<'tcx> ToTrace<'tcx> for ty::PolyExistentialTraitRef<'tcx> {
527-
fn to_trace(
528-
cause: &ObligationCause<'tcx>,
529-
a_is_expected: bool,
530-
a: Self,
531-
b: Self,
532-
) -> TypeTrace<'tcx> {
464+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
533465
TypeTrace {
534466
cause: cause.clone(),
535-
values: ValuePairs::ExistentialTraitRef(ExpectedFound::new(a_is_expected, a, b)),
467+
values: ValuePairs::ExistentialTraitRef(ExpectedFound::new(true, a, b)),
536468
}
537469
}
538470
}
539471

540472
impl<'tcx> ToTrace<'tcx> for ty::PolyExistentialProjection<'tcx> {
541-
fn to_trace(
542-
cause: &ObligationCause<'tcx>,
543-
a_is_expected: bool,
544-
a: Self,
545-
b: Self,
546-
) -> TypeTrace<'tcx> {
473+
fn to_trace(cause: &ObligationCause<'tcx>, a: Self, b: Self) -> TypeTrace<'tcx> {
547474
TypeTrace {
548475
cause: cause.clone(),
549-
values: ValuePairs::ExistentialProjection(ExpectedFound::new(a_is_expected, a, b)),
476+
values: ValuePairs::ExistentialProjection(ExpectedFound::new(true, a, b)),
550477
}
551478
}
552479
}

Diff for: compiler/rustc_trait_selection/src/traits/select/mod.rs

-3
Original file line numberDiff line numberDiff line change
@@ -2598,7 +2598,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
25982598
DefineOpaqueTypes::Yes,
25992599
ToTrace::to_trace(
26002600
&obligation.cause,
2601-
true,
26022601
hr_target_principal,
26032602
hr_source_principal,
26042603
),
@@ -2638,7 +2637,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
26382637
DefineOpaqueTypes::Yes,
26392638
ToTrace::to_trace(
26402639
&obligation.cause,
2641-
true,
26422640
hr_target_projection,
26432641
hr_source_projection,
26442642
),
@@ -2669,7 +2667,6 @@ impl<'tcx> SelectionContext<'_, 'tcx> {
26692667
DefineOpaqueTypes::Yes,
26702668
ToTrace::to_trace(
26712669
&obligation.cause,
2672-
true,
26732670
hr_target_projection,
26742671
hr_source_projection,
26752672
),

0 commit comments

Comments
 (0)