-
-
Notifications
You must be signed in to change notification settings - Fork 14.1k
Improve print_type.
#144625
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
Improve print_type.
#144625
Conversation
`ty::Param`s have a name, might as well print it.
|
|
|
Note: the output of |
| Ok(()) | ||
| } | ||
|
|
||
| ty::Param(param_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.
Can you add a comment here? All the other sections in this match have a nice comment.
| | ty::Dynamic(_, _, _) | ||
| | ty::UnsafeBinder(_) => self.pretty_print_type(ty), | ||
|
|
||
| // Placeholders (all printed as `_` to uniformize them). |
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.
This does sound like the _ was deliberate -- but I don't have a strong opinion either way.
|
|
||
| fn main() { | ||
| assert_eq!(Bar(()).foo(), "issue_61894::Bar<_>::foo::f"); | ||
| assert_eq!(Bar(()).foo(), "issue_61894::Bar<M>::foo::f"); |
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.
What is confusing about this is that there is no M in scope when printing the name. If M shadows the name of some other type, this could become misleading.
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.
yea, iirc printing _ was on purpose, because it can't have been relevant for the type name if it's still an uninstantiated param. If there are two impl<M> Bar<M> (e.g. with different bounds, which is where such "dupliate impl blocks" are common), then the type names would still be the same, so adding the M does not really bring any benefit
ty::Params have a name, might as well print it.r? @oli-obk