-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Type can no longer be inferred in 1.49 #81317
Comments
Based on that it worked on stable 1.48 and now doesn't on 1.49 I assume this is a stable to stable regression. @rustbot modify labels: +regression-from-stable-to-stable-regression-untriaged |
Minimized further: use num::BigUint; // Cargo.toml: num = "0.1"
pub trait Protocol: Sized + Default {
type PacketIndex: Into<u64> + Into<BigUint>;
}
pub fn decrypt_portion<P: Protocol>(index: P::PacketIndex) {
let iv: BigUint = loop{};
let len: usize = loop{};
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];
} Errors:
|
Reduced the code to not use external BigUint type: use std::ops::{BitXor, Shl};
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];
}
pub struct BigUint;
impl BigUint {
fn to_bytes_be(&self) -> Vec<u8> {
todo!()
}
}
impl From<u8> for BigUint {
fn from(_: u8) -> Self {
unimplemented!()
}
}
impl Shl<usize> for BigUint {
type Output = BigUint;
fn shl(self, _rhs: usize) -> Self::Output {
unimplemented!()
}
}
impl BitXor for BigUint {
type Output = BigUint;
fn bitxor(self, _rhs: Self) -> Self::Output {
unimplemented!()
}
}
impl<'a> BitXor<&'a BigUint> for BigUint {
type Output = BigUint;
fn bitxor(self, _rhs: &'a BigUint) -> Self::Output {
unimplemented!()
}
} |
pub struct S;
pub trait P {
type I: Into<u64> + Into<S>;
}
trait A<B> {
fn m(self, _: B) -> S;
}
impl A<S> for S {
fn m(self, _: S) -> S {
todo!()
}
}
impl A<&'static S> for S {
fn m(self, _: &'static S) -> S {
todo!()
}
}
pub fn f<T: P>(i: T::I) {
S.m(i.into());
} |
Could this be related to #80816? |
searched nightlies: from nightly-2020-10-01 to nightly-2020-11-14 bisected with cargo-bisect-rustc v0.6.0Host triple: x86_64-unknown-linux-gnu cargo bisect-rustc --preserve --start=2020-10-01 --end=2020-11-14 -- check Using code: pub struct S;
pub trait P {
type I: Into<u64> + Into<S>;
}
trait A<B> {
fn m(self, _: B) -> S;
}
impl A<S> for S {
fn m(self, _: S) -> S {
todo!()
}
}
impl A<&'static S> for S {
fn m(self, _: &'static S) -> S {
todo!()
}
}
pub fn f<T: P>(i: T::I) {
let _ = S.m(i.into());
} |
An alternate reduction: use core::ops::Shl;
struct A;
impl A {
fn a(&self) {}
}
impl Shl<i8> for A {
type Output = A;
fn shl(self, _: i8) -> A {
self
}
}
impl Shl<i32> for A {
type Output = A;
fn shl(self, _: i32) -> A {
self
}
}
pub fn decrypt_portion_no_worky() {
let iv = A << 16;
iv.a();
}
pub fn decrypt_portion_works() {
let iv = A << 16;
// Calling no methods works?!
} |
@mbartlett21 that does not appear to be a valid reduction as it does not work on 1.48 for me |
use std::ops::BitXor;
pub struct S;
pub trait P {
type I: Into<u64> + Into<S>;
}
pub fn decrypt_portion<T: P>(index: T::I) {
let iv = S ^ index.into();
&iv.to_bytes_be();
}
impl S {
fn to_bytes_be(&self) -> &[u8] {
unimplemented!()
}
}
impl BitXor for S {
type Output = S;
fn bitxor(self, _rhs: Self) -> Self::Output {
unimplemented!()
}
}
impl<'a> BitXor<&'a S> for S {
type Output = S;
fn bitxor(self, _rhs: &'a S) -> Self::Output {
unimplemented!()
}
} this reduction works for me and without changing the error message as with ojedas reduction |
Assigning |
duplicate of #80816 but keeping open so I make sure to test both repros |
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
Version it worked on
It most recently worked on: 1.48
Version with regression
rustc --version --verbose
:I tried to minimize the code necessary for reproduction and I got it down to:
The text was updated successfully, but these errors were encountered: