Skip to content

add a test for issue rust-lang/rust#81317 #140632

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

Merged
merged 3 commits into from
May 6, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions tests/ui/type-inference/regression-issue-81317.rs
Original file line number Diff line number Diff line change
@@ -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 changes: 17 additions & 0 deletions tests/ui/type-inference/regression-issue-81317.stderr
Original file line number Diff line number Diff line change
@@ -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