Skip to content

More clearly Error Message: Calculating with different types #34698

Closed
@StefanoD

Description

@StefanoD

This yields with rust 1.9

let result = -0.25 % 2;

following error message:

:7:18: 7:27 error: the trait bound _: std::ops::Rem<_> is not satisfied [E0277]
:7 let result = -0.25 % 2;
^~~~~~~~~
:7:18: 7:27 help: see the detailed explanation for E0277
:7:18: 7:27 help: the following implementations were found:
:7:18: 7:27 help:
:7:18: 7:27 help: <&'a f64 as std::ops::Rem>
:7:18: 7:27 help: <f64 as std::ops::Rem<&'a f64>>
:7:18: 7:27 help: <&'b f64 as std::ops::Rem<&'a f64>>
:7:18: 7:27 help: and 54 others
error: aborting due to previous error

This is the fix:

let result = -0.25 % 2.0;

This is a really compilicated error message for the fact, that calucating with different types are not allowed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lints

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions