about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMichael Howell <michael@notriddle.com>2023-03-07 11:21:12 -0700
committerMichael Howell <michael@notriddle.com>2023-03-07 11:37:04 -0700
commit44813e038c62ac975f4efaf8fb588949d24528af (patch)
tree731356c11b1a7195166970df184fb29548bec65c
parenta6446c53fe8be6692b07e121b831c3db770ff94a (diff)
downloadrust-44813e038c62ac975f4efaf8fb588949d24528af.tar.gz
rust-44813e038c62ac975f4efaf8fb588949d24528af.zip
rustdoc: fix type search when more than one `where` clause applies
-rw-r--r--src/librustdoc/html/render/search_index.rs2
-rw-r--r--tests/rustdoc-js-std/option-type-signatures.js23
-rw-r--r--tests/rustdoc-js/where-clause.js8
-rw-r--r--tests/rustdoc-js/where-clause.rs8
4 files changed, 33 insertions, 8 deletions
diff --git a/src/librustdoc/html/render/search_index.rs b/src/librustdoc/html/render/search_index.rs
index 483137f4c35..84213182d0a 100644
--- a/src/librustdoc/html/render/search_index.rs
+++ b/src/librustdoc/html/render/search_index.rs
@@ -484,7 +484,7 @@ fn add_generics_and_bounds_as_types<'tcx, 'a>(
     // for its bounds.
     if let Type::Generic(arg_s) = *arg {
         // First we check if the bounds are in a `where` predicate...
-        if let Some(where_pred) = generics.where_predicates.iter().find(|g| match g {
+        for where_pred in generics.where_predicates.iter().filter(|g| match g {
             WherePredicate::BoundPredicate { ty: Type::Generic(ty_s), .. } => *ty_s == arg_s,
             _ => false,
         }) {
diff --git a/tests/rustdoc-js-std/option-type-signatures.js b/tests/rustdoc-js-std/option-type-signatures.js
index dee4819e81a..6bf421a2135 100644
--- a/tests/rustdoc-js-std/option-type-signatures.js
+++ b/tests/rustdoc-js-std/option-type-signatures.js
@@ -1,7 +1,18 @@
-const QUERY = 'option, fnonce -> option';
+const QUERY = [
+    'option, fnonce -> option',
+    'option -> default',
+];
 
-const EXPECTED = {
-    'others': [
-        { 'path': 'std::option::Option', 'name': 'map' },
-    ],
-};
+const EXPECTED = [
+    {
+        'others': [
+            { 'path': 'std::option::Option', 'name': 'map' },
+        ],
+    },
+    {
+        'others': [
+            { 'path': 'std::option::Option', 'name': 'unwrap_or_default' },
+            { 'path': 'std::option::Option', 'name': 'get_or_insert_default' },
+        ],
+    },
+];
diff --git a/tests/rustdoc-js/where-clause.js b/tests/rustdoc-js/where-clause.js
index 4112f08fb0a..86254a80e20 100644
--- a/tests/rustdoc-js/where-clause.js
+++ b/tests/rustdoc-js/where-clause.js
@@ -1,4 +1,4 @@
-const QUERY = ['trait<nested>', '-> trait<nested>', 't1, t2', '-> shazam'];
+const QUERY = ['trait<nested>', '-> trait<nested>', 't1, t2', '-> shazam', 'drizzel -> shazam'];
 
 const EXPECTED = [
     {
@@ -19,6 +19,12 @@ const EXPECTED = [
     {
         'others': [
             { 'path': 'where_clause', 'name': 'bippety' },
+            { 'path': 'where_clause::Drizzel', 'name': 'boppety' },
+        ],
+    },
+    {
+        'others': [
+            { 'path': 'where_clause::Drizzel', 'name': 'boppety' },
         ],
     },
 ];
diff --git a/tests/rustdoc-js/where-clause.rs b/tests/rustdoc-js/where-clause.rs
index f8bdc072216..56c01019fb6 100644
--- a/tests/rustdoc-js/where-clause.rs
+++ b/tests/rustdoc-js/where-clause.rs
@@ -20,3 +20,11 @@ pub trait Shazam {}
 pub fn bippety<X>() -> &'static X where X: Shazam {
     panic!()
 }
+
+pub struct Drizzel<T>(T);
+
+impl<T> Drizzel<T> {
+    pub fn boppety(&self) -> &T where T: Shazam {
+        panic!();
+    }
+}