summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc-js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-06-07 05:48:48 +0000
commitef24de24a82fe681581cc130f342363c47c0969a (patch)
tree0d494f7e1a38b95c92426f58fe6eaa877303a86c /tests/rustdoc-js
parentReleasing progress-linux version 1.74.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-ef24de24a82fe681581cc130f342363c47c0969a.tar.xz
rustc-ef24de24a82fe681581cc130f342363c47c0969a.zip
Merging upstream version 1.75.0+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/rustdoc-js')
-rw-r--r--tests/rustdoc-js/auxiliary/equivalent.rs15
-rw-r--r--tests/rustdoc-js/impl-trait.js19
-rw-r--r--tests/rustdoc-js/impl-trait.rs6
-rw-r--r--tests/rustdoc-js/search-method-disambiguate.js28
-rw-r--r--tests/rustdoc-js/search-method-disambiguate.rs22
-rw-r--r--tests/rustdoc-js/search-non-local-trait-impl.js9
-rw-r--r--tests/rustdoc-js/search-non-local-trait-impl.rs8
7 files changed, 102 insertions, 5 deletions
diff --git a/tests/rustdoc-js/auxiliary/equivalent.rs b/tests/rustdoc-js/auxiliary/equivalent.rs
new file mode 100644
index 000000000..a19b5a2d4
--- /dev/null
+++ b/tests/rustdoc-js/auxiliary/equivalent.rs
@@ -0,0 +1,15 @@
+use std::borrow::Borrow;
+
+pub trait Equivalent<K: ?Sized> {
+ fn equivalent(&self, key: &K) -> bool;
+}
+
+impl<Q: ?Sized, K: ?Sized> Equivalent<K> for Q
+where
+ Q: Eq,
+ K: Borrow<Q>,
+{
+ fn equivalent(&self, key: &K) -> bool {
+ PartialEq::eq(self, key.borrow())
+ }
+}
diff --git a/tests/rustdoc-js/impl-trait.js b/tests/rustdoc-js/impl-trait.js
index 710e594b5..00d67d639 100644
--- a/tests/rustdoc-js/impl-trait.js
+++ b/tests/rustdoc-js/impl-trait.js
@@ -1,3 +1,4 @@
+// exact-check
// ignore-order
const EXPECTED = [
@@ -20,9 +21,16 @@ const EXPECTED = [
{
'query': '-> Aaaaaaa',
'others': [
- { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
- { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' },
{ 'path': 'impl_trait', 'name': 'bbbbbbb' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'ggggggg' },
+ ],
+ },
+ {
+ 'query': '-> Bbbbbbb',
+ 'others': [
+ { 'path': 'impl_trait::Ccccccc', 'name': 'ggggggg' },
],
},
{
@@ -31,13 +39,14 @@ const EXPECTED = [
{ 'path': 'impl_trait', 'name': 'Aaaaaaa' },
],
'in_args': [
- { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
{ 'path': 'impl_trait::Ccccccc', 'name': 'eeeeeee' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
],
'returned': [
- { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
- { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' },
{ 'path': 'impl_trait', 'name': 'bbbbbbb' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'ggggggg' },
],
},
];
diff --git a/tests/rustdoc-js/impl-trait.rs b/tests/rustdoc-js/impl-trait.rs
index fb8869b46..d20fdd60e 100644
--- a/tests/rustdoc-js/impl-trait.rs
+++ b/tests/rustdoc-js/impl-trait.rs
@@ -1,6 +1,9 @@
pub trait Aaaaaaa {}
+pub trait Bbbbbbb {}
+
impl Aaaaaaa for () {}
+impl Bbbbbbb for () {}
pub fn bbbbbbb() -> impl Aaaaaaa {
()
@@ -18,4 +21,7 @@ impl Ccccccc {
pub fn fffffff(&self, x: impl Aaaaaaa) -> impl Aaaaaaa {
x
}
+ pub fn ggggggg(&self) -> impl Aaaaaaa + Bbbbbbb {
+ ()
+ }
}
diff --git a/tests/rustdoc-js/search-method-disambiguate.js b/tests/rustdoc-js/search-method-disambiguate.js
new file mode 100644
index 000000000..70aa895f9
--- /dev/null
+++ b/tests/rustdoc-js/search-method-disambiguate.js
@@ -0,0 +1,28 @@
+// exact-check
+// ignore-order
+// ignore-tidy-linelength
+
+const FILTER_CRATE = "search_method_disambiguate";
+
+const EXPECTED = [
+ {
+ 'query': 'MyTy -> bool',
+ 'others': [
+ {
+ 'path': 'search_method_disambiguate::MyTy',
+ 'name': 'my_method',
+ 'href': '../search_method_disambiguate/struct.MyTy.html#impl-X-for-MyTy%3Cbool%3E/method.my_method'
+ },
+ ],
+ },
+ {
+ 'query': 'MyTy -> u8',
+ 'others': [
+ {
+ 'path': 'search_method_disambiguate::MyTy',
+ 'name': 'my_method',
+ 'href': '../search_method_disambiguate/struct.MyTy.html#impl-X-for-MyTy%3Cu8%3E/method.my_method'
+ },
+ ],
+ }
+];
diff --git a/tests/rustdoc-js/search-method-disambiguate.rs b/tests/rustdoc-js/search-method-disambiguate.rs
new file mode 100644
index 000000000..ae884447a
--- /dev/null
+++ b/tests/rustdoc-js/search-method-disambiguate.rs
@@ -0,0 +1,22 @@
+pub trait X {
+ type InnerType;
+ fn my_method(&self) -> Self::InnerType;
+}
+
+pub struct MyTy<T> {
+ pub t: T,
+}
+
+impl X for MyTy<bool> {
+ type InnerType = bool;
+ fn my_method(&self) -> bool {
+ self.t
+ }
+}
+
+impl X for MyTy<u8> {
+ type InnerType = u8;
+ fn my_method(&self) -> u8 {
+ self.t
+ }
+}
diff --git a/tests/rustdoc-js/search-non-local-trait-impl.js b/tests/rustdoc-js/search-non-local-trait-impl.js
new file mode 100644
index 000000000..9ebeceb69
--- /dev/null
+++ b/tests/rustdoc-js/search-non-local-trait-impl.js
@@ -0,0 +1,9 @@
+// exact-check
+
+// This test ensures that methods from blanket impls of not available foreign traits
+// don't show up in the search results.
+
+const EXPECTED = {
+ 'query': 'equivalent',
+ 'others': [],
+};
diff --git a/tests/rustdoc-js/search-non-local-trait-impl.rs b/tests/rustdoc-js/search-non-local-trait-impl.rs
new file mode 100644
index 000000000..462b75b0b
--- /dev/null
+++ b/tests/rustdoc-js/search-non-local-trait-impl.rs
@@ -0,0 +1,8 @@
+// aux-crate:priv:equivalent=equivalent.rs
+// compile-flags: -Zunstable-options --extern equivalent
+// edition:2018
+
+extern crate equivalent;
+
+#[derive(Clone, PartialEq, Eq, Debug)]
+pub struct LayoutError;