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

manual_unwrap_or is not showing for simple ref cases #11795

Open
nyurik opened this issue Nov 12, 2023 · 1 comment
Open

manual_unwrap_or is not showing for simple ref cases #11795

nyurik opened this issue Nov 12, 2023 · 1 comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't

Comments

@nyurik
Copy link
Contributor

nyurik commented Nov 12, 2023

Summary

This case is not detected. I suspect this is due to the initial fix for #7228 (?).

Lint Name

manual_unwrap_or

Reproducer

I tried this code:

fn test_func(val: Option<&str>) -> String {
    let s = match val {
        None => "",
        Some(v) => v,
    };
    s.to_string()
}

I expected to see this happen: a warning to simplify the match statement to use unwrap_or

Instead, this happened: no warnings

Version

rustc 1.73.0 (cc66ad468 2023-10-03)
binary: rustc
commit-hash: cc66ad468955717ab92600c770da8c1601a4ff33
commit-date: 2023-10-03
host: x86_64-unknown-linux-gnu
release: 1.73.0
LLVM version: 17.0.2
@nyurik nyurik added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Nov 12, 2023
@nyurik
Copy link
Contributor Author

nyurik commented Nov 12, 2023

P.S. Note that the above could also be solved with unwrap_or_default()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't
Projects
None yet
Development

No branches or pull requests

1 participant