Closed
Description
Code
I tried this code: Johni0702/rtp on the dtls-srtp Branch
I expected to see this happen: Compiles successfully as in 1.48
Instead, this happened: Error E0282 in src/rfc3711.rs
error[E0282]: type annotations needed
--> src/rfc3711.rs:477:19
|
476 | let iv = iv ^ (BigUint::from(1_u8) << (context.session_encr_key.len() * 8));
| -- consider giving `iv` a type
477 | let iv = &iv.to_bytes_be()[1..context.session_encr_key.len() + 1];
| ^^ cannot infer type
|
= note: type must be known at this point
error[E0282]: type annotations needed
--> src/rfc3711.rs:511:19
|
510 | let iv = iv ^ (BigUint::from(1_u8) << (context.session_encr_key.len() * 8));
| -- consider giving `iv` a type
511 | let iv = &iv.to_bytes_be()[1..context.session_encr_key.len() + 1];
| ^^ cannot infer type
|
= note: type must be known at this point
error: aborting due to 2 previous errors
Version it worked on
It most recently worked on: 1.48
Version with regression
rustc --version --verbose
:
rustc 1.49.0 (e1884a8e3 2020-12-29)
binary: rustc
commit-hash: e1884a8e3c3e813aada8254edfa120e85bf5ffca
commit-date: 2020-12-29
host: x86_64-unknown-linux-gnu
release: 1.49.0
I tried to minimize the code necessary for reproduction and I got it down to:
//file: src/lib.rs
use num::BigUint; // Cargo.toml: num = "0.1"
pub trait Protocol {
type PacketIndex: Into<u64> + Into<BigUint>;
}
fn from_nothing<T>() -> T {
todo!()
}
pub fn decrypt_portion<P: Protocol>(index: P::PacketIndex) {
let iv: BigUint = from_nothing();
let len: usize = from_nothing();
let iv = iv ^ (index.into() << 16);
let iv = iv ^ (BigUint::from(1_u8) << (len * 8));
let _iv: &[u8] = &iv.to_bytes_be()[1..len + 1];
}
Metadata
Metadata
Assignees
Labels
Area: Type inferenceCall for participation: An issue has been fixed and does not reproduce, but no test has been added.Relevant to the compiler team, which will review and decide on the PR/issue.Relevant to the types team, which will review and decide on the PR/issue.Performance or correctness regression from one stable version to another.