diff options
| author | bravomikekilo <bmk1221@126.com> | 2019-07-31 22:56:12 +0800 |
|---|---|---|
| committer | bravomikekilo <bmk1221@126.com> | 2019-07-31 22:56:12 +0800 |
| commit | b12c20ccc30aebb2f5c90f04e2209ef12fe8b759 (patch) | |
| tree | 8df54a2759b254bafa16e883437af743d05c02cb | |
| parent | 4eeaaa722d6ac6d24de6e4d3faefb7c44e674b37 (diff) | |
| download | rust-b12c20ccc30aebb2f5c90f04e2209ef12fe8b759.tar.gz rust-b12c20ccc30aebb2f5c90f04e2209ef12fe8b759.zip | |
add a pair of whitespace after remove parentheses
| -rw-r--r-- | src/librustc_lint/unused.rs | 12 | ||||
| -rw-r--r-- | src/test/ui/lint/unused_parens_json_suggestion.stderr | 2 |
2 files changed, 11 insertions, 3 deletions
diff --git a/src/librustc_lint/unused.rs b/src/librustc_lint/unused.rs index 4cccaa942b7..9ef34c201e1 100644 --- a/src/librustc_lint/unused.rs +++ b/src/librustc_lint/unused.rs @@ -424,11 +424,19 @@ impl UnusedParens { }, _ => false, } - }).to_owned(); + }); + + let replace = { + let mut replace = String::from(" "); + replace.push_str(parens_removed); + replace.push(' '); + replace + }; + err.span_suggestion_short( span, "remove these parentheses", - parens_removed, + replace, Applicability::MachineApplicable, ); err.emit(); diff --git a/src/test/ui/lint/unused_parens_json_suggestion.stderr b/src/test/ui/lint/unused_parens_json_suggestion.stderr index 396395a17f7..54230b19cb4 100644 --- a/src/test/ui/lint/unused_parens_json_suggestion.stderr +++ b/src/test/ui/lint/unused_parens_json_suggestion.stderr @@ -81,7 +81,7 @@ } ], "label": null, - "suggested_replacement": "1 / (2 + 3)", + "suggested_replacement": " 1 / (2 + 3) ", "suggestion_applicability": "MachineApplicable", "expansion": null } |
