Skip to content

Conversation

@nnethercote
Copy link
Contributor

ty::Params have a name, might as well print it.

r? @oli-obk

`ty::Param`s have a name, might as well print it.
@rustbot
Copy link
Collaborator

rustbot commented Jul 29, 2025

oli-obk is not on the review rotation at the moment.
They may take a while to respond.

@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 29, 2025
@rustbot
Copy link
Collaborator

rustbot commented Jul 29, 2025

This PR modifies tests/ui/issues/. If this PR is adding new tests to tests/ui/issues/,
please refrain from doing so, and instead add it to more descriptive subdirectories.

Some changes occurred to the CTFE machinery

cc @RalfJung, @oli-obk, @lcnr

@nnethercote
Copy link
Contributor Author

Note: the output of std::any::type_name is allowed to change, the docs say "The exact contents and format of the string returned are not specified, other than being a best-effort description of the type... the output may change between versions of the compiler."

Ok(())
}

ty::Param(param_ty) => {
Copy link
Member

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).
Copy link
Member

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");
Copy link
Member

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.

Copy link
Contributor

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

@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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