I tried this code (playground):
fn main() {
let a: [i64; 1] = [0];
let f = |p| {
a[p].pow(1)
};
let c: i64 = f(0);
}
I expected to see this happen: no errors
Instead, this happened:
error[E0282]: type annotations needed
--> src/main.rs:4:9
|
4 | a[p].pow(1)
| ^^^^ cannot infer type
|
= note: type must be known at this point
Replacing it with a[0] compiles, removing .pow(1) also compiles. Extracting a[p] into a variable as so:
also results in an error suggesting giving x an explicit type. Giving x an explicit i64 type also compiles.
Meta
rustc --version --verbose:
rustc 1.46.0 (04488afe3 2020-08-24)
binary: rustc
commit-hash: 04488afe34512aa4c33566eb16d8c912a3ae04f9
commit-date: 2020-08-24
host: x86_64-unknown-linux-gnu
release: 1.46.0
LLVM version: 10.0
Same issue on beta and nightly.
I tried this code (playground):
I expected to see this happen: no errors
Instead, this happened:
Replacing it with
a[0]compiles, removing.pow(1)also compiles. Extractinga[p]into a variable as so:also results in an error suggesting giving
xan explicit type. Givingxan expliciti64type also compiles.Meta
rustc --version --verbose:Same issue on beta and nightly.