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

Clippy subtree update #129991

Closed
wants to merge 54 commits into from
Closed

Conversation

flip1995
Copy link
Member

@flip1995 flip1995 commented Sep 5, 2024

r? @Manishearth

Cargo.lock update due to Clippy version bump.

nyurik and others added 30 commits July 16, 2024 18:00
When a user explicitly tags a param as unused (yet?), there is no need to raise another lint on it.
…times, r=cjgillot

Fix `elided_named_lifetimes` in code

rust-lang#129207 (comment)

r? cjgillot
…ng_sub_expression, r=xFrednet

Diverging subexpression lint should not fire on todo!()

As per rust-lang#10243  it is not that helpful to point out that a subexpression diverges, so do not fire on todo

changelog: [`diverging_sub_expression`]: do not trigger on todo
Clippy subtree update

r? `@Manishearth`
…blyxyas

Ignore underscore-prefixed args for needless_pass_by_value lint

When a user explicitly tags a param as unused (yet?), there is no need to raise another lint on it.

fixes rust-lang#7295

Note that I had to rename all `_*` params in the tests, but kept the variable name length to avoid extra changes in the expected output.

changelog: [`needless_pass_by_value`]: do not warn if the argument name starts with an `_`
…=dswij

Rewrite `empty_line_after_doc_comments` and `empty_line_after_outer_attr`, move them from `nursery` to `suspicious`

changelog: [`empty_line_after_doc_comments`], [`empty_line_after_outer_attr`]: rewrite and move them from `nursery` to `suspicious`

They now lint when there's a comment between the last attr/doc comment and the empty line, to cover the case:

```rust
/// Docs for `old_code
// fn old_code() {}

fn new_code() {}
```

When these lints or `suspicious_doc_comments` trigger we no longer trigger any other doc lint as a broad fix for rust-lang#12917, reverts some of rust-lang#13002 as the empty line lints cover it

I ended up not doing rust-lang/rust-clippy#12917 (comment) as I don't think it's needed
check std::panic::panic_any in panic lint

close rust-lang#13292
This PR detects `std::panic::panic_any` in panic lint.

changelog: check std::panic::panic_any in panic lint
…ns, r=Manishearth

Fix manual_range_patterns case with one element at OR

Close rust-lang#11825
As mentioned rust-lang#11825 `OR` can be used for stylistic purposes with one element, we can filter this case from triggering lint

changelog: [`manual_range_patterns`]: not trigger when `OR` has only one element
…e_items, r=llogiq

Add new lint: `used_underscore_items`

Closes rust-lang#13260

---

changelog: new [`used_underscore_items`] lint against using items with a single leading underscore
new lint: `zombie_processes`

Closes rust-lang#10754

Lint description should explain this PR, so I think there's nothing else to say here ^^

changelog: new lint: [`zombie_processes`]
Use `is_diagnostic_item` for checking a def_id in `unnecessary_min_or_max`.

close rust-lang#13191
This PR fixes the false positives in `unnecessary_min_or_max `.
We should use `is_diagnostic_item` for checking def_ids in this lint.

----

changelog: fix false positive in `unnecessary_min_or_max `.
…ature, r=flip1995

Remove `feature=cargo-clippy` argument

Roses are red,
Violets are blue,
Fixme was written,
And now it's due

---

changelog: **Important Change** Removed the implicit `cargo-clippy` feature set by Clippy as announced here: <https://blog.rust-lang.org/2024/02/28/Clippy-deprecating-feature-cargo-clippy.html>
[rust-lang#13246](rust-lang/rust-clippy#13246)

Follow-up of: rust-lang/rust-clippy#12292

r? `@flip1995`

cc: `@GuillaumeGomez`
GuillaumeGomez and others added 20 commits August 31, 2024 16:24
…check, r=y21

Extend `implicit_saturating_sub` lint

Fixes rust-lang#10070.

It can serve as base if we want to add equivalent checks for other arithmetic operations.

Also one important note: when writing this lint, I realized that I could check for wrong conditions performed beforehand on subtraction and added another part in the lint. Considering they both rely on the same checks, I kept both in the same place. Not sure if it makes sense though...

changelog: Extend `implicit_saturating_sub` lint
…gillot

Lint that warns when an elided lifetime ends up being a named lifetime

As suggested in rust-lang#48686 (comment)

Fixes rust-lang#48686
…oc_fix, r=y21

Provide more clear example for `WRONG_SELF_CONVENTION`

Provide more clear example for `WRONG_SELF_CONVENTION`

changelog: none
Add new check for passing pointers to an `asm!` block with `nomem` option

changelog: Add new check for passing pointers to an `asm!` block with `nomem` option

Continuing work from rust-lang#127063
…tri3

move `manual_c_str_literals` to complexity

IMO the suggestion to use `c""` literals over a hardcoded `\0` byte string literal has some fairly strong upsides (no need to manually null-terminate it and the compiler checks for intermediary null bytes) that this should just be enabled by default.

It's also written slightly conservatively to only emit a warning when we can be reasonably confident that the lint is *actually* applicable (that is, lint on e.g. `b"foo\0".as_ptr()` but not `b"foo\0"`. The latter looks like a c-string but its type is `&[u8; _]`, and if it's used in a context where a byte slice is needed then you have no nice way to convert to it from a `c"foo"` literal of type `&CStr`).

changelog: move [`manual_c_str_literals`] to complexity (now warn-by-default)
Minor code simplification

changelog: none
…lip1995

Bump actions/download-artifact from 3 to 4

r? `@ghost`

changelog: none
Changelog for Clippy 1.81 🔰

Roses are red,
Violets are blue,
Expectations are stable,
And reasons are set

---

### The cat of this release is *Keepy* submitted by `@blyxyas:`

<img height=500 src="https://github.com/rust-lang/rust-clippy/assets/73757586/902dd802-5ac8-471e-bb93-e195526ba580" alt="The cats of this Clippy release" />

Cats for the next release can be nominated in the comments :D

---

changelog: none
@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 5, 2024
@rustbot
Copy link
Collaborator

rustbot commented Sep 5, 2024

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-tools failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
assertion failed: progress.is_finished()
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

FAILED TEST: tests/ui/empty_line_after/doc_comments.rs
command: CLIPPY_CONF_DIR="tests" RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "--error-format=json" "--emit=metadata" "-Aunused" "-Ainternal_features" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Dwarnings" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "--extern=clippy_config=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_config-850ab2d85dd88286.rlib" "--extern=clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-aa9c7de2eb3a9515.rlib" "--extern=clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-3fed604bcd69fad6.rlib" "--extern=futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-014329971e659014.rlib" "--extern=if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-49fd91c51cbf146b.rlib" "--extern=itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-a4b4cb2e17d4d2b3.rlib" "--extern=parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-608416dfddef6875.rlib" "--extern=quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-c813e0e7f4f9d2ff.rlib" "--extern=regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-ad85a18b6c78c875.rlib" "--extern=serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-67d93c74d46e97d4.rlib" "--extern=serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libserde_derive-d1700cdd722b1862.so" "--extern=syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-65f69184e16d38fe.rlib" "--extern=tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-f492a0afd48fb163.rlib" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui_test/tests/ui/empty_line_after" "tests/ui/empty_line_after/doc_comments.rs" "--edition" "2021"
error: actual output differed from expected
Execute `cargo uibless` to update `tests/ui/empty_line_after/doc_comments.stderr` to the actual output
--- tests/ui/empty_line_after/doc_comments.stderr
+++ <stderr output>
+++ <stderr output>
-error: empty line after doc comment
+thread 'rustc' panicked at /checkout/compiler/rustc_errors/src/diagnostic.rs:927:9:
-  --> tests/ui/empty_line_after/doc_comments.rs:6:1
+assertion `left == right` failed: Span must not be empty and have no suggestion
-   |
+  left: Some(SubstitutionPart { span: tests/ui/empty_line_after/doc_comments.rs:7:1: 7:1 (#0), snippet: "" })
+ right: None
-LL | |
+stack backtrace:
-   | |_
-   | |_
+   0:     0x7fdf23386571 - <<std[f2614f31225da369]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[12987377804e0c64]::fmt::Display>::fmt
-LL |   fn first_in_crate() {}
+   1:     0x7fdf233e23f0 - core[12987377804e0c64]::fmt::write
+   2:     0x7fdf23379869 - <std[f2614f31225da369]::sys::pal::unix::stdio::Stderr as std[f2614f31225da369]::io::Write>::write_fmt
-   |
+   3:     0x7fdf23386412 - <std[f2614f31225da369]::sys::backtrace::BacktraceLock>::print
-   = note: `-D clippy::empty-line-after-doc-comments` implied by `-D warnings`
-   = note: `-D clippy::empty-line-after-doc-comments` implied by `-D warnings`
+   4:     0x7fdf2338900a - std[f2614f31225da369]::panicking::default_hook::{closure#1}
-   = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_doc_comments)]`
+   5:     0x7fdf23388d9d - std[f2614f31225da369]::panicking::default_hook
-   = help: if the empty line is unintentional remove it
+   6:     0x7fdf1ec48542 - <alloc[5ca9042bc80d3eaa]::boxed::Box<rustc_driver_impl[478ad758e53a618b]::install_ice_hook::{closure#0}> as core[12987377804e0c64]::ops::function::Fn<(&dyn for<'a, 'b> core[12987377804e0c64]::ops::function::Fn<(&'a std[f2614f31225da369]::panic::PanicHookInfo<'b>,), Output = ()> + core[12987377804e0c64]::marker::Sync + core[12987377804e0c64]::marker::Send, &std[f2614f31225da369]::panic::PanicHookInfo)>>::call
-help: if the comment should document the crate use an inner doc comment
+   7:     0x7fdf23389908 - std[f2614f31225da369]::panicking::rust_panic_with_hook
+   8:     0x7fdf2338962b - std[f2614f31225da369]::panicking::begin_panic_handler::{closure#0}
+   8:     0x7fdf2338962b - std[f2614f31225da369]::panicking::begin_panic_handler::{closure#0}
-LL ~ //! Meant to be an
+   9:     0x7fdf23386bc9 - std[f2614f31225da369]::sys::backtrace::__rust_end_short_backtrace::<std[f2614f31225da369]::panicking::begin_panic_handler::{closure#0}, !>
-LL ~ //! inner doc comment
+  10:     0x7fdf23389234 - rust_begin_unwind
-LL ~ //! for the crate
-   |
+  12:     0x7fdf233de7c6 - core[12987377804e0c64]::panicking::assert_failed_inner
 
-error: empty line after doc comment
-error: empty line after doc comment
+error: the compiler unexpectedly panicked. this is a bug.
 
-error: empty line after doc comment
+note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml
-error: empty line after doc comment
+note: please make sure that you have updated to the latest nightly
 
-error: empty lines after doc comment
---
-
-error: empty line after doc comment
-  --> tests/ui/empty_line_after/doc_comments.rs:85:5
-   |
-LL | /     /**
-LL | |      * Docs for `old_code`
-LL | |      */
-LL | |     /* fn old_code() {} */
-   | |_
-...
-LL |       fn new_code() {}
-   |       ------------- the comment documents this function
---
-
-error: empty line after doc comment
-  --> tests/ui/empty_line_after/doc_comments.rs:96:5
-   |
-LL | /     /// Docs for `old_code2`
-LL | |     /* fn old_code2() {} */
-   | |_
-LL |       /// Docs for `new_code2`
-LL |       fn new_code2() {}
-   |       -------------- the comment documents this function
---

error: diagnostic code `clippy::empty_line_after_doc_comments` not found on line 6
##[error] --> tests/ui/empty_line_after/doc_comments.rs:3:8
  |
3 | //~vvv empty_line_after_doc_comments
  |

error: diagnostic code `clippy::empty_line_after_doc_comments` not found on line 14
##[error]  --> tests/ui/empty_line_after/doc_comments.rs:11:12
##[error]  --> tests/ui/empty_line_after/doc_comments.rs:11:12
   |
11 |     //~vvv empty_line_after_doc_comments
   |

error: diagnostic code `clippy::empty_line_after_doc_comments` not found on line 27
##[error]  --> tests/ui/empty_line_after/doc_comments.rs:26:10
---

error: diagnostic code `clippy::empty_line_after_doc_comments` not found on line 34
##[error]  --> tests/ui/empty_line_after/doc_comments.rs:33:6
   |
33 | //~v empty_line_after_doc_comments
   |

error: diagnostic code `clippy::empty_line_after_doc_comments` not found on line 44
##[error]  --> tests/ui/empty_line_after/doc_comments.rs:43:6
##[error]  --> tests/ui/empty_line_after/doc_comments.rs:43:6
   |
43 | //~v empty_line_after_doc_comments
   |

error: diagnostic code `clippy::empty_line_after_doc_comments` not found on line 56
##[error]  --> tests/ui/empty_line_after/doc_comments.rs:55:10
---

error: diagnostic code `clippy::empty_line_after_doc_comments` not found on line 63
##[error]  --> tests/ui/empty_line_after/doc_comments.rs:61:11
   |
61 |     //~vv empty_line_after_doc_comments
   |

error: diagnostic code `clippy::empty_line_after_doc_comments` not found on line 78
##[error]  --> tests/ui/empty_line_after/doc_comments.rs:77:10
---
   |


FAILED TEST: tests/ui/empty_line_after/outer_attribute.rs
command: CLIPPY_CONF_DIR="tests" RUSTC_ICE="0" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/clippy-driver" "--error-format=json" "--emit=metadata" "-Aunused" "-Ainternal_features" "-Zui-testing" "-Zdeduplicate-diagnostics=no" "-Dwarnings" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps" "--extern=clippy_config=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_config-850ab2d85dd88286.rlib" "--extern=clippy_lints=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_lints-aa9c7de2eb3a9515.rlib" "--extern=clippy_utils=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libclippy_utils-3fed604bcd69fad6.rlib" "--extern=futures=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libfutures-014329971e659014.rlib" "--extern=if_chain=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libif_chain-49fd91c51cbf146b.rlib" "--extern=itertools=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libitertools-a4b4cb2e17d4d2b3.rlib" "--extern=parking_lot=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libparking_lot-608416dfddef6875.rlib" "--extern=quote=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libquote-c813e0e7f4f9d2ff.rlib" "--extern=regex=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libregex-ad85a18b6c78c875.rlib" "--extern=serde=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libserde-67d93c74d46e97d4.rlib" "--extern=serde_derive=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib/libserde_derive-d1700cdd722b1862.so" "--extern=syn=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libsyn-65f69184e16d38fe.rlib" "--extern=tokio=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/deps/libtokio-f492a0afd48fb163.rlib" "-Ldependency=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/release/deps" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui_test/tests/ui/empty_line_after" "tests/ui/empty_line_after/outer_attribute.rs" "--extern" "proc_macro_attr=/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui_test/tests/ui/auxiliary/libproc_macro_attr.so" "-L" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/ui_test/tests/ui/auxiliary" "--edition" "2021"
error: actual output differed from expected
Execute `cargo uibless` to update `tests/ui/empty_line_after/outer_attribute.stderr` to the actual output
--- tests/ui/empty_line_after/outer_attribute.stderr
+++ <stderr output>
+++ <stderr output>
-error: empty line after outer attribute
+thread 'rustc' panicked at /checkout/compiler/rustc_errors/src/diagnostic.rs:927:9:
-  --> tests/ui/empty_line_after/outer_attribute.rs:5:1
+assertion `left == right` failed: Span must not be empty and have no suggestion
-   |
+  left: Some(SubstitutionPart { span: tests/ui/empty_line_after/outer_attribute.rs:6:1: 6:1 (#0), snippet: "" })
-LL | / #[crate_type = "lib"]
+ right: None
+stack backtrace:
-   | |_
-   | |_
+   0:     0x7f2963af7571 - <<std[f2614f31225da369]::sys::backtrace::BacktraceLock>::print::DisplayBacktrace as core[12987377804e0c64]::fmt::Display>::fmt
-LL |   fn first_in_crate() {}
+   1:     0x7f2963b533f0 - core[12987377804e0c64]::fmt::write
-   |   ------------------- the attribute applies to this function
+   2:     0x7f2963aea869 - <std[f2614f31225da369]::sys::pal::unix::stdio::Stderr as std[f2614f31225da369]::io::Write>::write_fmt
+   3:     0x7f2963af7412 - <std[f2614f31225da369]::sys::backtrace::BacktraceLock>::print
-   = note: `-D clippy::empty-line-after-outer-attr` implied by `-D warnings`
+   4:     0x7f2963afa00a - std[f2614f31225da369]::panicking::default_hook::{closure#1}
-   = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_outer_attr)]`
-   = help: to override `-D warnings` add `#[allow(clippy::empty_line_after_outer_attr)]`
+   5:     0x7f2963af9d9d - std[f2614f31225da369]::panicking::default_hook
-   = help: if the empty line is unintentional remove it
+   6:     0x7f295f3b9542 - <alloc[5ca9042bc80d3eaa]::boxed::Box<rustc_driver_impl[478ad758e53a618b]::install_ice_hook::{closure#0}> as core[12987377804e0c64]::ops::function::Fn<(&dyn for<'a, 'b> core[12987377804e0c64]::ops::function::Fn<(&'a std[f2614f31225da369]::panic::PanicHookInfo<'b>,), Output = ()> + core[12987377804e0c64]::marker::Sync + core[12987377804e0c64]::marker::Send, &std[f2614f31225da369]::panic::PanicHookInfo)>>::call
-help: if the attribute should apply to the crate use an inner attribute
+   7:     0x7f2963afa908 - std[f2614f31225da369]::panicking::rust_panic_with_hook
+   8:     0x7f2963afa62b - std[f2614f31225da369]::panicking::begin_panic_handler::{closure#0}
-LL | #![crate_type = "lib"]
-LL | #![crate_type = "lib"]
+   9:     0x7f2963af7bc9 - std[f2614f31225da369]::sys::backtrace::__rust_end_short_backtrace::<std[f2614f31225da369]::panicking::begin_panic_handler::{closure#0}, !>
+  10:     0x7f2963afa234 - rust_begin_unwind
 
-error: empty line after outer attribute
+error: the compiler unexpectedly panicked. this is a bug.
+error: the compiler unexpectedly panicked. this is a bug.
 
-error: empty line after outer attribute
+note: we would appreciate a bug report: https://github.com/rust-lang/rust-clippy/issues/new?template=ice.yml
-error: empty lines after outer attribute
+note: please make sure that you have updated to the latest nightly
 
-error: empty line after outer attribute
---

error: diagnostic code `clippy::empty_line_after_outer_attr` not found on line 5
##[error] --> tests/ui/empty_line_after/outer_attribute.rs:4:6
  |
4 | //~v empty_line_after_outer_attr
  |

error: diagnostic code `clippy::empty_line_after_outer_attr` not found on line 13
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:12:6
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:12:6
   |
12 | //~v empty_line_after_outer_attr
   |

error: diagnostic code `clippy::empty_line_after_outer_attr` not found on line 23
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:22:6
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:22:6
   |
22 | //~v empty_line_after_outer_attr
   |

error: diagnostic code `clippy::empty_line_after_outer_attr` not found on line 30
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:29:10
---

error: diagnostic code `clippy::empty_line_after_outer_attr` not found on line 37
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:36:6
   |
36 | //~v empty_line_after_outer_attr
   |

error: diagnostic code `clippy::empty_line_after_outer_attr` not found on line 45
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:44:6
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:44:6
   |
44 | //~v empty_line_after_outer_attr
   |

error: diagnostic code `clippy::empty_line_after_outer_attr` not found on line 53
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:52:6
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:52:6
   |
52 | //~v empty_line_after_outer_attr
   |

error: diagnostic code `clippy::empty_line_after_outer_attr` not found on line 58
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:57:6
##[error]  --> tests/ui/empty_line_after/outer_attribute.rs:57:6
   |
57 | //~v empty_line_after_outer_attr
   |

FAILURES:
    tests/ui/empty_line_after/doc_comments.rs

@Manishearth
Copy link
Member

CI broken

Comment on lines +231 to +236
diag.multipart_suggestion_with_style(
format!("if the empty {lines} {are} unintentional remove {them}"),
empty_lines().map(|empty_line| (empty_line, String::new())).collect(),
Applicability::MaybeIncorrect,
SuggestionStyle::HideCodeAlways,
);
Copy link
Member Author

Choose a reason for hiding this comment

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

This triggers the debug assertion that in a multipart suggestion, one part can't be and empty span and at the same time suggest to remove it.

I think a possible fix would be to change this code to a span_suggestion and build a span from first_gap.prev_stop.span.hi to empty_lines().last().hi or something like that. I tried it, but ran into off-by-one errors...

@Alexendoo do you have time to take a look at this? You can reproduce locally by setting debug-assertions = true in [rust] in the config.toml.

Copy link
Member Author

@flip1995 flip1995 Sep 13, 2024

Choose a reason for hiding this comment

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

@estebank What is the best way to suggest removing non contiguous empty lines. I.e.

1 /// Comment that should stay
2 
3 // More things that should stay
4 
5 struct X;

The empty_lines() functions returns the spans of lines 2 and 4 which should be removed, but their spans are 2:1-2:1 and 4:1-4:1, so considered empty spans. rustfix has no problem applying this suggestion, while the debug_assertion causes the failure in CI. Is there a better way to suggest removing those empty lines, than the above? If not, should the debug_assertion in the multipart_suggestion implementation be relaxed?

Copy link
Member

@y21 y21 Sep 13, 2024

Choose a reason for hiding this comment

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

If the suggestion is to remove a line, shouldn't the spans be 2:1-3:1 and 4:1-5:1? An empty span wouldn't include the newline character at 2:1, would it? 🤔
I'm surprised rustfix can fix it with no problem

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried adding a BytePos(1) to the span. But then the spans overlap (for 2 contiguous empty lines), as the first span is 2:1-3:1 and the next span is 3:1-4:1 with an overlap at 3:1. And rustfix can't apply multipart suggestions with overlapping spans.

Copy link
Member Author

Choose a reason for hiding this comment

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

Will be fixed in rust-lang/rust-clippy#13439

Since we already behind the sync after this one by 3 days, I will open a new PR for it.

@bors
Copy link
Contributor

bors commented Sep 19, 2024

☔ The latest upstream changes (presumably #130572) made this pull request unmergeable. Please resolve the merge conflicts.

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.