rust/tests
Samuel Tardieu 8d6de0b82e
Fix expect_fun_call producing invalid suggestions (#15122)
Previously expect_fun_call would too eagerly convert cases like
`foo.expect(if | block | match)` into `foo.unwrap_or_else`.
Additionally, it would also add to_string() even though the argument is
being passed into format!() which can accept a &str. I also discovered
some other cases where this lint would either produce invalid results,
or be triggered unnecessarily:

- Clippy would suggest changing expect to unwrap_or_else even if the
expression inside expect contains a return statement
- opt.expect(const_fn()) no longer triggers the lint
- The lint would always add braces to the closure body, even if the body
of expect is a single expression
- opt.expect({"literal"}) used to get turned into
```opt.unwrap_or_else(|| panic!("{}", {"literal"}.to_string()))```

Fixes rust-lang/rust-clippy#15056

changelog: [`expect_fun_call`]: fix expect_fun_call producing invalid
suggestions
2025-07-14 15:05:59 +00:00
..
test_utils
ui Fix expect_fun_call producing invalid suggestions (#15122) 2025-07-14 15:05:59 +00:00
ui-cargo Merge commit '9f9a822509' into clippy-subtree-update 2025-02-28 23:27:09 +01:00
ui-internal Merge commit '0450db33a5' into clippy-subtree-update 2025-05-15 19:28:39 +02:00
ui-toml Merge remote-tracking branch 'upstream/master' into rustup 2025-07-10 20:01:08 +02:00
workspace_test
check-fmt.rs
clippy.toml Merge commit '0621446356' into clippy-subtree-update 2025-04-22 18:24:43 +02:00
compile-test.rs use ui_test dependency builder for non-internal test dependencies 2025-07-01 13:27:49 +02:00
config-metadata.rs
dogfood.rs Merge commit 'c5dbd1de07' into clippy-subtree-update 2025-06-27 12:20:57 +02:00
integration.rs Merge commit '0450db33a5' into clippy-subtree-update 2025-05-15 19:28:39 +02:00
lint_message_convention.rs Merge commit '1e5237f4a5' into clippy-subtree-update 2025-03-20 22:34:29 +01:00
missing-test-files.rs
symbols-used.rs Merge commit '4ef75291b5' into clippy-subtree-update 2025-06-13 11:24:45 +02:00
versioncheck.rs Merge commit 'c5dbd1de07' into clippy-subtree-update 2025-06-27 12:20:57 +02:00
workspace.rs