I tried this code:
// Ought to work fine but doesn't
fn borrow_and_deref<T>(p: T) -> i32 where for<'a> &'a T: Deref<Target=i32> {
*&p
}
I expected to see this happen: Successful typechecking
Instead, this happened:

If we invoke deref manually, rather than implicitly through syntax sugar everything works fine:
// Works, so the issue is specifically at the intersection of syntax
// sugar and the trait bound
fn borrow_and_deref<T>(p: T) -> i32 where for<'a> &'a T: Deref<Target=i32> {
*(&p).deref()
}
So this issue is specifically at the intersection of this kind of constraint and the syntax sugar.
Playground link
I tried this code:
I expected to see this happen: Successful typechecking
Instead, this happened:

If we invoke deref manually, rather than implicitly through syntax sugar everything works fine:
So this issue is specifically at the intersection of this kind of constraint and the syntax sugar.
Playground link