Commit 81fb703
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 changedLines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1020 | 1020 | | |
1021 | 1021 | | |
1022 | 1022 | | |
1023 | | - | |
| 1023 | + | |
1024 | 1024 | | |
1025 | 1025 | | |
1026 | 1026 | | |
| |||
0 commit comments