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

#4542 remove machine applicable suggestion #4544

Merged
merged 1 commit into from
Sep 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion clippy_lints/src/explicit_write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,8 @@ fn write_output_string(write_args: &HirVec<Expr>) -> Option<String> {
if output_args.len() > 0;
if let ExprKind::AddrOf(_, ref output_string_expr) = output_args[0].node;
if let ExprKind::Array(ref string_exprs) = output_string_expr.node;
if string_exprs.len() > 0;
// we only want to provide an automatic suggestion for simple (non-format) strings
if string_exprs.len() == 1;
if let ExprKind::Lit(ref lit) = string_exprs[0].node;
if let LitKind::Str(ref write_output, _) = lit.node;
then {
Expand Down
8 changes: 8 additions & 0 deletions tests/ui/explicit_write_non_rustfix.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#![allow(unused_imports, clippy::blacklisted_name)]
#![warn(clippy::explicit_write)]

fn main() {
use std::io::Write;
let bar = "bar";
writeln!(std::io::stderr(), "foo {}", bar).unwrap();
}
10 changes: 10 additions & 0 deletions tests/ui/explicit_write_non_rustfix.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
error: use of `writeln!(stderr(), ...).unwrap()`. Consider using `eprintln!` instead
--> $DIR/explicit_write_non_rustfix.rs:7:5
|
LL | writeln!(std::io::stderr(), "foo {}", bar).unwrap();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D clippy::explicit-write` implied by `-D warnings`

error: aborting due to previous error