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
{{ message }}
Repository navigation
Allow search to find methods involving a type even when wrapped in another type #139665
Currently, docs.rs search only matches exact type names. I'd like the search to include methods that return or accept a type even if that type is wrapped inside another type.
Example:
Suppose I have a struct called S, and a method defined as follows:
fn m(&self) -> E<S>
When I search for S, I expect to find this method listed in search results, even though the method returns E<S> rather than directly returning S.
Similarly, if a method takes an argument like E<S>:
fn another_method(arg: E<S>)
Then searching for S should also return another_method.
Deep/Nested Types:
This shouldn't be limited to just one level of wrapping. Ideally, the search should support multi-level nested types as well. For example:
fn complex_method() -> Arc<Mutex<S>>
This method should also show up when searching for S, despite S being deeply wrapped inside Arc and Mutex.
UI Suggestion:
If showing deeply nested matches by default is considered too noisy or expensive, it would be great to have a toggle or checkbox in the UI settings to enable "nested type search". That way, users who want deeper results can opt in when needed.
This enhancement would significantly improve the discoverability of methods and types, especially when generics and error handling wrappers are involved.
If you look at the screenshot above, we have the metadata method inside DirEntry that returns Result<Metadata>.
I previously requested that whenever I search for Metadata, this specific method (DirEntry::metadata) should also appear in the results—but currently, it does not. See the following screenshot for reference:
However, when I search specifically for Result<Metadata>, the method correctly appears, as shown in the screenshot below:
To clarify once again: when I search for just Metadata, the method DirEntry::metadata should appear in the search results as well.
@notriddle@syphar@GuillaumeGomez Please take a look at the above comment and help me if I’m doing the search incorrectly, if this feature has already been merged, or if there’s any documentation on how to use the search—please point me to it. From my perspective, nobody should need to learn how to search; it should be straightforward and intuitive. You simply search for something, and it should just appear. For example, I should be able to search for Metadata, and the DirEntry::metadata method should immediately appear, as simple as that.
Could you please assign someone to address this bug? Additionally, just as a gentle reminder, the fix shouldn't be limited only to unwrapping a single generic layer, but should also handle multiple nested layers of genetics. For example, if we have a method returning a deeply nested type like Result<Option<Vec<Box<Metadata>>>>, then searching simply Metadata should still surface such method in search results which either return or take as argument this type(Metadata)
Activity
syphar commentedon Apr 11, 2025
( I did some slight reformatting to make it readable).
This is a request not to docs.rs, but to rustdoc itself.
cc @GuillaumeGomez should we move it? Or does it already exist?
GuillaumeGomez commentedon Apr 11, 2025
It should be on rust repository indeed. Moving it.
GuillaumeGomez commentedon Apr 11, 2025
cc @lolbinarycat @notriddle
notriddle commentedon Apr 11, 2025
This is #127589
mohan314e commentedon Apr 11, 2025
If you look at the screenshot above, we have the
metadatamethod insideDirEntrythat returnsResult<Metadata>.I previously requested that whenever I search for
Metadata, this specific method (DirEntry::metadata) should also appear in the results—but currently, it does not. See the following screenshot for reference:However, when I search specifically for
Result<Metadata>, the method correctly appears, as shown in the screenshot below:To clarify once again: when I search for just
Metadata, the methodDirEntry::metadatashould appear in the search results as well.mohan314e commentedon Apr 11, 2025
@notriddle @syphar @GuillaumeGomez Please take a look at the above comment and help me if I’m doing the search incorrectly, if this feature has already been merged, or if there’s any documentation on how to use the search—please point me to it. From my perspective, nobody should need to learn how to search; it should be straightforward and intuitive. You simply search for something, and it should just appear. For example, I should be able to search for Metadata, and the DirEntry::metadata method should immediately appear, as simple as that.
notriddle commentedon Apr 11, 2025
You're right. In this case, it's supposed to unbox the
Result, and it isn't. That's an actual bug.rapidfsn commentedon Apr 11, 2025
Thanks! @notriddle
Could you please assign someone to address this bug? Additionally, just as a gentle reminder, the fix shouldn't be limited only to unwrapping a single generic layer, but should also handle multiple nested layers of genetics. For example, if we have a method returning a deeply nested type like
Result<Option<Vec<Box<Metadata>>>>, then searching simplyMetadatashould still surface such method in search results which either return or take as argument this type(Metadata)notriddle commentedon Apr 11, 2025
Vec isn't marked as unboxable, so that example won't work.
Result<Option<Box<Metadata>>>, however, will work.rapidfsn commentedon Apr 11, 2025
That will do the job. It is fine to skip the type which are not marked as unboxable.
rustdoc-search: add unbox flag to Result aliases
Rollup merge of rust-lang#139688 - rust-lang:notriddle/io-result-unbo…
Unrolled build for rust-lang#139688
rustdoc-search: add unbox flag to Result aliases
Rollup merge of rust-lang#139688 - rust-lang:notriddle/io-result-unbo…