Skip to content
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

Provide Display implementation for types that can be used in diagnostic messages #57

Open
celinval opened this issue Dec 13, 2023 · 4 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@celinval
Copy link
Contributor

celinval commented Dec 13, 2023

In order to make it easier for generating user friendly messages, it would be great if we could provide a Display implementation for things like type, function definition, instance, static variables, and everything that implements CrateDef. The implementation would print their definition to the final user.

@momvart
Copy link

momvart commented Jan 14, 2024

@rustbot claim

@momvart
Copy link

momvart commented Jan 15, 2024

@celinval
Just to double-check, by definition you mean the full information, right? Like for AdtDef to include all variants and fields, for FnDef the body, etc.

@celinval
Copy link
Contributor Author

Hi @momvart, that's a good question. I was thinking about just the name including any generic / instantiation parameter. For example, for things that implement CrateDef, I believe we can just invoke the name() function. Instance has its own name function that can be used.

For types, I think the closest we have is pretty_ty(), but there's a PR open to finish implementing it: rust-lang/rust#118364.

For types, I think we should probably implement Display for Ty, and replace pretty_ty usages.

@momvart
Copy link

momvart commented Jan 15, 2024

Thanks for the answer. So overall I think long and fine details are not required and some identifiers are enough for this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants