Closed
Description
The clippy lint print_with_newline triggers during scenarios without access to a println macro, such as no_std environments
Lint name:
print_with_newline
I tried this code:
#![no_std]
fn main() {
print!("Hello World!\n");
// Replacing print with println, as suggested by the lint, fails to build as there is no println macro
//println!("Hello World!")
}
#[macro_export]
macro_rules! print {
($($arg:tt)*) => {
unimplemented!()
}
}
I expected to see this happen:
No lint activation
Instead, this happened:
warning: using `print!()` with a format string that ends in a single newline
--> src/main.rs:4:5
|
4 | print!("Hello World!\n");
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(clippy::print_with_newline)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#print_with_newline
help: use `println!` instead
|
4 | println!("Hello World!");
| ^^^^^^^ --
warning: 1 warning emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.00s
Meta
cargo clippy -V
: clippy 0.1.52 (9b471a3 2021-02-19)rustc -Vv
:rustc 1.52.0-nightly (9b471a3f5 2021-02-19) binary: rustc commit-hash: 9b471a3f5fe57e5c6e08acf665f2094422415a3d commit-date: 2021-02-19 host: x86_64-unknown-linux-gnu release: 1.52.0-nightly LLVM version: 11.0.1