This commit is contained in:
Skgland 2025-05-03 22:36:17 +02:00 committed by Bennet Bleßmann
parent 097cd98869
commit 4ba683ee52
No known key found for this signature in database
GPG key ID: 3BE1A1A3CBC3CF99
2 changed files with 57 additions and 0 deletions

View file

@ -0,0 +1,40 @@
// Regression test for #81317: type can no longer be infered as of 1.49
//@ check-fail
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();
//~^ ERROR type annotations needed
&iv.to_bytes_be();
}
impl S {
fn to_bytes_be(&self) -> &[u8] {
&[]
}
}
impl BitXor for S {
type Output = S;
fn bitxor(self, _rhs: Self) -> Self::Output {
S
}
}
impl<'a> BitXor<&'a S> for S {
type Output = S;
fn bitxor(self, _rhs: &'a S) -> Self::Output {
S
}
}
fn main() {}

View file

@ -0,0 +1,17 @@
error[E0282]: type annotations needed
--> $DIR/regression-issue-81317.rs:13:9
|
LL | let iv = S ^ index.into();
| ^^
LL |
LL | &iv.to_bytes_be();
| -- type must be known at this point
|
help: consider giving `iv` an explicit type
|
LL | let iv: /* Type */ = S ^ index.into();
| ++++++++++++
error: aborting due to 1 previous error
For more information about this error, try `rustc --explain E0282`.