Skip to content

Can't add f64 + {float} #9

Closed
rust-lang/rust
#109749
@compiler-errors

Description

@compiler-errors
fn foo(x: f64) {
    let y = x + 1.0;
}
error[E0277]: cannot add `{float}` to `f64`
 --> <source>:2:15
  |
2 |     let y = x + 1.0;
  |               ^ no implementation for `f64 + {float}`
  |
  = help: the trait `Add<{float}>` is not implemented for `f64`
  = help: the following other types implement trait `Add<Rhs>`:
            <&'a f64 as Add<f64>>
            <&f64 as Add<&f64>>
            <f64 as Add<&f64>>
            <f64 as Add>

error: the type `fn(f64, _) -> <f64 as Add<_>>::Output` is not well-formed
 --> <source>:2:15
  |
2 |     let y = x + 1.0;
  |               ^

That WF error is strange.


Probably also fixes: tests/ui/associated-types/issue-18655.rs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions