-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Associated type in higher-rank trait bounds cause unexpected E0227 and useless help #94160
Comments
This is fixed by #94070, and thus (likely but not checked) also fixed by #90887 (since those are basically equivalent).
While this does fix the compiler error here, I am somewhat doubtful that we could make the compiler give this feedback in general. This issue is really just because the compiler has troubles with associated types that have higher-ranked lifetimes in them, which the two PRs mentioned above alleviate a bit. |
If this compiles successfully, that's good enough for me. (There is no need to display help.) |
This issue seems same as #90729. Should I close this issue? |
I would argue that this is sufficiently different from #90729, since it doesn't require |
I understand. |
FYI use std::ops::Add;
fn ref_add<'a, T>(a: &'a T, b: &'a T) -> T
where
T: From<<&'a T as Add>::Output>,
&'a T: Add,
{
T::from(a + b)
}
fn ref_add_hrtb<T>(a: &T, b: &T) -> T
where
T: for<'x> From<<&'x T as Add>::Output>,
for<'x> &'x T: Add,
{
T::from(a + b)
}
fn main() {
let a = 2i32;
let b = 3i32;
assert_eq!(ref_add(&a, &b), 5i32); // pass
assert_eq!(ref_add_hrtb(&a, &b), 5i32); // E0277
} above code generate below output.
|
I think this was fixed in #90887, but needs to be confirmed. |
@jackh726, confirmed fixed on master. |
I confirmed fixed on nightly(1eb7258 2022-03-08). 🎉 |
Given the following code: code in playground
The current output is:
Ideally the help should look like:
Not higher-rank trait bounds (below code) is compiled successfully.
The text was updated successfully, but these errors were encountered: