about summary refs log tree commit diff
diff options
context:
space:
mode:
authorSkgland <bennet.blessmann+github@googlemail.com>2025-05-03 22:36:17 +0200
committerBennet Bleßmann <bennet.blessmann+github@googlemail.com>2025-05-03 22:36:17 +0200
commit4ba683ee529ed87cc52d4983492dbf89b495ca0f (patch)
tree192ba116d9725171ffcef9559865c700f77e6329
parent097cd98869cf07a2860bef16c0d4a2b3b019b23a (diff)
downloadrust-4ba683ee529ed87cc52d4983492dbf89b495ca0f.tar.gz
rust-4ba683ee529ed87cc52d4983492dbf89b495ca0f.zip
add a test for issue rust-lang/rust#81317
-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`.