Skip to content

Add a diagnostic for similarly named traits #144674

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

rperier
Copy link
Contributor

@rperier rperier commented Jul 30, 2025

cc #133123

This is a first proposal, suggestions are welcome

@rustbot
Copy link
Collaborator

rustbot commented Jul 30, 2025

r? @lcnr

rustbot has assigned @lcnr.
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

@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 Jul 30, 2025
@rust-log-analyzer

This comment has been minimized.

…equired one

This is useful when you have two dependencies that use different trait for
the same thing and with the same name. The user can accidentally implement
the bad one which might be confusing.
@rperier rperier force-pushed the add_note_if_a_type_impl_a_trait_with_the_same_name branch from ff869dc to abdb087 Compare August 1, 2025 06:40
@rustbot rustbot added the A-run-make Area: port run-make Makefiles to rmake.rs label Aug 1, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 1, 2025

This PR modifies run-make tests.

cc @jieyouxu

@rperier
Copy link
Contributor Author

rperier commented Aug 1, 2025

Fixed by using predicate_must_hold_modulo_regions

Comment on lines +5133 to +5135
trait_ref
.skip_binder()
.with_self_ty(self.tcx, trait_predicate.skip_binder().self_ty()),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

skip_binder is pretty much never correct:

https://rustc-dev-guide.rust-lang.org/ty_module/early_binder.html?highlight=Binder#earlybinder-and-instantiating-parameters

also see https://rustc-dev-guide.rust-lang.org/typing_parameter_envs.html

U will also need to properly handle the generic parameters of the traits here, e.g. what if we've got trait Trait {} and a separate trait Trait<T> {}

Also, check predicate must hold for the other trait, not per impl.

Copy link
Contributor Author

@rperier rperier Aug 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mhhhh, I see. I have to document myself about this part, thanks for the links.

Also, check predicate must hold for the other trait, not per impl.

Would you have a usecase for this ? You're probably right, but I don't get it.

thanks !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-run-make Area: port run-make Makefiles to rmake.rs 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants