rust/tests
bors 7a34143fa3 Auto merge of #11135 - smoelius:unwrap_or_else_default-fp, r=Centri3
Fix `unwrap_or_else_default` false positive

This PR fixes a false positive in the handling of `unwrap_or_else` with a default value when the value is needed for type inference.

An easy example to exhibit the false positive is the following:
```rust
    let option = None;
    option.unwrap_or_else(Vec::new).push(1);
```
The following code would not compile, because the fact that the value is a `Vec` has been lost:
```rust
    let option = None;
    option.unwrap_or_default().push(1);
```
The fix is to:
- implement a heuristic to tell whether an expression's type can be determined purely from its subexpressions, and the arguments and locals they use;
- apply the heuristic to `unwrap_or_else`'s receiver.

The heuristic returns false when applied to `option` in the above example, but it returns true when applied to `option` in either of the following examples:
```rust
    let option: Option<Vec<u64>> = None;
    option.unwrap_or_else(Vec::new).push(1);
```
```rust
    let option = None::<Vec<u64>>;
    option.unwrap_or_else(Vec::new).push(1);
```

(Aside: https://github.com/rust-lang/rust-clippy/pull/10120 unfairly contained multiple changes in one PR. I am trying to break that PR up into smaller pieces.)

---

changelog: FP: [`unwrap_or_else_default`]: No longer lints if the default value is needed for type inference
2023-07-19 11:37:30 +00:00
..
test_utils Revert "Dogfood missing_assert_message on Clippy" 2023-03-08 08:51:50 +00:00
ui Auto merge of #11135 - smoelius:unwrap_or_else_default-fp, r=Centri3 2023-07-19 11:37:30 +00:00
ui-cargo Remove unused flags from ui-cargo tests 2023-07-18 18:46:09 +00:00
ui-internal clippy-driver: Update bug URL to use the ice template 2023-07-16 11:51:01 +02:00
ui-toml Add imports_granularity = "Module" to rustfmt.toml 2023-07-13 12:44:57 +00:00
workspace_test Merge commit '37f4c1725d' into clippyup 2023-07-02 14:59:02 +02:00
check-fmt.rs Merge commit 'f51aade56f' into clippyup 2022-08-31 09:24:45 -04:00
clippy.toml
compile-test.rs Merge remote-tracking branch 'upstream/master' into rustup 2023-07-14 13:36:16 +02:00
dogfood.rs Merge commit '371120bdbf' into clippyup 2023-05-05 17:45:49 +02:00
headers.rs Merge commit '37f4c1725d' into clippyup 2023-07-02 14:59:02 +02:00
integration.rs Revert "Dogfood missing_assert_message on Clippy" 2023-03-08 08:51:50 +00:00
lint_message_convention.rs Merge commit '37f4c1725d' into clippyup 2023-07-02 14:59:02 +02:00
missing-test-files.rs Merge commit '37f4c1725d' into clippyup 2023-07-02 14:59:02 +02:00
versioncheck.rs Merge commit '4bdfb0741d' into clippyup 2022-12-17 14:12:54 +01:00
workspace.rs Merge commit '37f4c1725d' into clippyup 2023-07-02 14:59:02 +02:00