-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right now
Description
Consider the following code:
use std::marker::PhantomData;
struct A<T>(PhantomData<T>);
impl<T> A<T> {
fn general(self) {
self.overloaded() // <--
}
}
impl<T: Sync> A<T> {
fn overloaded(self) {}
}
trait Overload: Sized {
fn overloaded(self) {}
}
impl<T> Overload for A<T> {}
At the location marked with <--
, T
is not constrained to Sync
and as such the call resolves to the Overload
implementation.
However, rust-analyzer shows the information for A::overloaded(self)
instead.
A similar case occurs when using by-value precedence to select a method between two traits.
use std::marker::PhantomData;
struct A<T>(PhantomData<T>);
trait Bound {
fn either(&self) -> usize {
todo!()
}
}
trait Safe: Sized {
fn either(self) -> u8 {
todo!()
}
}
impl<T> Bound for A<T> {}
impl<T: Bound + Send + Sync> Safe for T {}
fn issue() {
let bound = A::<*const ()>(PhantomData).either(); // <--
let _: usize = bound;
}
saecki
Metadata
Metadata
Assignees
Labels
A-tytype system / type inference / traits / method resolutiontype system / type inference / traits / method resolutionS-actionableSomeone could pick this issue up and work on it right nowSomeone could pick this issue up and work on it right now