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

Add suggestion for explicit_write lint #3450

Merged
merged 7 commits into from Dec 12, 2018

Conversation

phansch
Copy link
Member

@phansch phansch commented Nov 23, 2018

Closes #2083

@phansch phansch changed the title Add suggestion for explicit_write lint WIP: Add suggestion for explicit_write lint Nov 23, 2018
@phansch phansch added the S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) label Nov 23, 2018
Copy link
Member Author

@phansch phansch left a 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

clippy_lints/src/explicit_write.rs Outdated Show resolved Hide resolved
@phansch phansch force-pushed the structured_sugg_for_explicit_write branch 2 times, most recently from 7fe226f to 13819ce Compare November 24, 2018 10:06
@phansch phansch changed the title WIP: Add suggestion for explicit_write lint Add suggestion for explicit_write lint Nov 24, 2018
@phansch phansch added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Nov 24, 2018
@@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in whether

// used.
let mut write_output: String = write_output.to_string();
if write_output.ends_with('\n') {
write_output.truncate(write_output.len() - 1)
Copy link
Member

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()?

// 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();
Copy link
Member

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?

@phansch phansch force-pushed the structured_sugg_for_explicit_write branch from b3d41bf to c84a17d Compare November 29, 2018 07:22
@phansch phansch added S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) S-waiting-on-review Status: Awaiting review from the assignee but also interested parties and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties S-waiting-on-author Status: This is awaiting some action from the author. (Use `@rustbot ready` to update this status) labels Nov 29, 2018
@phansch

This comment has been minimized.

@bors

This comment has been minimized.

@phansch phansch force-pushed the structured_sugg_for_explicit_write branch from 0933b7a to 194acaf Compare December 12, 2018 06:33
Copy link
Member

@flip1995 flip1995 left a 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.

@flip1995
Copy link
Member

@bors rollup

@flip1995
Copy link
Member

Let's queue this

@bors r+

@bors
Copy link
Contributor

bors commented Dec 12, 2018

📌 Commit 194acaf has been approved by flip1995

bors added a commit that referenced this pull request Dec 12, 2018
…lip1995

Add suggestion for explicit_write lint

Closes #2083
@bors
Copy link
Contributor

bors commented Dec 12, 2018

⌛ Testing commit 194acaf with merge 7c823ca...

@bors
Copy link
Contributor

bors commented Dec 12, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: flip1995
Pushing 7c823ca to master...

@bors bors merged commit 194acaf into rust-lang:master Dec 12, 2018
@phansch phansch deleted the structured_sugg_for_explicit_write branch December 12, 2018 18:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants