Hi, I'm working on issue #71580 to suggest
into() instead of
try_into() if possible. In the thread there Jonas suggested looking for the impl(eg.
impl Into<isize> from i16) as a way to have a more robust mechanism to do this.
I'm a bit stumped on how I can go about finding the impl. From Jonas's comment it seems I can achieve this by using
rustc_trait_selection::traits::SelectionContext::select, however I'm not entirely sure how I can construct an
Obligation to pass.
I'd appreaciate any advice on how I can proceed with SelectionContext, or alternative ways
@Samrat Man Singh that is the (only) way, and the obligation is just a predicate (which will be your
X: Into<Y>) and a "cause" - if you're not going to report an error from this lookup (which diagnostics wouldn't), you can use a dummy cause
@Samrat Man Singh there's also the
predicate_for_trait_def helper function but idk how often it's used
In Clippy we have a small helper using
ah this is about finding impls, not traits