Skip to content

get_unwrap is questionable advice #3862

Closed
@joshlf

Description

@joshlf

The get_unwrap lint suggests replacing x.get(y).unwrap() with x[y]. IMO, this is bad advice because the former syntax makes it clear that there's a risk of a panic, while the latter looks innocuous. It's generally good to be aware of where panics can happen. It's especially true when processing untrusted input, where a panic caused by user input is a Denial-of-Service vulnerability.

I propose that we make this lint non-default at the least, and possibly consider removing it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions