-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
base: master
Are you sure you want to change the base?
Add a diagnostic for similarly named traits #144674
Conversation
This comment has been minimized.
This comment has been minimized.
compiler/rustc_trait_selection/src/error_reporting/traits/suggestions.rs
Outdated
Show resolved
Hide resolved
…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.
ff869dc
to
abdb087
Compare
This PR modifies cc @jieyouxu |
Fixed by using predicate_must_hold_modulo_regions |
trait_ref | ||
.skip_binder() | ||
.with_self_ty(self.tcx, trait_predicate.skip_binder().self_ty()), |
There was a problem hiding this comment.
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:
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.
There was a problem hiding this comment.
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 !
cc #133123
This is a first proposal, suggestions are welcome