summaryrefslogtreecommitdiffstats
path: root/tests/rustdoc-js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:18:58 +0000
commita4b7ed7a42c716ab9f05e351f003d589124fd55d (patch)
treeb620cd3f223850b28716e474e80c58059dca5dd4 /tests/rustdoc-js
parentAdding upstream version 1.67.1+dfsg1. (diff)
downloadrustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.tar.xz
rustc-a4b7ed7a42c716ab9f05e351f003d589124fd55d.zip
Adding upstream version 1.68.2+dfsg1.upstream/1.68.2+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/rustdoc-js')
-rw-r--r--tests/rustdoc-js/basic.js7
-rw-r--r--tests/rustdoc-js/basic.rs2
-rw-r--r--tests/rustdoc-js/doc-alias-filter-out.js9
-rw-r--r--tests/rustdoc-js/doc-alias-filter-out.rs2
-rw-r--r--tests/rustdoc-js/doc-alias-filter.js17
-rw-r--r--tests/rustdoc-js/doc-alias-filter.rs5
-rw-r--r--tests/rustdoc-js/doc-alias-whitespace.js19
-rw-r--r--tests/rustdoc-js/doc-alias-whitespace.rs2
-rw-r--r--tests/rustdoc-js/doc-alias.js295
-rw-r--r--tests/rustdoc-js/doc-alias.rs75
-rw-r--r--tests/rustdoc-js/exact-match.js9
-rw-r--r--tests/rustdoc-js/exact-match.rs68
-rw-r--r--tests/rustdoc-js/foreign-type-path.js9
-rw-r--r--tests/rustdoc-js/foreign-type-path.rs13
-rw-r--r--tests/rustdoc-js/generics-impl.js57
-rw-r--r--tests/rustdoc-js/generics-impl.rs35
-rw-r--r--tests/rustdoc-js/generics-multi-trait.js32
-rw-r--r--tests/rustdoc-js/generics-multi-trait.rs12
-rw-r--r--tests/rustdoc-js/generics-trait.js23
-rw-r--r--tests/rustdoc-js/generics-trait.rs8
-rw-r--r--tests/rustdoc-js/generics.js73
-rw-r--r--tests/rustdoc-js/generics.rs28
-rw-r--r--tests/rustdoc-js/impl-trait.js51
-rw-r--r--tests/rustdoc-js/impl-trait.rs21
-rw-r--r--tests/rustdoc-js/module-substring.js9
-rw-r--r--tests/rustdoc-js/module-substring.rs68
-rw-r--r--tests/rustdoc-js/path-ordering.js14
-rw-r--r--tests/rustdoc-js/path-ordering.rs9
-rw-r--r--tests/rustdoc-js/primitive.js25
-rw-r--r--tests/rustdoc-js/primitive.rs5
-rw-r--r--tests/rustdoc-js/prototype.js16
-rw-r--r--tests/rustdoc-js/prototype.rs4
-rw-r--r--tests/rustdoc-js/raw-pointer.js55
-rw-r--r--tests/rustdoc-js/raw-pointer.rs24
-rw-r--r--tests/rustdoc-js/reexport.js17
-rw-r--r--tests/rustdoc-js/reexport.rs11
-rw-r--r--tests/rustdoc-js/search-short-types.js9
-rw-r--r--tests/rustdoc-js/search-short-types.rs74
-rw-r--r--tests/rustdoc-js/struct-like-variant.js7
-rw-r--r--tests/rustdoc-js/struct-like-variant.rs8
-rw-r--r--tests/rustdoc-js/substring.js8
-rw-r--r--tests/rustdoc-js/substring.rs21
-rw-r--r--tests/rustdoc-js/summaries.js21
-rw-r--r--tests/rustdoc-js/summaries.rs22
44 files changed, 1299 insertions, 0 deletions
diff --git a/tests/rustdoc-js/basic.js b/tests/rustdoc-js/basic.js
new file mode 100644
index 000000000..d99b23468
--- /dev/null
+++ b/tests/rustdoc-js/basic.js
@@ -0,0 +1,7 @@
+const QUERY = 'Fo';
+
+const EXPECTED = {
+ 'others': [
+ { 'path': 'basic', 'name': 'Foo' },
+ ],
+};
diff --git a/tests/rustdoc-js/basic.rs b/tests/rustdoc-js/basic.rs
new file mode 100644
index 000000000..da946a58b
--- /dev/null
+++ b/tests/rustdoc-js/basic.rs
@@ -0,0 +1,2 @@
+/// Docs for Foo
+pub struct Foo;
diff --git a/tests/rustdoc-js/doc-alias-filter-out.js b/tests/rustdoc-js/doc-alias-filter-out.js
new file mode 100644
index 000000000..46a089d06
--- /dev/null
+++ b/tests/rustdoc-js/doc-alias-filter-out.js
@@ -0,0 +1,9 @@
+// exact-check
+
+const QUERY = 'true';
+
+const FILTER_CRATE = 'some_other_crate';
+
+const EXPECTED = {
+ 'others': [],
+};
diff --git a/tests/rustdoc-js/doc-alias-filter-out.rs b/tests/rustdoc-js/doc-alias-filter-out.rs
new file mode 100644
index 000000000..3f0c09479
--- /dev/null
+++ b/tests/rustdoc-js/doc-alias-filter-out.rs
@@ -0,0 +1,2 @@
+#[doc(alias = "true")]
+pub struct Foo;
diff --git a/tests/rustdoc-js/doc-alias-filter.js b/tests/rustdoc-js/doc-alias-filter.js
new file mode 100644
index 000000000..e06047ba7
--- /dev/null
+++ b/tests/rustdoc-js/doc-alias-filter.js
@@ -0,0 +1,17 @@
+// exact-check
+
+const QUERY = '"true"';
+
+const FILTER_CRATE = 'doc_alias_filter';
+
+const EXPECTED = {
+ 'others': [
+ {
+ 'path': 'doc_alias_filter',
+ 'name': 'Foo',
+ 'alias': 'true',
+ 'href': '../doc_alias_filter/struct.Foo.html',
+ 'is_alias': true
+ },
+ ],
+};
diff --git a/tests/rustdoc-js/doc-alias-filter.rs b/tests/rustdoc-js/doc-alias-filter.rs
new file mode 100644
index 000000000..d5227814c
--- /dev/null
+++ b/tests/rustdoc-js/doc-alias-filter.rs
@@ -0,0 +1,5 @@
+#[doc(alias = "true")]
+pub struct Foo;
+
+#[doc(alias = "false")]
+pub struct Bar;
diff --git a/tests/rustdoc-js/doc-alias-whitespace.js b/tests/rustdoc-js/doc-alias-whitespace.js
new file mode 100644
index 000000000..c9fc0c431
--- /dev/null
+++ b/tests/rustdoc-js/doc-alias-whitespace.js
@@ -0,0 +1,19 @@
+// exact-check
+
+const QUERY = [
+ 'Demon Lord',
+];
+
+const EXPECTED = [
+ {
+ 'others': [
+ {
+ 'path': 'doc_alias_whitespace',
+ 'name': 'Struct',
+ 'alias': 'Demon Lord',
+ 'href': '../doc_alias_whitespace/struct.Struct.html',
+ 'is_alias': true
+ },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/doc-alias-whitespace.rs b/tests/rustdoc-js/doc-alias-whitespace.rs
new file mode 100644
index 000000000..16c022c74
--- /dev/null
+++ b/tests/rustdoc-js/doc-alias-whitespace.rs
@@ -0,0 +1,2 @@
+#[doc(alias = "Demon Lord")]
+pub struct Struct;
diff --git a/tests/rustdoc-js/doc-alias.js b/tests/rustdoc-js/doc-alias.js
new file mode 100644
index 000000000..7bb0cbe38
--- /dev/null
+++ b/tests/rustdoc-js/doc-alias.js
@@ -0,0 +1,295 @@
+// exact-check
+
+const QUERY = [
+ 'StructItem',
+ 'StructFieldItem',
+ 'StructMethodItem',
+ 'ImplTraitItem',
+ 'StructImplConstItem',
+ 'ImplTraitFunction',
+ 'EnumItem',
+ 'VariantItem',
+ 'EnumMethodItem',
+ 'TypedefItem',
+ 'TraitItem',
+ 'TraitTypeItem',
+ 'AssociatedConstItem',
+ 'TraitFunctionItem',
+ 'FunctionItem',
+ 'ModuleItem',
+ 'ConstItem',
+ 'StaticItem',
+ 'UnionItem',
+ 'UnionFieldItem',
+ 'UnionMethodItem',
+ 'MacroItem',
+];
+
+const EXPECTED = [
+ {
+ // StructItem
+ 'others': [
+ {
+ 'path': 'doc_alias',
+ 'name': 'Struct',
+ 'alias': 'StructItem',
+ 'href': '../doc_alias/struct.Struct.html',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // StructFieldItem
+ 'others': [
+ {
+ 'path': 'doc_alias::Struct',
+ 'name': 'field',
+ 'alias': 'StructFieldItem',
+ 'href': '../doc_alias/struct.Struct.html#structfield.field',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // StructMethodItem
+ 'others': [
+ {
+ 'path': 'doc_alias::Struct',
+ 'name': 'method',
+ 'alias': 'StructMethodItem',
+ 'href': '../doc_alias/struct.Struct.html#method.method',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // ImplTraitItem
+ 'others': [],
+ },
+ {
+ // StructImplConstItem
+ 'others': [
+ {
+ 'path': 'doc_alias::Struct',
+ 'name': 'ImplConstItem',
+ 'alias': 'StructImplConstItem',
+ 'href': '../doc_alias/struct.Struct.html#associatedconstant.ImplConstItem',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // ImplTraitFunction
+ 'others': [
+ {
+ 'path': 'doc_alias::Struct',
+ 'name': 'function',
+ 'alias': 'ImplTraitFunction',
+ 'href': '../doc_alias/struct.Struct.html#method.function',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // EnumItem
+ 'others': [
+ {
+ 'path': 'doc_alias',
+ 'name': 'Enum',
+ 'alias': 'EnumItem',
+ 'href': '../doc_alias/enum.Enum.html',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // VariantItem
+ 'others': [
+ {
+ 'path': 'doc_alias::Enum',
+ 'name': 'Variant',
+ 'alias': 'VariantItem',
+ 'href': '../doc_alias/enum.Enum.html#variant.Variant',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // EnumMethodItem
+ 'others': [
+ {
+ 'path': 'doc_alias::Enum',
+ 'name': 'method',
+ 'alias': 'EnumMethodItem',
+ 'href': '../doc_alias/enum.Enum.html#method.method',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // TypedefItem
+ 'others': [
+ {
+ 'path': 'doc_alias',
+ 'name': 'Typedef',
+ 'alias': 'TypedefItem',
+ 'href': '../doc_alias/type.Typedef.html',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // TraitItem
+ 'others': [
+ {
+ 'path': 'doc_alias',
+ 'name': 'Trait',
+ 'alias': 'TraitItem',
+ 'href': '../doc_alias/trait.Trait.html',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // TraitTypeItem
+ 'others': [
+ {
+ 'path': 'doc_alias::Trait',
+ 'name': 'Target',
+ 'alias': 'TraitTypeItem',
+ 'href': '../doc_alias/trait.Trait.html#associatedtype.Target',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // AssociatedConstItem
+ 'others': [
+ {
+ 'path': 'doc_alias::Trait',
+ 'name': 'AssociatedConst',
+ 'alias': 'AssociatedConstItem',
+ 'href': '../doc_alias/trait.Trait.html#associatedconstant.AssociatedConst',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // TraitFunctionItem
+ 'others': [
+ {
+ 'path': 'doc_alias::Trait',
+ 'name': 'function',
+ 'alias': 'TraitFunctionItem',
+ 'href': '../doc_alias/trait.Trait.html#tymethod.function',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // FunctionItem
+ 'others': [
+ {
+ 'path': 'doc_alias',
+ 'name': 'function',
+ 'alias': 'FunctionItem',
+ 'href': '../doc_alias/fn.function.html',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // ModuleItem
+ 'others': [
+ {
+ 'path': 'doc_alias',
+ 'name': 'Module',
+ 'alias': 'ModuleItem',
+ 'href': '../doc_alias/Module/index.html',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // ConstItem
+ 'others': [
+ {
+ 'path': 'doc_alias',
+ 'name': 'Const',
+ 'alias': 'ConstItem',
+ 'href': '../doc_alias/constant.Const.html',
+ 'is_alias': true
+ },
+ {
+ 'path': 'doc_alias::Struct',
+ 'name': 'ImplConstItem',
+ },
+ ],
+ },
+ {
+ // StaticItem
+ 'others': [
+ {
+ 'path': 'doc_alias',
+ 'name': 'Static',
+ 'alias': 'StaticItem',
+ 'href': '../doc_alias/static.Static.html',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // UnionItem
+ 'others': [
+ {
+ 'path': 'doc_alias',
+ 'name': 'Union',
+ 'alias': 'UnionItem',
+ 'href': '../doc_alias/union.Union.html',
+ 'is_alias': true
+ },
+ // Not an alias!
+ {
+ 'path': 'doc_alias::Union',
+ 'name': 'union_item',
+ 'href': '../doc_alias/union.Union.html#structfield.union_item'
+ },
+ ],
+ },
+ {
+ // UnionFieldItem
+ 'others': [
+ {
+ 'path': 'doc_alias::Union',
+ 'name': 'union_item',
+ 'alias': 'UnionFieldItem',
+ 'href': '../doc_alias/union.Union.html#structfield.union_item',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // UnionMethodItem
+ 'others': [
+ {
+ 'path': 'doc_alias::Union',
+ 'name': 'method',
+ 'alias': 'UnionMethodItem',
+ 'href': '../doc_alias/union.Union.html#method.method',
+ 'is_alias': true
+ },
+ ],
+ },
+ {
+ // MacroItem
+ 'others': [
+ {
+ 'path': 'doc_alias',
+ 'name': 'Macro',
+ 'alias': 'MacroItem',
+ 'href': '../doc_alias/macro.Macro.html',
+ 'is_alias': true
+ },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/doc-alias.rs b/tests/rustdoc-js/doc-alias.rs
new file mode 100644
index 000000000..750b7b757
--- /dev/null
+++ b/tests/rustdoc-js/doc-alias.rs
@@ -0,0 +1,75 @@
+#[doc(alias = "StructItem")]
+pub struct Struct {
+ #[doc(alias = "StructFieldItem")]
+ pub field: u32,
+}
+
+impl Struct {
+ #[doc(alias = "StructImplConstItem")]
+ pub const ImplConstItem: i32 = 0;
+ #[doc(alias = "StructMethodItem")]
+ pub fn method(&self) {}
+}
+
+impl Trait for Struct {
+ type Target = u32;
+ const AssociatedConst: i32 = 12;
+
+ #[doc(alias = "ImplTraitFunction")]
+ fn function() -> Self::Target { 0 }
+}
+
+#[doc(alias = "EnumItem")]
+pub enum Enum {
+ #[doc(alias = "VariantItem")]
+ Variant,
+}
+
+impl Enum {
+ #[doc(alias = "EnumMethodItem")]
+ pub fn method(&self) {}
+}
+
+#[doc(alias = "TypedefItem")]
+pub type Typedef = i32;
+
+#[doc(alias = "TraitItem")]
+pub trait Trait {
+ #[doc(alias = "TraitTypeItem")]
+ type Target;
+ #[doc(alias = "AssociatedConstItem")]
+ const AssociatedConst: i32;
+
+ #[doc(alias = "TraitFunctionItem")]
+ fn function() -> Self::Target;
+}
+
+#[doc(alias = "FunctionItem")]
+pub fn function() {}
+
+#[doc(alias = "ModuleItem")]
+pub mod Module {}
+
+#[doc(alias = "ConstItem")]
+pub const Const: u32 = 0;
+
+#[doc(alias = "StaticItem")]
+pub static Static: u32 = 0;
+
+#[doc(alias = "UnionItem")]
+pub union Union {
+ #[doc(alias = "UnionFieldItem")]
+ pub union_item: u32,
+ pub y: f32,
+}
+
+impl Union {
+ #[doc(alias = "UnionMethodItem")]
+ pub fn method(&self) {}
+}
+
+#[doc(alias = "MacroItem")]
+#[macro_export]
+macro_rules! Macro {
+ () => {}
+}
diff --git a/tests/rustdoc-js/exact-match.js b/tests/rustdoc-js/exact-match.js
new file mode 100644
index 000000000..b0a411bee
--- /dev/null
+++ b/tests/rustdoc-js/exact-match.js
@@ -0,0 +1,9 @@
+const QUERY = 'si::pc';
+
+const EXPECTED = {
+ 'others': [
+ { 'path': 'exact_match::Si', 'name': 'pc' },
+ { 'path': 'exact_match::Psi', 'name': 'pc' },
+ { 'path': 'exact_match::Si', 'name': 'pa' },
+ ],
+};
diff --git a/tests/rustdoc-js/exact-match.rs b/tests/rustdoc-js/exact-match.rs
new file mode 100644
index 000000000..2eacc0a35
--- /dev/null
+++ b/tests/rustdoc-js/exact-match.rs
@@ -0,0 +1,68 @@
+macro_rules! imp {
+ ($name:ident) => {
+ pub struct $name {
+ pub op: usize,
+ }
+ impl $name {
+ pub fn op() {}
+ pub fn cmp() {}
+ pub fn map() {}
+ pub fn pop() {}
+ pub fn ptr() {}
+ pub fn rpo() {}
+ pub fn drop() {}
+ pub fn copy() {}
+ pub fn zip() {}
+ pub fn sup() {}
+ pub fn pa() {}
+ pub fn pb() {}
+ pub fn pc() {}
+ pub fn pd() {}
+ pub fn pe() {}
+ pub fn pf() {}
+ pub fn pg() {}
+ pub fn ph() {}
+ pub fn pi() {}
+ pub fn pj() {}
+ pub fn pk() {}
+ pub fn pl() {}
+ pub fn pm() {}
+ pub fn pn() {}
+ pub fn po() {}
+ }
+ };
+ ($name:ident, $($names:ident),*) => {
+ imp!($name);
+ imp!($($names),*);
+ };
+}
+macro_rules! en {
+ ($name:ident) => {
+ pub enum $name {
+ Ptr,
+ Rp,
+ Rpo,
+ Pt,
+ Drop,
+ Dr,
+ Dro,
+ Sup,
+ Op,
+ Cmp,
+ Map,
+ Mp,
+ }
+ };
+ ($name:ident, $($names:ident),*) => {
+ en!($name);
+ en!($($names),*);
+ };
+}
+
+imp!(Ot, Foo, Cmp, Map, Loc, Lac, Toc, Si, Sig, Sip, Psy, Psi, Py, Pi, Pa, Pb, Pc, Pd);
+imp!(Pe, Pf, Pg, Ph, Pj, Pk, Pl, Pm, Pn, Po, Pq, Pr, Ps, Pt, Pu, Pv, Pw, Px, Pz, Ap, Bp, Cp);
+imp!(Dp, Ep, Fp, Gp, Hp, Ip, Jp, Kp, Lp, Mp, Np, Op, Pp, Qp, Rp, Sp, Tp, Up, Vp, Wp, Xp, Yp, Zp);
+
+en!(Place, Plac, Plae, Plce, Pace, Scalar, Scalr, Scaar, Sclar, Salar);
+
+pub struct P;
diff --git a/tests/rustdoc-js/foreign-type-path.js b/tests/rustdoc-js/foreign-type-path.js
new file mode 100644
index 000000000..334761bad
--- /dev/null
+++ b/tests/rustdoc-js/foreign-type-path.js
@@ -0,0 +1,9 @@
+const QUERY = 'MyForeignType::my_method';
+
+const EXPECTED = {
+ 'others': [
+ // Test case for https://github.com/rust-lang/rust/pull/96887#pullrequestreview-967154358
+ // Validates that the parent path for a foreign type method is correct.
+ { 'path': 'foreign_type_path::aaaaaaa::MyForeignType', 'name': 'my_method' },
+ ],
+};
diff --git a/tests/rustdoc-js/foreign-type-path.rs b/tests/rustdoc-js/foreign-type-path.rs
new file mode 100644
index 000000000..83400104e
--- /dev/null
+++ b/tests/rustdoc-js/foreign-type-path.rs
@@ -0,0 +1,13 @@
+#![feature(extern_types)]
+
+pub mod aaaaaaa {
+
+ extern {
+ pub type MyForeignType;
+ }
+
+ impl MyForeignType {
+ pub fn my_method() {}
+ }
+
+}
diff --git a/tests/rustdoc-js/generics-impl.js b/tests/rustdoc-js/generics-impl.js
new file mode 100644
index 000000000..bb6e0041d
--- /dev/null
+++ b/tests/rustdoc-js/generics-impl.js
@@ -0,0 +1,57 @@
+// exact-check
+
+const QUERY = [
+ 'Aaaaaaa -> u32',
+ 'Aaaaaaa -> bool',
+ 'Aaaaaaa -> usize',
+ 'Read -> u64',
+ 'bool -> u64',
+ 'Ddddddd -> u64',
+ '-> Ddddddd'
+];
+
+const EXPECTED = [
+ {
+ // Aaaaaaa -> u32
+ 'others': [
+ { 'path': 'generics_impl::Aaaaaaa', 'name': 'bbbbbbb' },
+ ],
+ },
+ {
+ // Aaaaaaa -> bool
+ 'others': [
+ { 'path': 'generics_impl::Aaaaaaa', 'name': 'ccccccc' },
+ ],
+ },
+ {
+ // Aaaaaaa -> usize
+ 'others': [
+ { 'path': 'generics_impl::Aaaaaaa', 'name': 'read' },
+ ],
+ },
+ {
+ // Read -> u64
+ 'others': [
+ { 'path': 'generics_impl::Ddddddd', 'name': 'eeeeeee' },
+ { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' },
+ ],
+ },
+ {
+ // bool -> u64
+ 'others': [
+ { 'path': 'generics_impl::Ddddddd', 'name': 'fffffff' },
+ ],
+ },
+ {
+ // Ddddddd -> u64
+ 'others': [
+ { 'path': 'generics_impl::Ddddddd', 'name': 'ggggggg' },
+ ],
+ },
+ {
+ // -> Ddddddd
+ 'others': [
+ { 'path': 'generics_impl::Ddddddd', 'name': 'hhhhhhh' },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/generics-impl.rs b/tests/rustdoc-js/generics-impl.rs
new file mode 100644
index 000000000..696218021
--- /dev/null
+++ b/tests/rustdoc-js/generics-impl.rs
@@ -0,0 +1,35 @@
+use std::io::{Result as IoResult, Read};
+
+pub struct Aaaaaaa;
+
+impl Aaaaaaa {
+ pub fn bbbbbbb(self) -> u32 {
+ 1
+ }
+ pub fn ccccccc(&self) -> bool {
+ true
+ }
+}
+
+impl Read for Aaaaaaa {
+ fn read(&mut self, out: &mut [u8]) -> IoResult<usize> {
+ Ok(out.len())
+ }
+}
+
+pub struct Ddddddd<T>(T);
+
+impl<T: Read> Ddddddd<T> {
+ pub fn eeeeeee(_: T) -> u64 {
+ 1
+ }
+ pub fn fffffff(_: bool) -> u64 {
+ 1
+ }
+ pub fn ggggggg(self) -> u64 {
+ 1
+ }
+ pub fn hhhhhhh() -> Self where T: Default {
+ Ddddddd(T::default())
+ }
+}
diff --git a/tests/rustdoc-js/generics-multi-trait.js b/tests/rustdoc-js/generics-multi-trait.js
new file mode 100644
index 000000000..e7fcea876
--- /dev/null
+++ b/tests/rustdoc-js/generics-multi-trait.js
@@ -0,0 +1,32 @@
+// exact-check
+
+const QUERY = [
+ 'Result<SomeTrait>',
+ 'Zzzzzzzzzzzzzzzzzz',
+ 'Nonononononononono',
+];
+
+const EXPECTED = [
+ // check one of the generic items
+ {
+ 'in_args': [
+ { 'path': 'generics_multi_trait', 'name': 'beta' },
+ ],
+ 'returned': [
+ { 'path': 'generics_multi_trait', 'name': 'bet' },
+ ],
+ },
+ {
+ 'in_args': [
+ { 'path': 'generics_multi_trait', 'name': 'beta' },
+ ],
+ 'returned': [
+ { 'path': 'generics_multi_trait', 'name': 'bet' },
+ ],
+ },
+ // ignore the name of the generic itself
+ {
+ 'in_args': [],
+ 'returned': [],
+ },
+];
diff --git a/tests/rustdoc-js/generics-multi-trait.rs b/tests/rustdoc-js/generics-multi-trait.rs
new file mode 100644
index 000000000..e6fd06d25
--- /dev/null
+++ b/tests/rustdoc-js/generics-multi-trait.rs
@@ -0,0 +1,12 @@
+pub trait SomeTrait {}
+pub trait Zzzzzzzzzzzzzzzzzz {}
+
+pub fn bet<Nonononononononono: SomeTrait + Zzzzzzzzzzzzzzzzzz>() -> Result<Nonononononononono, ()> {
+ loop {}
+}
+
+pub fn beta<Nonononononononono: SomeTrait + Zzzzzzzzzzzzzzzzzz>(
+ _param: Result<Nonononononononono, ()>,
+) {
+ loop {}
+}
diff --git a/tests/rustdoc-js/generics-trait.js b/tests/rustdoc-js/generics-trait.js
new file mode 100644
index 000000000..787662243
--- /dev/null
+++ b/tests/rustdoc-js/generics-trait.js
@@ -0,0 +1,23 @@
+const QUERY = [
+ 'Result<SomeTrait>',
+ 'OtherThingxxxxxxxx',
+];
+
+const EXPECTED = [
+ {
+ 'in_args': [
+ { 'path': 'generics_trait', 'name': 'beta' },
+ ],
+ 'returned': [
+ { 'path': 'generics_trait', 'name': 'bet' },
+ ],
+ },
+ {
+ 'in_args': [
+ { 'path': 'generics_trait', 'name': 'alpha' },
+ ],
+ 'returned': [
+ { 'path': 'generics_trait', 'name': 'alef' },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/generics-trait.rs b/tests/rustdoc-js/generics-trait.rs
new file mode 100644
index 000000000..20db117cc
--- /dev/null
+++ b/tests/rustdoc-js/generics-trait.rs
@@ -0,0 +1,8 @@
+pub trait SomeTrait {}
+pub trait OtherThingxxxxxxxx {}
+
+pub fn alef<T: OtherThingxxxxxxxx>() -> Result<T, ()> { loop {} }
+pub fn bet<T: SomeTrait>() -> Result<T, ()> { loop {} }
+
+pub fn alpha<T: OtherThingxxxxxxxx>(_param: Result<T, ()>) { loop {} }
+pub fn beta<T: SomeTrait>(_param: Result<T, ()>) { loop {} }
diff --git a/tests/rustdoc-js/generics.js b/tests/rustdoc-js/generics.js
new file mode 100644
index 000000000..5e5ba7cd9
--- /dev/null
+++ b/tests/rustdoc-js/generics.js
@@ -0,0 +1,73 @@
+// exact-check
+
+const QUERY = [
+ 'R<P>',
+ '"P"',
+ 'P',
+ 'ExtraCreditStructMulti<ExtraCreditInnerMulti, ExtraCreditInnerMulti>',
+ 'TraitCat',
+ 'TraitDog',
+ 'Result<String>',
+];
+
+const EXPECTED = [
+ {
+ // R<P>
+ 'returned': [
+ { 'path': 'generics', 'name': 'alef' },
+ ],
+ 'in_args': [
+ { 'path': 'generics', 'name': 'alpha' },
+ ],
+ },
+ {
+ // "P"
+ 'others': [
+ { 'path': 'generics', 'name': 'P' },
+ ],
+ 'returned': [
+ { 'path': 'generics', 'name': 'alef' },
+ ],
+ 'in_args': [
+ { 'path': 'generics', 'name': 'alpha' },
+ ],
+ },
+ {
+ // P
+ 'returned': [
+ { 'path': 'generics', 'name': 'alef' },
+ ],
+ 'in_args': [
+ { 'path': 'generics', 'name': 'alpha' },
+ ],
+ },
+ {
+ // "ExtraCreditStructMulti"<ExtraCreditInnerMulti, ExtraCreditInnerMulti>
+ 'in_args': [
+ { 'path': 'generics', 'name': 'extracreditlabhomework' },
+ ],
+ 'returned': [],
+ },
+ {
+ // TraitCat
+ 'in_args': [
+ { 'path': 'generics', 'name': 'gamma' },
+ ],
+ },
+ {
+ // TraitDog
+ 'in_args': [
+ { 'path': 'generics', 'name': 'gamma' },
+ ],
+ },
+ {
+ // Result<String>
+ 'others': [],
+ 'returned': [
+ { 'path': 'generics', 'name': 'super_soup' },
+ ],
+ 'in_args': [
+ { 'path': 'generics', 'name': 'super_soup' },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/generics.rs b/tests/rustdoc-js/generics.rs
new file mode 100644
index 000000000..055c51c7e
--- /dev/null
+++ b/tests/rustdoc-js/generics.rs
@@ -0,0 +1,28 @@
+pub struct P;
+pub struct Q;
+pub struct R<T>(T);
+
+// returns test
+pub fn alef() -> R<P> { loop {} }
+pub fn bet() -> R<Q> { loop {} }
+
+// in_args test
+pub fn alpha(_x: R<P>) { loop {} }
+pub fn beta(_x: R<Q>) { loop {} }
+
+// test case with multiple appearances of the same type
+pub struct ExtraCreditStructMulti<T, U> { t: T, u: U }
+pub struct ExtraCreditInnerMulti {}
+pub fn extracreditlabhomework(
+ _param: ExtraCreditStructMulti<ExtraCreditInnerMulti, ExtraCreditInnerMulti>
+) { loop {} }
+pub fn redherringmatchforextracredit(
+ _param: ExtraCreditStructMulti<ExtraCreditInnerMulti, ()>
+) { loop {} }
+
+pub trait TraitCat {}
+pub trait TraitDog {}
+
+pub fn gamma<T: TraitCat + TraitDog>(t: T) {}
+
+pub fn super_soup(s: Result<String, i32>) -> Result<String, i32> { s }
diff --git a/tests/rustdoc-js/impl-trait.js b/tests/rustdoc-js/impl-trait.js
new file mode 100644
index 000000000..8d594bf8a
--- /dev/null
+++ b/tests/rustdoc-js/impl-trait.js
@@ -0,0 +1,51 @@
+// ignore-order
+
+const QUERY = [
+ 'Aaaaaaa -> i32',
+ 'Aaaaaaa -> Aaaaaaa',
+ 'Aaaaaaa -> usize',
+ '-> Aaaaaaa',
+ 'Aaaaaaa',
+];
+
+const EXPECTED = [
+ {
+ // Aaaaaaa -> i32
+ 'others': [
+ { 'path': 'impl_trait::Ccccccc', 'name': 'eeeeeee' },
+ ],
+ },
+ {
+ // Aaaaaaa -> Aaaaaaa
+ 'others': [
+ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
+ ],
+ },
+ {
+ // Aaaaaaa -> usize
+ 'others': [],
+ },
+ {
+ // -> Aaaaaaa
+ 'others': [
+ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' },
+ { 'path': 'impl_trait', 'name': 'bbbbbbb' },
+ ],
+ },
+ {
+ // Aaaaaaa
+ 'others': [
+ { 'path': 'impl_trait', 'name': 'Aaaaaaa' },
+ ],
+ 'in_args': [
+ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'eeeeeee' },
+ ],
+ 'returned': [
+ { 'path': 'impl_trait::Ccccccc', 'name': 'fffffff' },
+ { 'path': 'impl_trait::Ccccccc', 'name': 'ddddddd' },
+ { 'path': 'impl_trait', 'name': 'bbbbbbb' },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/impl-trait.rs b/tests/rustdoc-js/impl-trait.rs
new file mode 100644
index 000000000..fb8869b46
--- /dev/null
+++ b/tests/rustdoc-js/impl-trait.rs
@@ -0,0 +1,21 @@
+pub trait Aaaaaaa {}
+
+impl Aaaaaaa for () {}
+
+pub fn bbbbbbb() -> impl Aaaaaaa {
+ ()
+}
+
+pub struct Ccccccc {}
+
+impl Ccccccc {
+ pub fn ddddddd(&self) -> impl Aaaaaaa {
+ ()
+ }
+ pub fn eeeeeee(&self, _x: impl Aaaaaaa) -> i32 {
+ 0
+ }
+ pub fn fffffff(&self, x: impl Aaaaaaa) -> impl Aaaaaaa {
+ x
+ }
+}
diff --git a/tests/rustdoc-js/module-substring.js b/tests/rustdoc-js/module-substring.js
new file mode 100644
index 000000000..a446c39eb
--- /dev/null
+++ b/tests/rustdoc-js/module-substring.js
@@ -0,0 +1,9 @@
+const QUERY = 'ig::pc';
+
+const EXPECTED = {
+ 'others': [
+ { 'path': 'module_substring::Sig', 'name': 'pc' },
+ { 'path': 'module_substring::Si', 'name': 'pc' },
+ { 'path': 'module_substring::Si', 'name': 'pa' },
+ ],
+};
diff --git a/tests/rustdoc-js/module-substring.rs b/tests/rustdoc-js/module-substring.rs
new file mode 100644
index 000000000..2eacc0a35
--- /dev/null
+++ b/tests/rustdoc-js/module-substring.rs
@@ -0,0 +1,68 @@
+macro_rules! imp {
+ ($name:ident) => {
+ pub struct $name {
+ pub op: usize,
+ }
+ impl $name {
+ pub fn op() {}
+ pub fn cmp() {}
+ pub fn map() {}
+ pub fn pop() {}
+ pub fn ptr() {}
+ pub fn rpo() {}
+ pub fn drop() {}
+ pub fn copy() {}
+ pub fn zip() {}
+ pub fn sup() {}
+ pub fn pa() {}
+ pub fn pb() {}
+ pub fn pc() {}
+ pub fn pd() {}
+ pub fn pe() {}
+ pub fn pf() {}
+ pub fn pg() {}
+ pub fn ph() {}
+ pub fn pi() {}
+ pub fn pj() {}
+ pub fn pk() {}
+ pub fn pl() {}
+ pub fn pm() {}
+ pub fn pn() {}
+ pub fn po() {}
+ }
+ };
+ ($name:ident, $($names:ident),*) => {
+ imp!($name);
+ imp!($($names),*);
+ };
+}
+macro_rules! en {
+ ($name:ident) => {
+ pub enum $name {
+ Ptr,
+ Rp,
+ Rpo,
+ Pt,
+ Drop,
+ Dr,
+ Dro,
+ Sup,
+ Op,
+ Cmp,
+ Map,
+ Mp,
+ }
+ };
+ ($name:ident, $($names:ident),*) => {
+ en!($name);
+ en!($($names),*);
+ };
+}
+
+imp!(Ot, Foo, Cmp, Map, Loc, Lac, Toc, Si, Sig, Sip, Psy, Psi, Py, Pi, Pa, Pb, Pc, Pd);
+imp!(Pe, Pf, Pg, Ph, Pj, Pk, Pl, Pm, Pn, Po, Pq, Pr, Ps, Pt, Pu, Pv, Pw, Px, Pz, Ap, Bp, Cp);
+imp!(Dp, Ep, Fp, Gp, Hp, Ip, Jp, Kp, Lp, Mp, Np, Op, Pp, Qp, Rp, Sp, Tp, Up, Vp, Wp, Xp, Yp, Zp);
+
+en!(Place, Plac, Plae, Plce, Pace, Scalar, Scalr, Scaar, Sclar, Salar);
+
+pub struct P;
diff --git a/tests/rustdoc-js/path-ordering.js b/tests/rustdoc-js/path-ordering.js
new file mode 100644
index 000000000..4aee569b0
--- /dev/null
+++ b/tests/rustdoc-js/path-ordering.js
@@ -0,0 +1,14 @@
+// exact-check
+
+const QUERY = 'b::ccccccc';
+
+const EXPECTED = {
+ 'others': [
+ // `ccccccc` is an exact match for all three of these.
+ // However `b` is a closer match for `bb` than for any
+ // of the others, so it ought to go first.
+ { 'path': 'path_ordering::bb', 'name': 'Ccccccc' },
+ { 'path': 'path_ordering::aa', 'name': 'Ccccccc' },
+ { 'path': 'path_ordering::dd', 'name': 'Ccccccc' },
+ ],
+};
diff --git a/tests/rustdoc-js/path-ordering.rs b/tests/rustdoc-js/path-ordering.rs
new file mode 100644
index 000000000..7843cf7f9
--- /dev/null
+++ b/tests/rustdoc-js/path-ordering.rs
@@ -0,0 +1,9 @@
+pub mod dd {
+ pub struct Ccccccc;
+}
+pub mod aa {
+ pub struct Ccccccc;
+}
+pub mod bb {
+ pub struct Ccccccc;
+}
diff --git a/tests/rustdoc-js/primitive.js b/tests/rustdoc-js/primitive.js
new file mode 100644
index 000000000..918f70999
--- /dev/null
+++ b/tests/rustdoc-js/primitive.js
@@ -0,0 +1,25 @@
+// exact-check
+
+const QUERY = [
+ "i32",
+ "str",
+ "TotoIsSomewhere",
+];
+
+const EXPECTED = [
+ {
+ 'in_args': [
+ { 'path': 'primitive', 'name': 'foo' },
+ ],
+ },
+ {
+ 'returned': [
+ { 'path': 'primitive', 'name': 'foo' },
+ ],
+ },
+ {
+ 'others': [],
+ 'in_args': [],
+ 'returned': [],
+ },
+];
diff --git a/tests/rustdoc-js/primitive.rs b/tests/rustdoc-js/primitive.rs
new file mode 100644
index 000000000..2b30ccf15
--- /dev/null
+++ b/tests/rustdoc-js/primitive.rs
@@ -0,0 +1,5 @@
+pub fn foo(i: i32) -> &'static str {
+ "hello"
+}
+
+pub fn foo2<TotoIsSomewhere>(i: &TotoIsSomewhere, j: TotoIsSomewhere) {}
diff --git a/tests/rustdoc-js/prototype.js b/tests/rustdoc-js/prototype.js
new file mode 100644
index 000000000..2f1d841c3
--- /dev/null
+++ b/tests/rustdoc-js/prototype.js
@@ -0,0 +1,16 @@
+// exact-check
+
+const QUERY = ['constructor', '__proto__'];
+
+const EXPECTED = [
+ {
+ 'others': [],
+ 'returned': [],
+ 'in_args': [],
+ },
+ {
+ 'others': [],
+ 'returned': [],
+ 'in_args': [],
+ },
+];
diff --git a/tests/rustdoc-js/prototype.rs b/tests/rustdoc-js/prototype.rs
new file mode 100644
index 000000000..5f6d73cc1
--- /dev/null
+++ b/tests/rustdoc-js/prototype.rs
@@ -0,0 +1,4 @@
+// The alias needed to be there to reproduce the bug
+// that used to be here.
+#[doc(alias="other_alias")]
+pub fn something_else() {}
diff --git a/tests/rustdoc-js/raw-pointer.js b/tests/rustdoc-js/raw-pointer.js
new file mode 100644
index 000000000..140b955ea
--- /dev/null
+++ b/tests/rustdoc-js/raw-pointer.js
@@ -0,0 +1,55 @@
+// ignore-order
+
+const QUERY = [
+ 'Aaaaaaa -> i32',
+ 'Aaaaaaa -> Aaaaaaa',
+ 'Aaaaaaa -> usize',
+ '-> Aaaaaaa',
+ 'Aaaaaaa',
+];
+
+const EXPECTED = [
+ {
+ // Aaaaaaa -> i32
+ 'others': [
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'eeeeeee' },
+ ],
+ },
+ {
+ // Aaaaaaa -> Aaaaaaa
+ 'others': [
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'fffffff' },
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'ggggggg' },
+ ],
+ },
+ {
+ // Aaaaaaa -> usize
+ 'others': [],
+ },
+ {
+ // -> Aaaaaaa
+ 'others': [
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'fffffff' },
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'ggggggg' },
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'ddddddd' },
+ { 'path': 'raw_pointer', 'name': 'bbbbbbb' },
+ ],
+ },
+ {
+ // Aaaaaaa
+ 'others': [
+ { 'path': 'raw_pointer', 'name': 'Aaaaaaa' },
+ ],
+ 'in_args': [
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'fffffff' },
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'ggggggg' },
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'eeeeeee' },
+ ],
+ 'returned': [
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'fffffff' },
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'ggggggg' },
+ { 'path': 'raw_pointer::Ccccccc', 'name': 'ddddddd' },
+ { 'path': 'raw_pointer', 'name': 'bbbbbbb' },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/raw-pointer.rs b/tests/rustdoc-js/raw-pointer.rs
new file mode 100644
index 000000000..b8ace2e0b
--- /dev/null
+++ b/tests/rustdoc-js/raw-pointer.rs
@@ -0,0 +1,24 @@
+use std::ptr;
+
+pub struct Aaaaaaa {}
+
+pub fn bbbbbbb() -> *const Aaaaaaa {
+ ptr::null()
+}
+
+pub struct Ccccccc {}
+
+impl Ccccccc {
+ pub fn ddddddd(&self) -> *const Aaaaaaa {
+ ptr::null()
+ }
+ pub fn eeeeeee(&self, _x: *const Aaaaaaa) -> i32 {
+ 0
+ }
+ pub fn fffffff(&self, x: *const Aaaaaaa) -> *const Aaaaaaa {
+ x
+ }
+ pub fn ggggggg(&self, x: *mut Aaaaaaa) -> *mut Aaaaaaa {
+ x
+ }
+}
diff --git a/tests/rustdoc-js/reexport.js b/tests/rustdoc-js/reexport.js
new file mode 100644
index 000000000..871e75d9b
--- /dev/null
+++ b/tests/rustdoc-js/reexport.js
@@ -0,0 +1,17 @@
+// exact-check
+
+const QUERY = ['Subscriber', 'AnotherOne'];
+
+const EXPECTED = [
+ {
+ 'others': [
+ { 'path': 'reexport::fmt', 'name': 'Subscriber' },
+ { 'path': 'reexport', 'name': 'FmtSubscriber' },
+ ],
+ },
+ {
+ 'others': [
+ { 'path': 'reexport', 'name': 'AnotherOne' },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/reexport.rs b/tests/rustdoc-js/reexport.rs
new file mode 100644
index 000000000..d69b2901e
--- /dev/null
+++ b/tests/rustdoc-js/reexport.rs
@@ -0,0 +1,11 @@
+// This test enforces that the (renamed) reexports are present in the search results.
+
+pub mod fmt {
+ pub struct Subscriber;
+}
+mod foo {
+ pub struct AnotherOne;
+}
+
+pub use foo::AnotherOne;
+pub use fmt::Subscriber as FmtSubscriber;
diff --git a/tests/rustdoc-js/search-short-types.js b/tests/rustdoc-js/search-short-types.js
new file mode 100644
index 000000000..3b2f15a40
--- /dev/null
+++ b/tests/rustdoc-js/search-short-types.js
@@ -0,0 +1,9 @@
+const QUERY = 'P';
+
+const EXPECTED = {
+ 'others': [
+ { 'path': 'search_short_types', 'name': 'P' },
+ { 'path': 'search_short_types::VeryLongTypeName', 'name': 'p' },
+ { 'path': 'search_short_types', 'name': 'Pa' },
+ ],
+};
diff --git a/tests/rustdoc-js/search-short-types.rs b/tests/rustdoc-js/search-short-types.rs
new file mode 100644
index 000000000..a4083f9a7
--- /dev/null
+++ b/tests/rustdoc-js/search-short-types.rs
@@ -0,0 +1,74 @@
+macro_rules! imp {
+ ($name:ident) => {
+ pub struct $name {
+ pub op: usize,
+ }
+ impl $name {
+ pub fn op() {}
+ pub fn cmp() {}
+ pub fn map() {}
+ pub fn pop() {}
+ pub fn ptr() {}
+ pub fn rpo() {}
+ pub fn drop() {}
+ pub fn copy() {}
+ pub fn zip() {}
+ pub fn sup() {}
+ pub fn pa() {}
+ pub fn pb() {}
+ pub fn pc() {}
+ pub fn pd() {}
+ pub fn pe() {}
+ pub fn pf() {}
+ pub fn pg() {}
+ pub fn ph() {}
+ pub fn pi() {}
+ pub fn pj() {}
+ pub fn pk() {}
+ pub fn pl() {}
+ pub fn pm() {}
+ pub fn pn() {}
+ pub fn po() {}
+ }
+ };
+ ($name:ident, $($names:ident),*) => {
+ imp!($name);
+ imp!($($names),*);
+ };
+}
+macro_rules! en {
+ ($name:ident) => {
+ pub enum $name {
+ Ptr,
+ Rp,
+ Rpo,
+ Pt,
+ Drop,
+ Dr,
+ Dro,
+ Sup,
+ Op,
+ Cmp,
+ Map,
+ Mp,
+ }
+ };
+ ($name:ident, $($names:ident),*) => {
+ en!($name);
+ en!($($names),*);
+ };
+}
+
+imp!(Ot, Foo, Cmp, Map, Loc, Lac, Toc, Si, Sig, Sip, Psy, Psi, Py, Pi, Pa, Pb, Pc, Pd);
+imp!(Pe, Pf, Pg, Ph, Pj, Pk, Pl, Pm, Pn, Po, Pq, Pr, Ps, Pt, Pu, Pv, Pw, Px, Pz, Ap, Bp, Cp);
+imp!(Dp, Ep, Fp, Gp, Hp, Ip, Jp, Kp, Lp, Mp, Np, Op, Pp, Qp, Rp, Sp, Tp, Up, Vp, Wp, Xp, Yp, Zp);
+
+en!(Place, Plac, Plae, Plce, Pace, Scalar, Scalr, Scaar, Sclar, Salar);
+
+pub struct P;
+
+pub struct VeryLongTypeName;
+impl VeryLongTypeName {
+ pub fn p() {}
+ pub fn ap() {}
+}
diff --git a/tests/rustdoc-js/struct-like-variant.js b/tests/rustdoc-js/struct-like-variant.js
new file mode 100644
index 000000000..f6deea51e
--- /dev/null
+++ b/tests/rustdoc-js/struct-like-variant.js
@@ -0,0 +1,7 @@
+const QUERY = 'name';
+
+const EXPECTED = {
+ 'others': [
+ { 'path': 'struct_like_variant::Enum::Bar', 'name': 'name', 'desc': 'This is a name.' },
+ ],
+};
diff --git a/tests/rustdoc-js/struct-like-variant.rs b/tests/rustdoc-js/struct-like-variant.rs
new file mode 100644
index 000000000..2f52a319a
--- /dev/null
+++ b/tests/rustdoc-js/struct-like-variant.rs
@@ -0,0 +1,8 @@
+#![crate_name = "struct_like_variant"]
+
+pub enum Enum {
+ Bar {
+ /// This is a name.
+ name: String
+ }
+}
diff --git a/tests/rustdoc-js/substring.js b/tests/rustdoc-js/substring.js
new file mode 100644
index 000000000..af05cd1ad
--- /dev/null
+++ b/tests/rustdoc-js/substring.js
@@ -0,0 +1,8 @@
+const QUERY = 'waker_from';
+
+const EXPECTED = {
+ 'others': [
+ { 'path': 'substring::SuperWaker', 'name': 'local_waker_from_nonlocal' },
+ { 'path': 'substring::SuperWakerTask', 'name': 'local_waker_from_nonlocal' },
+ ],
+};
diff --git a/tests/rustdoc-js/substring.rs b/tests/rustdoc-js/substring.rs
new file mode 100644
index 000000000..e729c722c
--- /dev/null
+++ b/tests/rustdoc-js/substring.rs
@@ -0,0 +1,21 @@
+pub struct SuperWaker;
+
+impl SuperWaker {
+ pub fn local_waker_from_nonlocal() {}
+ pub fn local_waker_frm_nonlocal() {}
+ pub fn some_method() {}
+ pub fn some_other_method() {}
+ pub fn waker_non_local() {}
+ pub fn from_non_local() {}
+}
+
+pub struct SuperWakerTask;
+
+impl SuperWakerTask {
+ pub fn local_waker_from_nonlocal() {}
+ pub fn local_waker_frm_nonlocal() {}
+ pub fn some_method() {}
+ pub fn some_other_method() {}
+ pub fn waker_non_local() {}
+ pub fn from_non_local() {}
+}
diff --git a/tests/rustdoc-js/summaries.js b/tests/rustdoc-js/summaries.js
new file mode 100644
index 000000000..dfb11e804
--- /dev/null
+++ b/tests/rustdoc-js/summaries.js
@@ -0,0 +1,21 @@
+// ignore-tidy-linelength
+
+const QUERY = ['summaries', 'summaries::Sidebar', 'summaries::Sidebar2'];
+
+const EXPECTED = [
+ {
+ 'others': [
+ { 'path': '', 'name': 'summaries', 'desc': 'This <em>summary</em> has a link, [<code>code</code>], and <code>Sidebar2</code> intra-doc.' },
+ ],
+ },
+ {
+ 'others': [
+ { 'path': 'summaries', 'name': 'Sidebar', 'desc': 'This <code>code</code> will be rendered in a code tag.' },
+ ],
+ },
+ {
+ 'others': [
+ { 'path': 'summaries', 'name': 'Sidebar2', 'desc': '' },
+ ],
+ },
+];
diff --git a/tests/rustdoc-js/summaries.rs b/tests/rustdoc-js/summaries.rs
new file mode 100644
index 000000000..1ee1c34aa
--- /dev/null
+++ b/tests/rustdoc-js/summaries.rs
@@ -0,0 +1,22 @@
+#![crate_type = "lib"]
+#![crate_name = "summaries"]
+
+#![allow(rustdoc::broken_intra_doc_links)]
+
+//! This *summary* has a [link], [`code`], and [`Sidebar2`] intra-doc.
+//!
+//! This is the second paragraph. It should not be rendered.
+//! To test that intra-doc links are resolved properly, [`code`] should render
+//! the square brackets, and [`Sidebar2`] should not.
+//!
+//! [link]: https://example.com
+
+/// This `code` will be rendered in a code tag.
+///
+/// This text should not be rendered.
+pub struct Sidebar;
+
+/// ```text
+/// this block should not be rendered
+/// ```
+pub struct Sidebar2;