Skip to content

Warn of obscure floating-point literals #8424

@tamaroning

Description

@tamaroning

What it does

This lint warns of misleading floating-point literals.
In the example, a has type i32 because floating-point literals must start with a decimal literal.
Instead of suffixes, we should use type ascriptions.

Lint Name

obscure_float_literal

Category

style

Advantage

  • Avoid ambiguity

Drawbacks

none

Example

let a = 0x1_f32; // == 0x1F32

Could be written as:

let a = 0x1 as f32;

Metadata

Metadata

Assignees

Labels

A-lintArea: New lints

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions