Closed
Description
Given the following code:
struct MyS;
impl MyS {
const FOO: i32 = 1;
fn foo() -> MyS {MyS}
}
fn main() {
let x: i32 = MyS::foo;
let y: i32 = i32::max - 42;
let z: i32 = i32::max;
}
The current output is:
error[E0308]: mismatched types
--> src/main.rs:9:18
|
9 | let x: i32 = MyS::foo;
| --- ^^^^^^^^ expected `i32`, found fn item
| |
| expected due to this
|
= note: expected type `i32`
found fn item `fn() -> MyS {MyS::foo}`
error[E0369]: cannot subtract `{integer}` from `fn(i32, i32) -> i32 {<i32 as Ord>::max}`
--> src/main.rs:11:27
|
11 | let y: i32 = i32::max - 42;
| -------- ^ -- {integer}
| |
| fn(i32, i32) -> i32 {<i32 as Ord>::max}
error[E0308]: mismatched types
--> src/main.rs:12:18
|
12 | let z: i32 = i32::max;
| --- ^^^^^^^^ expected `i32`, found fn item
| |
| expected due to this
|
= note: expected type `i32`
found fn item `fn(i32, i32) -> i32 {<i32 as Ord>::max}`
help: use parentheses to call this function
|
12 | let z: i32 = i32::max(...);
| +++++
Ideally the output of both errors should mention that the MyS::MAX
or i32::MAX
constants exists if the type of the constant would solve the type issues.
help: use `MyS::FOO` to refer to the constant of type MyS
or
help: use `i32::MAX` to refer to the constant of type i32