From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- tests/rustdoc-js/auxiliary/equivalent.rs | 15 +++++++++++++ tests/rustdoc-js/impl-trait.js | 19 ++++++++++++----- tests/rustdoc-js/impl-trait.rs | 6 ++++++ tests/rustdoc-js/search-method-disambiguate.js | 28 +++++++++++++++++++++++++ tests/rustdoc-js/search-method-disambiguate.rs | 22 +++++++++++++++++++ tests/rustdoc-js/search-non-local-trait-impl.js | 9 ++++++++ tests/rustdoc-js/search-non-local-trait-impl.rs | 8 +++++++ 7 files changed, 102 insertions(+), 5 deletions(-) create mode 100644 tests/rustdoc-js/auxiliary/equivalent.rs create mode 100644 tests/rustdoc-js/search-method-disambiguate.js create mode 100644 tests/rustdoc-js/search-method-disambiguate.rs create mode 100644 tests/rustdoc-js/search-non-local-trait-impl.js create mode 100644 tests/rustdoc-js/search-non-local-trait-impl.rs (limited to 'tests/rustdoc-js') 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 { + fn equivalent(&self, key: &K) -> bool; +} + +impl Equivalent for Q +where + Q: Eq, + K: Borrow, +{ + 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 { + pub t: T, +} + +impl X for MyTy { + type InnerType = bool; + fn my_method(&self) -> bool { + self.t + } +} + +impl X for MyTy { + 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; -- cgit v1.2.3