-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Delete line if suggestion would replace it with an empty line #120305
Conversation
(rustbot has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
0daae5c
to
dc5a11b
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.
Although this is a way to address this specific issue, it might be a better idea to modify rustc_errors::json::DiagnosticSpan::from_span_full
to have this logic of checking "does this span end on the last char of a line, followed by \n
? if extend the span by one byte". Doing it there doesn't change how the diff is shown in diagnostics, but aids rustfix not have to care about this and doesn't require us to address these kind of spans in every suggestion we produce.
Doing that globally seems to break a lot of diff --git a/tests/ui/binop/false-binop-caused-by-missing-semi.fixed b/tests/ui/binop/false-binop-caused-by-missing-semi.fixed
index b47372c9064..441fad80c8f 100644
--- a/tests/ui/binop/false-binop-caused-by-missing-semi.fixed
+++ b/tests/ui/binop/false-binop-caused-by-missing-semi.fixed
@@ -3,8 +3,7 @@ fn foo() {}
fn main() {
let mut y = 42;
let x = &mut y;
- foo();
- *x = 0; //~ ERROR invalid left-hand side of assignment
+ foo(); *x = 0; //~ ERROR invalid left-hand side of assignment
let _ = x;
println!("{y}");
}
diff --git a/tests/ui/block-result/consider-removing-last-semi.fixed b/tests/ui/block-result/consider-removing-last-semi.fixed
index 36a769fe529..931a5440b79 100644
--- a/tests/ui/block-result/consider-removing-last-semi.fixed
+++ b/tests/ui/block-result/consider-removing-last-semi.fixed
@@ -2,19 +2,16 @@
pub fn f() -> String { //~ ERROR mismatched types
0u8;
- "bla".to_string()
-}
+ "bla".to_string()}
pub fn g() -> String { //~ ERROR mismatched types
"this won't work".to_string();
- "removeme".to_string()
-}
+ "removeme".to_string()}
pub fn macro_tests() -> u32 { //~ ERROR mismatched types
macro_rules! mac {
() => (1);
}
- mac!()
-}
+ mac!()}``` |
@clubby789 what happens if you only do the span extension if the replacement is ""? An alternative heuristic could be to see if the start column is 0 as well... |
dc5a11b
to
0b70810
Compare
unused_import
fix if there is nothing else
Catches a lot more cases 👀 Good idea! |
This comment has been minimized.
This comment has been minimized.
0b70810
to
ea18259
Compare
Actually this could do with some improvement |
This comment has been minimized.
This comment has been minimized.
ea18259
to
a1eda8f
Compare
This comment has been minimized.
This comment has been minimized.
a1eda8f
to
799a810
Compare
Some changes occurred in src/tools/clippy cc @rust-lang/clippy |
☔ The latest upstream changes (presumably #121810) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
please rebase and I'll approve
799a810
to
367126d
Compare
@rustbot ready |
@bors r+ |
…iaskrgr Rollup of 11 pull requests Successful merges: - rust-lang#111505 (Made `INVALID_DOC_ATTRIBUTES` lint deny by default) - rust-lang#120305 (Delete line if suggestion would replace it with an empty line) - rust-lang#121153 (Suggest removing superfluous semicolon when statements used as expression) - rust-lang#121497 (`-Znext-solver=coherence`: suggest increasing recursion limit) - rust-lang#121634 (Clarify behavior of slice prefix/suffix operations in case of equality) - rust-lang#121706 (match lowering: Remove hacky branch in sort_candidate) - rust-lang#121730 (Add profiling support to AIX) - rust-lang#121750 (match lowering: Separate the `bool` case from other integers in `TestKind`) - rust-lang#121803 (Never say "`Trait` is implemented for `{type error}`") - rust-lang#121811 (Move sanitizer ui tests to sanitizer directory) - rust-lang#121824 (Implement missing ABI structures in StableMIR) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#120305 - clubby789:unused-import-line, r=estebank Delete line if suggestion would replace it with an empty line Fixes rust-lang#120296
Fixes #120296