Skip to content

Type inference failure for f32 #123824

Closed
@P1n3appl3

Description

@P1n3appl3

After this rollup we started seeing the following compile failure:

fn main() {
    let x = f32::from(3.14);
}
error[E0277]: the trait bound `f32: From<f64>` is not satisfied
  --> /tmp/repro.rs:2:13
   |
16 |     let x = f32::from(3.14);
   |             ^^^ the trait `From<f64>` is not implemented for `f32`
   |
   = help: the following other types implement trait `From<T>`:
             <f32 as From<bool>>
             <f32 as From<f16>>
             <f32 as From<i16>>
             <f32 as From<i8>>
             <f32 as From<u16>>
             <f32 as From<u8>>

error: aborting due to 1 previous error

I repro'd this locally on aa6a697 but we have CI that runs on every commit so we're fairly sure that it started with 4435924. Of the changes in that rollup #122470 is the only one that seemed to touch float stuff, but I'm not sure how adding some extra impls for f16 and f128 would break inference in this case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-inferenceArea: Type inferenceC-bugCategory: This is a bug.F-f16_and_f128`#![feature(f16)]`, `#![feature(f128)]`S-has-mcveStatus: A Minimal Complete and Verifiable Example has been found for this issueT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.T-libsRelevant to the library team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions