-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
diagnostics: add note when param-env shadows global impl #150424
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: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
| let all_impls = | ||
| impls.blanket_impls().iter().chain(impls.non_blanket_impls().values().flatten()); | ||
|
|
||
| for &impl_def_id in all_impls { |
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.
use compute_applicable_impls_for_diagnostics instead of all_impls here
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.
and specialization_graph::assoc_def to get the DefId of the assoc item
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.
okay!
| "the associated type `{}` is defined as `{}` in the implementation, \ | ||
| but the generic bound `{}` hides this definition", |
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.
cc @rust-lang/types unsure about this note. I think it's certainly useful. Ideally we'd link to some reference section or github issue explaining impl shadowing.
I think it's easiest to write a special github issue for this quickly explaining why this happens, what they can do about it, and how this may change in the future
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.
Im not sure a github issue is the best place but also I don't know where would be better... If something reference-like was t-types controlled then certainly there 🤔 github issue is probably good enough :)
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.
should I open a issue then ?
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.
going to do so myself as I have strong opinions on the way we frame this
This comment has been minimized.
This comment has been minimized.
22a4a6b to
f616235
Compare
|
@lcnr I made the suggested changes and CI is also green now . |
| let impl_trait_ref = tcx.impl_trait_ref(impl_def_id).instantiate(tcx, impl_substs); | ||
|
|
||
| let expected_trait_ref = alias.trait_ref(tcx); | ||
|
|
||
| if !self.infcx.can_eq(param_env, expected_trait_ref, impl_trait_ref) { | ||
| return false; | ||
| } |
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.
no need, handled by compute_applicable_impls_for_diagnostics
| let impl_trait_ref = tcx.impl_trait_ref(impl_def_id).instantiate(tcx, impl_substs); | |
| let expected_trait_ref = alias.trait_ref(tcx); | |
| if !self.infcx.can_eq(param_env, expected_trait_ref, impl_trait_ref) { | |
| return false; | |
| } |
This PR adds a diagnostics note when param-env shadows global impl as discussed in #149910
It adds a note explaining that the definition is hidden by the generic bound.
r?lcnr