bevy/crates/bevy_tasks/src
BD103 bc98333d7c
Fix a few Clippy lints (#11866)
# Objective

- The current implementations for `&Visibility == Visibility` and
`Visibility == &Visibility` are ambiguous, so they raise a warning for
being unconditionally recursive.
- `TaskPool`'s `LOCAL_EXECUTOR` thread local calls a `const` constructor
in a non-`const` context.

## Solution

- Make `&Visibility == Visibility` and `Visibility == &Visibility`
implementations use `Visibility == Visibility`.
- Wrap `LocalExecutor::new` in a special `const` block supported by
[`thread_local`](https://doc.rust-lang.org/stable/std/macro.thread_local.html).

---

This lints were found by running:

```shell
$ cargo clippy --workspace
```

There are a few other warnings that were more complicated, so I chose
not to include them in this PR.

<details>
  <summary>Here they are...</summary>

```shell
warning: function cannot return without recursing
  --> crates/bevy_utils/src/cow_arc.rs:92:5
   |
92 | /     fn eq(&self, other: &Self) -> bool {
93 | |         self.deref().eq(other.deref())
94 | |     }
   | |_____^
   |
note: recursive call site
  --> crates/bevy_utils/src/cow_arc.rs:93:9
   |
93 |         self.deref().eq(other.deref())
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

warning: method `get_path` is never used
  --> crates/bevy_reflect/src/serde/de.rs:26:8
   |
25 | trait StructLikeInfo {
   |       -------------- method in this trait
26 |     fn get_path(&self) -> &str;
   |        ^^^^^^^^
   |
   = note: `#[warn(dead_code)]` on by default

warning: methods `get_path` and `get_field` are never used
  --> crates/bevy_reflect/src/serde/de.rs:34:8
   |
33 | trait TupleLikeInfo {
   |       ------------- methods in this trait
34 |     fn get_path(&self) -> &str;
   |        ^^^^^^^^
35 |     fn get_field(&self, index: usize) -> Option<&UnnamedField>;
   |        ^^^^^^^^^
```

The other warnings are fixed by #11865.

</details>
2024-02-14 19:07:18 +00:00
..
iter Remove unnecessary path prefixes (#10749) 2023-11-28 23:43:40 +00:00
lib.rs Immediately poll the executor once before spawning it as a task (#11801) 2024-02-12 15:33:35 +00:00
single_threaded_task_pool.rs Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
slice.rs Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
task.rs Improve doc formatting. (#9840) 2023-09-18 19:43:56 +00:00
task_pool.rs Fix a few Clippy lints (#11866) 2024-02-14 19:07:18 +00:00
thread_executor.rs Replace or document ignored doctests (#11040) 2024-01-01 16:50:56 +00:00
usages.rs Global TaskPool API improvements (#10008) 2023-10-23 20:48:48 +00:00