Method resolution fails when through a reference to a trait object on Self: Sized methods #82825
Labels
A-trait-system
Area: Trait system
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-types
Relevant to the types team, which will review and decide on the PR/issue.
(playground: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=8d985c6ac7adc1a9835d4c7b5cd74f31)
To me it appears that method resolution should autoref and find the impl on the
&T
automatically, as theSelf: Sized
should beNote that this is specific to &self/&mut self methods, and by-value receivers work, like MANY of the methods on
Iterator
:https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=4dbe34cf1ffec880d225d96bd2370907 (rustc even gives an extremely good diagnostic about & vs &mut), though its unclear to me why in that cause,
next
is callable in that case, but I think it's because it lacks theSelf: Sized
bound)(note that the origin of this issue is me investigating how to stabilize the not-yet implemented
std::stream::Stream::next
https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=7e9fe3092902bafe9e5ae607a12e9b4e)Thanks @eddyb for helping me minimize this and suggesting that this may be possible to resolve in a simple way.
The text was updated successfully, but these errors were encountered: