method-probing machinery can false-negative because it doesn't know about associated types

2ba012b
Opened by Zack M. Davis at 2024-08-29 23:38:02

As part of the endeavor that also prompted #46459, it was noticed that we never generated a suggestion for .to_owned() even where it would be appropriate. Some strategic logging in matches_return_type revealed that the result being returned by .can_sub was—

Err(
    Sorts(
        ExpectedFound {
            expected: <_ as std::borrow::ToOwned>::Owned,
            found: std::string::String
        }
    )
)

But in this case, ToOwned::Owned should have been String.