From 12dc24f46007f82b93ed85614347a42d47580afa Mon Sep 17 00:00:00 2001 From: Michael Howell Date: Tue, 24 Sep 2024 18:18:01 -0700 Subject: rustdoc-search: simplify rules for generics and type params This commit is a response to feedback on the displayed type signatures results, by making generics act stricter. Generics are tightened by making order significant. This means `Vec` now matches only with a true vector of allocators, instead of matching the second type param. It also makes unboxing within generics stricter, so `Result` only matches if `B` is in the error type and `A` is in the success type. The top level of the function search is unaffected. Find the discussion on: * * * --- .../generics-match-ambiguity-no-unbox.js | 68 ++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 tests/rustdoc-js/generics-match-ambiguity-no-unbox.js (limited to 'tests/rustdoc-js/generics-match-ambiguity-no-unbox.js') diff --git a/tests/rustdoc-js/generics-match-ambiguity-no-unbox.js b/tests/rustdoc-js/generics-match-ambiguity-no-unbox.js new file mode 100644 index 00000000000..ea4c26d311c --- /dev/null +++ b/tests/rustdoc-js/generics-match-ambiguity-no-unbox.js @@ -0,0 +1,68 @@ +// ignore-order +// exact-check + +// Make sure that results are order-agnostic, even when there's search items that only differ +// by generics. + +const EXPECTED = [ + { + 'query': 'Wrap', + 'in_args': [ + { 'path': 'generics_match_ambiguity', 'name': 'bar' }, + { 'path': 'generics_match_ambiguity', 'name': 'foo' }, + ], + }, + { + 'query': 'Wrap', + 'in_args': [ + { 'path': 'generics_match_ambiguity', 'name': 'bar' }, + { 'path': 'generics_match_ambiguity', 'name': 'foo' }, + ], + }, + { + 'query': 'Wrap, Wrap', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'bar' }, + { 'path': 'generics_match_ambiguity', 'name': 'foo' }, + ], + }, + { + 'query': 'Wrap, Wrap', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'bar' }, + { 'path': 'generics_match_ambiguity', 'name': 'foo' }, + ], + }, + { + 'query': 'W3, W3', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'baaa' }, + { 'path': 'generics_match_ambiguity', 'name': 'baab' }, + ], + }, + { + 'query': 'W3, W3', + 'others': [ + { 'path': 'generics_match_ambiguity', 'name': 'baaa' }, + { 'path': 'generics_match_ambiguity', 'name': 'baab' }, + ], + }, + { + // strict generics matching; W2 doesn't match W2>, + // even though W2 works just fine (ignoring the W3) + 'query': 'W2, W2', + 'others': [], + }, + { + 'query': 'W2, W2', + 'others': [], + }, + { + 'query': 'W2, W3', + 'others': [], + }, + { + 'query': 'W2, W2', + 'others': [], + }, +]; -- cgit 1.4.1-3-g733a5