Skip to content

Commit 81fb703

Browse files
committed
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.
1 parent c69e1a0 commit 81fb703

File tree

1 file changed

+1
-1
lines changed
  • compiler/rustc_trait_selection/src/error_reporting/infer

1 file changed

+1
-1
lines changed

compiler/rustc_trait_selection/src/error_reporting/infer/region.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,7 +1020,7 @@ impl<'a, 'tcx> TypeErrCtxt<'a, 'tcx> {
10201020
&& let Some((sup_expected, sup_found)) =
10211021
self.values_str(sup_trace.values, &sup_trace.cause, err.long_ty_path())
10221022
&& let Some((sub_expected, sub_found)) =
1023-
self.values_str(sub_trace.values, &sup_trace.cause, err.long_ty_path())
1023+
self.values_str(sub_trace.values, &sub_trace.cause, err.long_ty_path())
10241024
&& sub_expected == sup_expected
10251025
&& sub_found == sup_found
10261026
{

0 commit comments

Comments
 (0)