Skip to content

or_fun_call: also lint and method for Option/Result #15073

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

Merged
merged 2 commits into from
Jul 6, 2025

Conversation

klensy
Copy link
Contributor

@klensy klensy commented Jun 18, 2025

build on top of #15071

This also adds ability to lint Option/Result::and method. Yes, this is not or method, but uses the same eager/lazy linting logic. Should i update lint description to list all checked structs/methods?

changelog: [or_fun_call]: lint Option/Result::and

@klensy klensy force-pushed the or-fun-call-and branch from d27ea09 to a82c142 Compare June 21, 2025 09:43
@klensy klensy marked this pull request as ready for review June 21, 2025 09:44
@rustbot
Copy link
Collaborator

rustbot commented Jun 21, 2025

r? @llogiq

rustbot has assigned @llogiq.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jun 21, 2025
Copy link
Contributor

@llogiq llogiq left a comment

Choose a reason for hiding this comment

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

This looks good, but at this point we might think about renaming the lint, it's far more applicable than when it was initially named.

That can be a followup PR though.

@llogiq llogiq added this pull request to the merge queue Jul 6, 2025
Merged via the queue into rust-lang:master with commit c943f4c Jul 6, 2025
13 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties label Jul 6, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jul 10, 2025
<strike>blocked on #15073</strike>

Lint method calls inside `map_or` too, so for this, lint will be showed:
```rust
Some(4).map_or("asd".to_string().len() as i32, f);
```
previously it worked only for:
```rust
Some(4).map_or(slow_fun(), f);
```

https://play.rust-lang.org/?version=nightly&mode=debug&edition=2024&gist=bfcda42a6af446e69bc883a8b45eb13c

Sorry for multiple `or_fun_call` PRs.

changelog: [`or_fun_call`]: lint method calls inside map_or first arg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants