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
Add suggestion for explicit_write lint #3450
Add suggestion for explicit_write lint #3450
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
need to fix one leftover debug variable name
7fe226f
to
13819ce
Compare
clippy_lints/src/explicit_write.rs
Outdated
@@ -83,32 +84,57 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for Pass { | |||
} else { | |||
"" | |||
}; | |||
|
|||
// We need to remove the last trailing newline from the string because the | |||
// underlying `fmt::write` function doesn't know wether `println!` or `print!` was |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo in whether
clippy_lints/src/explicit_write.rs
Outdated
// used. | ||
let mut write_output: String = write_output.to_string(); | ||
if write_output.ends_with('\n') { | ||
write_output.truncate(write_output.len() - 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about write_output.pop()
?
clippy_lints/src/explicit_write.rs
Outdated
// We need to remove the last trailing newline from the string because the | ||
// underlying `fmt::write` function doesn't know wether `println!` or `print!` was | ||
// used. | ||
let mut write_output: String = write_output_string(write_args).unwrap(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if this function can fail on some inputs, but if there are cases where this fails, it should probably fall back to not using a suggestion. Otherwise, maybe expect()
would be better?
b3d41bf
to
c84a17d
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
* Fix typo * Handle None value instead of using `unwrap()` * `pop()` instead of `x.truncate(x.len() - 1)`
0933b7a
to
194acaf
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
travis is currently failing (https://travis-ci.org/rust-lang/rust-clippy/jobs/467013498#L152). I'm working on a fix. If travis is working again r=me.
@bors rollup |
Let's queue this @bors r+ |
📌 Commit 194acaf has been approved by |
…lip1995 Add suggestion for explicit_write lint Closes #2083
☀️ Test successful - status-appveyor, status-travis |
Closes #2083