You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I still reproduce it. Maybe my description was not entirely clear. If a type implements the std::ops::Deref trait then there is an additional section in its documentation page Methods from Deref<Target=...>.
Even though Deref::deref returns an immutable reference, the generated documentation contains all methods, including those that would require DerefMut implementation for the code to compile.
So, considering the example code from my previous message :
letmut foo = Foo;assert_eq!(foo.len(),0);// okassert_eq!(foo.get(0),None);// ok// compile error, but generated documentation lists get_mut as an available functionassert_eq!(foo.get_mut(0),None);
I quickly grepped the source code and it looks like rustdoc only checks for the implementation of Deref
(link to code).
rustdoc: Filter more incorrect methods inherited through Deref
Old code filtered out only static methods. This code also excludes &mut self methods if there is no DerefMut implementation.
Fixes#35169
Wrong documentation is generated for types that only implement Deref, but not DerefMut. It inherits methods from both Deref and DerefMut.
Steps to reproduce:
cargo new deref-doc-bug
cargo doc --open
Generated documentation has methods for both
&[char]
and&mut [char]
, for examplefn get_mut
.Version
The text was updated successfully, but these errors were encountered: