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

Missing Entry::or_default on LinearMap #11355

Closed
dhardy opened this issue Aug 19, 2023 · 1 comment · Fixed by #11359
Closed

Missing Entry::or_default on LinearMap #11355

dhardy opened this issue Aug 19, 2023 · 1 comment · Fixed by #11359
Labels
C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have

Comments

@dhardy
Copy link

dhardy commented Aug 19, 2023

Summary

Lint unwrap_or_default suggests use of or_default with LinearMap::Entry which does not support this method.

It may be easier to add the method to linear-map, but the crate is in maintenance-only mode.

Lint Name

unwrap_or_default

Reproducer

let mut map = LinaerMap::new();
map.entry("x").or_insert_with(Default::default);

Version

No response

Additional Labels

No response

@dhardy dhardy added C-bug Category: Clippy is not doing the correct thing I-false-positive Issue: The lint was triggered on code it shouldn't have labels Aug 19, 2023
@Centri3
Copy link
Member

Centri3 commented Aug 19, 2023

We could fix this by using associated_value on FnCtxt, or perhaps the associated_item query (but this works on the impl level, not the type), then checking if or_default exists.

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-positive Issue: The lint was triggered on code it shouldn't have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants