Closed as not planned
Description
I was just making changes in one of the crates in my workspace, when the code broke in another crate of the workspace. Rust is no longer able to infer the type automatically, with an explicit annotation it works again.
Feel free to close this bug report if this is to be expected, but to me this seems very unusual for Rust.
This is the code:
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
struct S {}
fn main() {
// let s: S = serde_json::from_str("").unwrap();
}
fn check_len(len: &str) {
let vec = vec![1, 2, 3];
if vec.len() != len.parse().unwrap() {
panic!();
}
}
Uncomment the serde_json
line to trigger the bug. After uncommenting Rust needs an explicit type annotation as usize
for len.parse()
.
Meta
rustc --version --verbose
:
rustc 1.65.0-nightly (c0941dfb5 2022-08-21)
binary: rustc
commit-hash: c0941dfb5a7d07ef2d70cc54d319669d9d6f6c01
commit-date: 2022-08-21
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0
This occurs also with the stable and beta compiler