about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/ui/type-inference/regression-issue-81317.rs40
-rw-r--r--tests/ui/type-inference/regression-issue-81317.stderr17
2 files changed, 57 insertions, 0 deletions
diff --git a/tests/ui/type-inference/regression-issue-81317.rs b/tests/ui/type-inference/regression-issue-81317.rs
new file mode 100644
index 00000000000..50deb013d4b
--- /dev/null
+++ b/tests/ui/type-inference/regression-issue-81317.rs
@@ -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() {}
diff --git a/tests/ui/type-inference/regression-issue-81317.stderr b/tests/ui/type-inference/regression-issue-81317.stderr
new file mode 100644
index 00000000000..d018a2c4854
--- /dev/null
+++ b/tests/ui/type-inference/regression-issue-81317.stderr
@@ -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`.