Skip to content

False positive?: get_unwrap #1725

Open
Open
@Thinkofname

Description

@Thinkofname

Link to example: http://play.integer32.com/?gist=2d02b966174279055a9519a5f3182a7d&version=undefined

warning: called `.get().unwrap()` on a HashMap. Using `[]` is more clear and more concise
  --> src/main.rs:24:9
   |
24 |         data.data.get(&key).unwrap().clone()
   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try this `&data.data[&key]`
   |
   = note: #[warn(get_unwrap)] on by default
   = help: for further information visit https://github.com/Manishearth/rust-clippy/wiki#get_unwrap

Honestly seems like the suggested change should work but lifetimes seem to prevent it. Might be because Index and get take slightly different parameter types?

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work onI-false-positiveIssue: The lint was triggered on code it shouldn't haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when appliedT-middleType: Probably requires verifiying types

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions