Skip to content

Literal valid f64 cannot be parsed via f64::from_str #150307

@tisonkun

Description

@tisonkun

I tried this code:

use std::str::FromStr;

fn main() {
    let x = 1_000_000_.3_e+____4;
    let res = f64::from_str("1_000_000_.3_e+____4");
    println!("{:?}", x);
    println!("{:?}", res);
}

I expected to see this happen:

10000003000.0
Ok(10000003000.0)

Instead, this happened:

10000003000.0
Err(ParseFloatError { kind: Invalid })

Meta

rustc --version --verbose:

rustc 1.92.0-nightly (fa3155a64 2025-09-30)
binary: rustc
commit-hash: fa3155a644dd62e865825087b403646be01d4cef
commit-date: 2025-09-30
host: aarch64-apple-darwin
release: 1.92.0-nightly
LLVM version: 21.1.2
Backtrace

<backtrace>

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-discussionCategory: Discussion or questions that doesn't represent real issues.T-libs-apiRelevant to the library API team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions