Skip to content
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

Different trade-offs for or_fun_call false positives #12724

Open
kornelski opened this issue Apr 27, 2024 · 0 comments
Open

Different trade-offs for or_fun_call false positives #12724

kornelski opened this issue Apr 27, 2024 · 0 comments
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages

Comments

@kornelski
Copy link
Contributor

Description

I'm seeing the or_fun_call lint complain about use of methods that are cheap (e.g. vec.first(), x.as_ref().and_then(…), x.unwrap_or("str"), "".as_ref(), x.unwrap_or(Path::new(""))).

I've searched previous discussions about this lint, and it seems that various heuristics for detecting cheap methods were rejected, because sometimes there are edge cases that might be expensive.

Could there be another lint, or a setting for this lint, that changes the policy from warning just in case to warning only about methods that are actually known to have non-trivial cost? (prefer false negatives over false positives)

Version

rustc 1.79.0-nightly (3a36386dc 2024-04-25)
binary: rustc
commit-hash: 3a36386dc1075018dc7ca2640a2656adb31a61fe
commit-date: 2024-04-25
host: aarch64-apple-darwin
release: 1.79.0-nightly
LLVM version: 18.1.4

Additional Labels

No response

@J-ZhengLi J-ZhengLi added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label May 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages
Projects
None yet
Development

No branches or pull requests

2 participants