about summary refs log tree commit diff
path: root/clippy_lints/src/methods/expect_fun_call.rs
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-10-11 15:01:07 +0000
committerbors <bors@rust-lang.org>2024-10-11 15:01:07 +0000
commitb85f63260795be317af34e85ec645e69622bf4e3 (patch)
tree55cf2d0312a8a0dbf997500354573a03d6eccf40 /clippy_lints/src/methods/expect_fun_call.rs
parent6f1def79dd372e380357e1dfd2b8a54254ffe2d0 (diff)
parent8c46c498d9a575576d8d8106269cb549830ccf30 (diff)
Auto merge of #13528 - zvavybir:master, r=Alexendoo
Improved wording of or_fun_call lint

The current wording (e.g. ``use of `ok_or` followed by a function call``) is potentially confusing (at least it confused me) by suggesting that the function that follows the (in this case) `ok_or` is the problem and not the function that is an argument to it.

The code in my program that triggered the confusing message is the following:
```rust
let file_id = buf
    .lines()
    .next()
    .ok_or((
        InternalError::ProblemReadingFromInbox,
        anyhow!("No first line in inbox response ({file:?}): {buf:?}"),
    ))
    .html_context(stream, lang)?;
```
I thought that `html_context` was the problem and that I should do something along the following lines:
```rust
let file_id = buf
    .lines()
    .next()
    .ok_or_else(
        (
            InternalError::ProblemReadingFromInbox,
            anyhow!("No first line in inbox response ({file:?}): {buf:?}"),
        ),
        html_context(stream, lang),
    )?
```
This is of course wrong.  My confusion was only cleared up through the help message indicating what I should try instead.

If someone has a better idea of a replacement wording (currently e.g. ``` function call inside of `ok_or` ```), I'm all ears.

changelog: none
Diffstat (limited to 'clippy_lints/src/methods/expect_fun_call.rs')
-rw-r--r--clippy_lints/src/methods/expect_fun_call.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/clippy_lints/src/methods/expect_fun_call.rs b/clippy_lints/src/methods/expect_fun_call.rs
index 2922086522c..c288dbdabe9 100644
--- a/clippy_lints/src/methods/expect_fun_call.rs
+++ b/clippy_lints/src/methods/expect_fun_call.rs
@@ -143,7 +143,7 @@ pub(super) fn check<'tcx>(
                 cx,
                 EXPECT_FUN_CALL,
                 span_replace_word,
-                format!("use of `{name}` followed by a function call"),
+                format!("function call inside of `{name}`"),
                 "try",
                 format!("unwrap_or_else({closure_args} panic!({sugg}))"),
                 applicability,
@@ -161,7 +161,7 @@ pub(super) fn check<'tcx>(
         cx,
         EXPECT_FUN_CALL,
         span_replace_word,
-        format!("use of `{name}` followed by a function call"),
+        format!("function call inside of `{name}`"),
         "try",
         format!("unwrap_or_else({closure_args} {{ panic!(\"{{}}\", {arg_root_snippet}) }})"),
         applicability,