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

Print with newline edge cases #2295

Closed
killercup opened this issue Dec 23, 2017 · 3 comments
Closed

Print with newline edge cases #2295

killercup opened this issue Dec 23, 2017 · 3 comments

Comments

@killercup
Copy link
Member

killercup commented Dec 23, 2017

I ran clippy on diesel-rs/diesel#1428 and it gave the following warnings:

error: using `print!()` with a format string that ends in a newline, consider using `println!()` instead
  --> src/comment.rs:28:9
   |
28 |         print!("===============\n\n");
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
note: lint level defined here
  --> src/main.rs:1:9
   |
1  | #![deny(warnings)]
   |         ^^^^^^^^
   = note: #[deny(print_with_newline)] implied by #[deny(warnings)]
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.177/index.html#print_with_newline

error: using `print!()` with a format string that ends in a newline, consider using `println!()` instead
  --> src/post.rs:56:5
   |
56 |     print!("\n");
   |     ^^^^^^^^^^^^^
   |
   = help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.177/index.html#print_with_newline

These are not wrong but also not helpful: We want to explicitly write a number of new lines.

@sgrif
Copy link

sgrif commented Jan 2, 2018

Hilariously, I only wrote print!("\n") over println!("") because I could have sworn clippy complained on empty string to println!

@killercup
Copy link
Member Author

I could have sworn clippy complained on empty string to println!

It wants you to use println!();. Let me open an issue to add a suggestion for that: #2319.

@basil-cow
Copy link
Contributor

duplicate of #2990, can now be closed @flip1995

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

No branches or pull requests

4 participants