about summary refs log tree commit diff
path: root/src/doc/rustdoc
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2023-04-15 02:23:32 +0000
committerbors <bors@rust-lang.org>2023-04-15 02:23:32 +0000
commit3312a3053bb9996e56a5ed58b6b9306224ada727 (patch)
tree83c3d3b4d996988e966b6f24886f1e2171973679 /src/doc/rustdoc
parentfef27e038ee9886722548b70d0c7f75d7e666c72 (diff)
parent6ce53278e191f8047addc7f44b98e180bc80d66d (diff)
Auto merge of #109802 - notriddle:notriddle/rustdoc-search-generics-nested, r=GuillaumeGomez
rustdoc-search: add support for nested generics

This change allows `search.js` to parse nested generics (which look `Like<This<Example>>`) and match them. It maintains the existing "bag semantics", so that the order of type parameters is ignored but the number is required to be greater than or equal to what's in the query.

For example, a function with the signature `fn read_all(&mut self: impl Read) -> Result<Vec<u8>, Error>` will match these queries:

* `Read -> Result<Vec<u8>, Error>`
* `Read -> Result<Error, Vec>`
* `Read -> Result<Vec<u8>>`

But it *does not* match `Result<Vec, u8>` or `Result<u8<Vec>>`.
Diffstat (limited to 'src/doc/rustdoc')
-rw-r--r--src/doc/rustdoc/src/how-to-read-rustdoc.md11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/doc/rustdoc/src/how-to-read-rustdoc.md b/src/doc/rustdoc/src/how-to-read-rustdoc.md
index 2957916d56c..56342f65d99 100644
--- a/src/doc/rustdoc/src/how-to-read-rustdoc.md
+++ b/src/doc/rustdoc/src/how-to-read-rustdoc.md
@@ -94,6 +94,17 @@ can be matched with the following queries:
 * `trait:Iterator<primitive:u32> -> primitive:usize`
 * `Iterator -> usize`
 
+Generics and function parameters are order-agnostic, but sensitive to nesting
+and number of matches. For example, a function with the signature
+`fn read_all(&mut self: impl Read) -> Result<Vec<u8>, Error>`
+will match these queries:
+
+* `Read -> Result<Vec<u8>, Error>`
+* `Read -> Result<Error, Vec>`
+* `Read -> Result<Vec<u8>>`
+
+But it *does not* match `Result<Vec, u8>` or `Result<u8<Vec>>`.
+
 ### Changing displayed theme
 
 You can change the displayed theme by opening the settings menu (the gear