Fix copy-paste bug: use sub_trace.cause instead of sup_trace.cause in report_sub_sup_conflict
In `report_sub_sup_conflict`, when calling `values_str` for `sub_trace.values`, the code was incorrectly passing `sup_trace.cause` instead of `sub_trace.cause`. This is a copy-paste error from the preceding line which correctly uses `sup_trace.cause` for `sup_trace.values`. The `cause` parameter matters for `ValuePairs::PolySigs` comparisons, where `values_str` inspects `cause.code()` to extract `impl_item_def_id` and `trait_item_def_id` for richer function signature diagnostics. Using the wrong trace's cause could produce incorrect function def IDs, leading to misleading diagnostic output when the sub and sup traces originate from different obligations. Even for non-PolySigs variants where `cause` is currently unused by `values_str`, passing the semantically correct cause is the right thing to do for correctness and maintainability.
This commit is contained in:
parent
c69e1a04db
commit
81fb703664
1 changed files with 1 additions and 1 deletions
|
|
@ -1020,7 +1020,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
|
|||
&& let Some((sup_expected, sup_found)) =
|
||||
self.values_str(sup_trace.values, &sup_trace.cause, err.long_ty_path())
|
||||
&& let Some((sub_expected, sub_found)) =
|
||||
self.values_str(sub_trace.values, &sup_trace.cause, err.long_ty_path())
|
||||
self.values_str(sub_trace.values, &sub_trace.cause, err.long_ty_path())
|
||||
&& sub_expected == sup_expected
|
||||
&& sub_found == sup_found
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue