Really confusing error when clone
falls back to &T
instance
#54377
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
Consider the following code:
This fails saying
I just stared at this for at least 5 minutes wondering how in the world
clone
could fail to return an owned copy... until I realized that what really happens is that it does(&x).clone()
instead ofBar<F>::clone(x)
because the latter fails to satisfy all trait constraints.Might be worth having a specialized diagnostic for when
clone
and auto-(de)ref come together? Or more general, for when auto-(de)ref does something, and then fails, it should indicate somehow that auto-(de)ref happened, and maybe remark that some other possibilities were skipped because some bounds were not satisfied.The text was updated successfully, but these errors were encountered: