Skip to content

Suggest LOCALHOST #14819

Closed
Closed
@Rudxain

Description

@Rudxain

What it does

If it finds a hard-coded IP address that's identical to the corresponding std::net::Ipv{4,6}Addr::LOCALHOST, then it suggests replacing it by the associated constant. This should be auto-fixable as it's MachineApplicable

Advantage

Clarity

Drawbacks

Cognitive indirection? For a reader to see the actual IP address, they have to find the const definition

Example

std::net::Ipv4Addr::new(127, 0, 0, 1);

Could be written as:

std::net::Ipv4Addr::LOCALHOST;

Metadata

Metadata

Assignees

Labels

A-lintArea: New lintsgood 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