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

Suggest correct println call #51585

Closed
estebank opened this issue Jun 15, 2018 · 3 comments
Closed

Suggest correct println call #51585

estebank opened this issue Jun 15, 2018 · 3 comments
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@estebank
Copy link
Contributor

When trying to write println!(x);, suggest println!("{}", x);.

https://users.rust-lang.org/t/wtf-is-this-problem/18045

@estebank estebank added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-diagnostics Area: Messages for errors, warnings, and lints labels Jun 15, 2018
@csmoe
Copy link
Member

csmoe commented Jun 16, 2018

Since the x may impl Display or Debug, so {:?}/{}, which one should be suggested firstly?

@ollie27
Copy link
Member

ollie27 commented Jun 16, 2018

#30143 might complicate this because the current error message for println!(x); comes from concat! not format_args! like with print!(x);.

@estebank
Copy link
Contributor Author

@csmoe ideally we would check if x is debug or display and suggest accordingly, but we already have help text when we get that wrong, so we could (temporarily) give a best guess suggestion and let the compiler guide users with the follow up errors.

@ollie27 you're right.

Mark-Simulacrum added a commit to Mark-Simulacrum/rust that referenced this issue Jul 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

3 participants