Skip to content

Conversation

@cuiweixie
Copy link
Contributor

@cuiweixie cuiweixie commented Feb 8, 2026

This looks like a copy-past here from the line above.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 8, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 8, 2026

r? @jackh726

rustbot has assigned @jackh726.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler, types
  • compiler, types expanded to 23 candidates
  • Random selection from 13 candidates

@jackh726
Copy link
Member

jackh726 commented Feb 8, 2026

This needs at minimum a test, but some explanation of why this change was made is also appropriate.

@cuiweixie
Copy link
Contributor Author

This needs at minimum a test, but some explanation of why this change was made is also appropriate.

Done.

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.

@lqd
Copy link
Member

lqd commented Feb 8, 2026

Does this test fail without the changes in this PR? It doesn't seem like it would, so it'd be good to be sure.

@cuiweixie
Copy link
Contributor Author

Does this test fail without the changes in this PR? It doesn't seem like it would, so it'd be good to be sure.

No, the test would not failed. Can not construct a failed test via ui.But i think this fix is still worth. personal view.

@jackh726
Copy link
Member

jackh726 commented Feb 8, 2026

Is there a change in diagnostics for the test (not necessarily just a compile fail to pass? While this change seems correct, a test that changes is important for 3 reasons:

  1. It ensures that this doesn't regress accidentally
  2. It helps us have a more complete and comprehensive test suite
  3. It shows me that the current code was not intentional

Also, please update the OP with your reasoning so it's more obvious for others and posterity.

@cuiweixie
Copy link
Contributor Author

No, the test output does not change — the cause parameter is only used for PolySigs values in values_str, and this test produces TraitRefs. The PolySigs path here is effectively unreachable because try_report_impl_not_conforming_to_trait intercepts that case earlier. So this is a pure correctness fix for a copy-paste error, not an observable behavior change. I've updated the OP with this analysis.

@jackh726
Copy link
Member

jackh726 commented Feb 9, 2026

If the added test doesn't change in any way, there is absolutely no reason to include it. I'm inclined to merge the change because it's "obvious", but the test needs to be removed.

… 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.
@cuiweixie
Copy link
Contributor Author

If the added test doesn't change in any way, there is absolutely no reason to include it. I'm inclined to merge the change because it's "obvious", but the test needs to be removed.

test has been deleted.

@jackh726
Copy link
Member

jackh726 commented Feb 9, 2026

Thanks. As a side note, I think the OP text you had is pretty unnecessarily verbose. I edited it to what it is now, which is exactly sufficient for why this change is being made.

Like I said, it'd be nice to add a test for this, but given that there would be some very specific set of conditions for that test to trigger, and this is so small and obvious - I'm just going to r+ this.

In the future, I would be a bit more careful. Adding tests which aren't impacted by the changes you make is basically a no-go. Overly verbose descriptions and justifications are hard to review, and largely unnecessary. This generally may fall under rust-lang/compiler-team#893 and other team members may be more inclined to outright close the PR.

Hope this was a useful learning experience for you.

@bors r+

@rust-bors
Copy link
Contributor

rust-bors bot commented Feb 9, 2026

📌 Commit 81fb703 has been approved by jackh726

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 9, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Feb 9, 2026
fix: sup_trace to sub_trace

This looks like a copy-past here from the line above.
rust-bors bot pushed a commit that referenced this pull request Feb 10, 2026
…uwer

Rollup of 7 pull requests

Successful merges:

 - #151960 (rustc_parse: improve the error diagnostic for "missing let")
 - #152157 (Fix error spans for `asm!()` args that are macros)
 - #152317 (fix: sup_trace to sub_trace)
 - #150897 (rustc_parse_format: improve diagnostics for unsupported debug = syntax)
 - #151154 (Add `s390x-unknown-none-softfloat` with `RustcAbi::Softfloat`)
 - #152013 (Update to Xcode 26.2)
 - #152326 (Remove the compiler adhoc group)
@rust-bors rust-bors bot merged commit 3199309 into rust-lang:main Feb 10, 2026
11 checks passed
@rustbot rustbot added this to the 1.95.0 milestone Feb 10, 2026
rust-timer added a commit that referenced this pull request Feb 10, 2026
Rollup merge of #152317 - cuiweixie:sup_trace, r=jackh726

fix: sup_trace to sub_trace

This looks like a copy-past here from the line above.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants