add a test for issue rust-lang/rust#81317
This commit is contained in:
parent
097cd98869
commit
4ba683ee52
2 changed files with 57 additions and 0 deletions
40
tests/ui/type-inference/regression-issue-81317.rs
Normal file
40
tests/ui/type-inference/regression-issue-81317.rs
Normal 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() {}
|
||||
17
tests/ui/type-inference/regression-issue-81317.stderr
Normal file
17
tests/ui/type-inference/regression-issue-81317.stderr
Normal 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`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue