diff --git a/src/compiletest/header.rs b/src/compiletest/header.rs index 6efe6e608e8ad..4e6e7d07e74cb 100644 --- a/src/compiletest/header.rs +++ b/src/compiletest/header.rs @@ -36,6 +36,8 @@ pub struct TestProps { pub check_lines: Vec , // Build documentation for all specified aux-builds as well pub build_aux_docs: bool, + // Check the generated search-index against a embedded reference + pub check_search_index: bool, // Flag to force a crate to be built with the host architecture pub force_host: bool, // Check stdout for error-pattern output as well as stderr @@ -62,6 +64,7 @@ pub fn load_props(testfile: &Path) -> TestProps { let mut pp_exact = None; let mut check_lines = Vec::new(); let mut build_aux_docs = false; + let mut check_search_index = false; let mut force_host = false; let mut check_stdout = false; let mut no_prefer_dynamic = false; @@ -90,6 +93,10 @@ pub fn load_props(testfile: &Path) -> TestProps { build_aux_docs = parse_build_aux_docs(ln); } + if !check_search_index { + check_search_index = parse_check_search_index(ln); + } + if !force_host { force_host = parse_force_host(ln); } @@ -152,6 +159,7 @@ pub fn load_props(testfile: &Path) -> TestProps { exec_env: exec_env, check_lines: check_lines, build_aux_docs: build_aux_docs, + check_search_index: check_search_index, force_host: force_host, check_stdout: check_stdout, no_prefer_dynamic: no_prefer_dynamic, @@ -296,6 +304,10 @@ fn parse_build_aux_docs(line: &str) -> bool { parse_name_directive(line, "build-aux-docs") } +fn parse_check_search_index(line: &str) -> bool { + parse_name_directive(line, "check-search-index") +} + fn parse_check_stdout(line: &str) -> bool { parse_name_directive(line, "check-stdout") } diff --git a/src/compiletest/runtest.rs b/src/compiletest/runtest.rs index 5eef6b7f24c04..c72d337429709 100644 --- a/src/compiletest/runtest.rs +++ b/src/compiletest/runtest.rs @@ -1765,11 +1765,24 @@ fn run_rustdoc_test(config: &Config, props: &TestProps, testfile: &Path) { testfile, Command::new(&config.python) .arg(root.join("src/etc/htmldocck.py")) - .arg(out_dir) + .arg(out_dir.clone()) .arg(testfile)); if !res.status.success() { fatal_proc_rec("htmldocck failed!", &res); } + + if props.check_search_index { + let res = cmd2procres(config, + testfile, + Command::new(&config.python) + .arg(root.join("src/etc/search-index.py")) + .arg("check") + .arg(out_dir.join("search-index.js")) + .arg(testfile)); + if !res.status.success() { + fatal_proc_rec("search-index check failed!", &res); + } + } } fn run_codegen_units_test(config: &Config, props: &TestProps, testfile: &Path) { diff --git a/src/etc/search-index.py b/src/etc/search-index.py new file mode 100644 index 0000000000000..14909f8458f76 --- /dev/null +++ b/src/etc/search-index.py @@ -0,0 +1,463 @@ +#!/usr/bin/env python +# +# Copyright 2013-2016 The Rust Project Developers. See the COPYRIGHT +# file at the top-level directory of this distribution and at +# http://rust-lang.org/COPYRIGHT. +# +# Licensed under the Apache License, Version 2.0 or the MIT license +# , at your +# option. This file may not be copied, modified, or distributed +# except according to those terms. + +""" +search-index.py checks the contents of search-indexes generated by rustdoc +against a reference, which is being used by compiletest during rustdoc tests. + +To add this check to a rustdoc test a `// check-search-index` compiletest directive and +a reference-index, fencend in `/* !search-index ... */`, needs to be inserted: +``` +// check-search-index + +pub struct foo { + field: i32, +} + +/* !search-index +{ + "cap_lints": { + "cap_lints::foo": [ + "Struct" + ] + } +} +*/ +``` + +The reference-index can be written by hand or dumped from an existing search-index, +requiring the rustdoc test to be built by rustdoc beforehand, through: +`python search-index.py dump .../search-index.js` + +which can then be copied directly into the rustdoc test. + + + +The reference-index, a simplified json-format of the search-index, is structured like this: +``` +{ + "cratename": { + "Item::Path": [ + "ItemType", + "docstring, can be elided if not present" + ] + } +} +``` + +Some items, for example an AssociatedType, have a "parent-path" (a type and name) so that they +link to their parents doc-page. This parent-path is embedded into the items itempath like this: +"foo::Parent::Bar" + +Functions and Methods can have named aguments and a return value encoded into their type name: +"Function()" or "Function(foo, bar)" or "Function(foo, bar) -> foo" + +`python search-index.py dump index-file` can be used to dump a {search, reference}-index +to stdout, which can then be used for embedding into a rustdoc test. + +`python search-index.py update source dest` can be used to update the `dest` reference-index +that is embedded into a rustdoc test with the state of the `source` {search, reference}-index. + + +If you need to update the reference-index for ALL rustdoc tests you can +* use wildcards in the destination filepath and +* specify the `%(basename)s` template parameter in the source filepath +like this: + +python search-index.py update +"x86_64-unknown-linux-gnu/test/rustdoc/%(basename)s.stage1-x86_64-unknown-linux-gnu/search-index.js" +"src/test/rustdoc/*.rs" +""" + +from __future__ import print_function + +import sys +import os +import glob +import json +import re +import argparse + + +ERRS = [] + +class Error(Exception): + pass +class InvalidType(Error): + pass + +def stderr(*args, **kwargs): + kwargs.update({ "file": sys.stderr }) + print(*args, **kwargs) + +def record_errs(*errs): + global ERRS + ERRS += errs + +def abort_on_errs(): + if ERRS: + for err in ERRS: + stderr(err) + stderr("\nEncountered {} syntax errors".format(len(ERRS))) + raise SystemExit(1) + +class IndexEncoder(json.JSONEncoder): + def default(self, obj): + if isinstance(obj, Item): + return obj._encode() + return json.JSONEncoder.default(self, obj) + +class Item: + _index_map = {} + _ref_map = {} + _re_fn = re.compile(r"(?P\w+)(\((?P.+)\) ?((->)? ?(?P\w+))?)?") + + @classmethod + def from_index(klass, crate, data): + try: + item = klass._index_map[data[0]]() + except KeyError as e: + path = data[2] or crate._items[-1].path + if data[4] is not None: + try: + path += "::" + crate.paths[data[4]][1] + except IndexError: + path += "::" + path += "::" + data[1] + raise InvalidType("{} -> invalid type index `{}`".format(path, e)) + + item._init_from_index(crate, data) + return item + + def _init_from_index(self, crate, data): + self._name = data[1] + self._parent_idx = data[4] + + self.path = data[2] or crate._items[-1].path + self.description = data[3] + self.fn_inputs = tuple() + self.fn_outputs = None + assert self.path + + if data[5]: + self.fn_inputs = tuple(map(lambda i: i["name"], data[5]["inputs"])) + self.fn_outputs = (data[5]["output"] or {}).get("name", None) + + def finalize_index(self, crate): + if self._parent_idx is not None: + parent_name = crate.paths[self._parent_idx][1] + parent_ty = crate.paths[self._parent_idx][0].typename + self.path += "::{}<{}>".format(parent_name, parent_ty) + self.path += "::" + self._name + + @classmethod + def from_ref(klass, path, data): + match = klass._re_fn.match(data[0]) + ty = match.group("type") + + try: + item = klass._ref_map[ty]() + except KeyError as e: + raise InvalidType("{} -> invalid type `{}`".format(path, e)) + item._init_from_ref(path, data, match) + return item + + def _init_from_ref(self, path, data, extra): + self._name = path.split("::")[-1] + self.path = path + self.description = "" if len(data) == 1 else data[1] + inputs = extra.group("inputs") + self.fn_inputs = tuple(inp.strip() for inp in inputs.split(",")) if inputs else tuple() + self.fn_outputs = extra.group("outputs") + + def __eq__(self, other): + return (self.typename, self.path, self.fn_inputs, self.fn_outputs) == \ + (other.typename, other.path, other.fn_inputs, other.fn_outputs) + + def __ne__(self, other): + return not self == other + + def __repr__(self): + return str(self._encode()) + + def _encode(self): + if isinstance(self, (TyFn, TyMethod, TyTyMethod)): + sig = "{}({})".format(self.typename, ", ".join(self.fn_inputs)) + if self.fn_outputs: + sig += " -> {}".format(self.fn_outputs) + head = sig + else: + head = self.typename + + return [head, self.description] if self.description else [head] + + def diff(self, other, diff): + """Emit a diff of `self` and `other`, and return `(insertions, deletions)`.""" + if self != other: + print("- {} {}".format(self.path, self), file=diff) + print("+ {} {}".format(other.path, other), file=diff) + return (1, 1) + else: + return (0, 0) + +def itemtype(idx, tydesc): + class SpecificItem(Item): + pass + + SpecificItem.typename = tydesc + assert idx not in Item._index_map + Item._index_map[idx] = SpecificItem + Item._ref_map[tydesc] = SpecificItem + return SpecificItem + +TyMod = itemtype(0, "Module") +TyCrate = itemtype(1, "ExternCrate") +TyUse = itemtype(2, "Import") +TyStruct = itemtype(3, "Struct") +TyEnum = itemtype(4, "Enum") +TyFn = itemtype(5, "Function") +TyTypeDef = itemtype(6, "Typedef") +TyStatic = itemtype(7, "Static") +TyTrait = itemtype(8, "Trait") +TyImpl = itemtype(9, "Impl") +TyTyMethod = itemtype(10, "TyMethod") +TyMethod = itemtype(11, "Method") +TyStructField = itemtype(12, "StructField") +TyVariant = itemtype(13, "Variant") +TyMacro = itemtype(14, "Macro") +TyPrimitive = itemtype(15, "Primitive") +TyAssociatedType = itemtype(16, "AssociatedType") +TyConst = itemtype(17, "Constant") +TyAssociatedConst = itemtype(18, "AssociatedConst") + +class Index(dict): + def diff(self, other, diff): + """Emit a diff of `self` and `other`, and return `(insertions, deletions)`.""" + insertions = 0 + deletions = 0 + + self_keys = iter(sorted(self.keys())) + other_keys = iter(sorted(other.keys())) + + try: + other_key = next(other_keys) + except StopIteration: + other_key = None + + for key in self_keys: + while other_key < key and other_key is not None: + print("+ {}".format(other_key), file=diff) + del other[other_key] + insertions += 1 + try: + other_key = next(other_keys) + except StopIteration: + other_key = None + break + + if key == other_key: + add, rm = self.pop(key).diff(other.pop(other_key), diff) + insertions += add + deletions += rm + + try: + other_key = next(other_keys) + except StopIteration: + other_key = None + else: + print("- {}".format(key), file=diff) + del self[key] + deletions += 1 + + insertions += len(other.keys()) + deletions += len(self.keys()) + diff_keys = sorted([("-", k) for k in self.keys()] +\ + [("+", k) for k in other.keys()], key=lambda a:a[1]) + for mode, key in diff_keys: + print("{} {}".format(mode, key), file=diff) + + return (insertions, deletions) + + +class Crate(Index): + @classmethod + def from_index(klass, raw_data): + crate = klass() + crate.paths = tuple((Item._index_map[idx], name) for (idx, name) in raw_data["paths"]) + crate._items = [] + + for raw_item in raw_data["items"]: + try: + crate._items += [Item.from_index(crate, raw_item)] + except Error as e: + record_errs(e) + + for item in crate._items: + item.finalize_index(crate) + crate[item.path] = item + + del crate._items + return crate + + @classmethod + def from_ref(klass, raw_items): + crate = klass() + + for path, data in raw_items.items(): + try: + crate[path] = Item.from_ref(path, data) + except Error as e: + record_errs(e) + return crate + + def __eq__(self, other): + for path, item in self.items(): + other_item = other.get(path) + if other_item is None or other_item != item: + return False + return True + +def index_load(fpath): + with open(fpath, "r") as fp: + return index_loads(fp.read()) +index_load._format = "search-index" + +def index_loads(src): + index = Index() + for crateline in src.splitlines()[1:-1]: + _, cratename, rest = crateline.split("'", 2) + crateitems = json.loads(rest.split("=", 1)[1].strip()[:-1]) + index[cratename] = Crate.from_index(crateitems) + return index + +def ref_load(fpath): + with open(fpath, "r") as fp: + return ref_loads(fp.read()) +ref_load._format = "reference-index" + +def ref_loads(src): + match = RE_REF.search(src) + if match is not None: + index = Index() + ref = match.groups()[0].strip() + for (cratename, data) in json.loads(ref).items(): + index[cratename] = Crate.from_ref(data) + return index + raise SyntaxError("can't find embedded reference-index") + +DIFF_MSG = """ +{} insertions(+), {} deletions(-) + +Error -> distinct search-index""" + +def try_load(path, loaders): + errs = [] + temp = "{} -> failed to parse as `{}`:\n\t{}" + for loader in loaders: + try: + return loader(path) + except Exception as err: + errs += [temp.format(path, loader._format, err)] + record_errs(*errs) + abort_on_errs() + +def dumps(index, indent=4): + return json.dumps(index, cls=IndexEncoder, indent=indent, sort_keys=True) + +RE_REF = re.compile(r"/\*\s?!search-index\s(.*)\*/", flags=re.MULTILINE|re.DOTALL) +REF_FENCE = "/* !search-index\n{}\n*/" + +def dump_index(args): + index = try_load(args.index_path, (index_load, ref_load)) + abort_on_errs() + print(REF_FENCE.format(dumps(index, indent=args.indent))) + +def check_index(args): + index = try_load(args.check_index, (index_load, ref_load)) + ref = try_load(args.base_index, (ref_load, index_load)) + abort_on_errs() + insertions, deletions = ref.diff(index, sys.stderr) + + if insertions or deletions: + stderr(DIFF_MSG.format(insertions, deletions)) + raise SystemExit(1) + +def update_ref(source, destination): + for path in {source, destination}: + if not os.path.exists(path): + stderr("File does not exist: `{}`".format(path)) + raise SystemExit(1) + + source = try_load(source, (index_load, ref_load)) + abort_on_errs() + with open(destination, "r") as fp: + template = fp.read() + # escape newlines in json strings so that we're not + # splitting them later on when writing the new file + new_index = dumps(source).encode("unicode_escape") + new, n = RE_REF.subn(REF_FENCE.format(new_index), template) + if n != 1: + stderr("Error -> less or more than a single embedded reference-index") + raise SystemExit(1) + + root, fname = os.path.split(destination) + bak_path = os.path.join(root, "." + fname + ".bak") + os.rename(destination, bak_path) + try: + fp = open(destination, "w") + # Strip the trailing whitespace json.dumps leaves after a comma in a list + fp.writelines([line.rstrip() + '\n' for line in new.splitlines()]) + os.remove(bak_path) + except Exception as e: + os.remove(destination) + os.rename(bak_path, destination) + stderr("Error -> failed writing new reference-index:\n\t{}".format(e)) + raise SystemExit(1) + +def update_refs(args): + global ERRS + exit = 0 + for destination in glob.glob(args.destination): + template_dict = { "basename": os.path.splitext(os.path.basename(destination))[0] } + source = args.source % template_dict + try: + update_ref(source, destination) + except SystemExit as e: + exit = e.code + ERRS = [] + raise SystemExit(exit) + +def create_parser(): + parser = argparse.ArgumentParser() + sub = parser.add_subparsers() + + dump = sub.add_parser("dump", help="dump a {search, reference}-index as reference-index") + dump.add_argument("index_path", metavar="index-filepath") + dump.add_argument("--indent", type=int, default=4) + dump.set_defaults(func=dump_index) + + check = sub.add_parser("check", help="check a {search, reference}-index against another one") + check.add_argument("check_index", metavar="check-index") + check.add_argument("base_index", metavar="base-index") + check.set_defaults(func=check_index) + + update = sub.add_parser("update", + help="overwrite a reference-index from a {search, reference}-index") + update.add_argument("source") + update.add_argument("destination") + update.set_defaults(func=update_refs) + return parser + +if __name__ == "__main__": + parser = create_parser() + args = parser.parse_args(sys.argv[1:]) + args.func(args) diff --git a/src/test/rustdoc/assoc-consts.rs b/src/test/rustdoc/assoc-consts.rs index 8d3f9b59bb2ee..e23700ba8827a 100644 --- a/src/test/rustdoc/assoc-consts.rs +++ b/src/test/rustdoc/assoc-consts.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![feature(associated_consts)] pub trait Foo { @@ -24,3 +26,22 @@ impl Bar { // 'const BAR: usize = 3' pub const BAR: usize = 3; } + +/* !search-index +{ + "assoc_consts": { + "assoc_consts::Bar": [ + "Struct" + ], + "assoc_consts::Bar::BAR": [ + "AssociatedConst" + ], + "assoc_consts::Foo": [ + "Trait" + ], + "assoc_consts::Foo::FOO": [ + "AssociatedConst" + ] + } +} +*/ diff --git a/src/test/rustdoc/assoc-types.rs b/src/test/rustdoc/assoc-types.rs index d5047ade062dc..8f605a31c1a3a 100644 --- a/src/test/rustdoc/assoc-types.rs +++ b/src/test/rustdoc/assoc-types.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![crate_type="lib"] // @has assoc_types/trait.Index.html @@ -40,3 +42,34 @@ pub fn cmp_input(a: &T::Input, b: &U::Input) -> bool { a == b } + +/* !search-index +{ + "assoc_types": { + "assoc_types::Feed": [ + "Trait" + ], + "assoc_types::Feed::Input": [ + "AssociatedType" + ], + "assoc_types::Index": [ + "Trait" + ], + "assoc_types::Index::Output": [ + "AssociatedType" + ], + "assoc_types::Index::index": [ + "TyMethod(index, i) -> output" + ], + "assoc_types::cmp_input": [ + "Function(input, input) -> bool" + ], + "assoc_types::use_input": [ + "Function(t, input)" + ], + "assoc_types::use_output": [ + "Function(t, usize) -> output" + ] + } +} +*/ diff --git a/src/test/rustdoc/cap-lints.rs b/src/test/rustdoc/cap-lints.rs index e7f308a6f0b69..4bc8abdbe11dd 100644 --- a/src/test/rustdoc/cap-lints.rs +++ b/src/test/rustdoc/cap-lints.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + // This should fail a normal compile due to non_camel_case_types, // It should pass a doc-compile as it only needs to type-check and // therefore should not concern itself with the lints. @@ -18,3 +20,13 @@ pub struct foo { field: i32, } + +/* !search-index +{ + "cap_lints": { + "cap_lints::foo": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/default-impl.rs b/src/test/rustdoc/default-impl.rs index 6153a3966342c..c745e12b0cb75 100644 --- a/src/test/rustdoc/default-impl.rs +++ b/src/test/rustdoc/default-impl.rs @@ -10,6 +10,7 @@ // aux-build:rustdoc-default-impl.rs // ignore-cross-compile +// check-search-index extern crate rustdoc_default_impl as foo; @@ -17,3 +18,34 @@ pub use foo::bar; pub fn wut() { } + +/* !search-index +{ + "default_impl": { + "default_impl::Foo::test": [ + "Method()" + ], + "default_impl::bar": [ + "Module" + ], + "default_impl::bar::Bar": [ + "Trait" + ], + "default_impl::bar::Foo": [ + "Trait" + ], + "default_impl::bar::Foo::foo": [ + "Method()" + ], + "default_impl::bar::TypeId": [ + "Struct" + ], + "default_impl::wut": [ + "Function()" + ], + "rustdoc_default_impl::bar::TypeId::of": [ + "Method(typeid) -> typeid" + ] + } +} +*/ diff --git a/src/test/rustdoc/deprecated.rs b/src/test/rustdoc/deprecated.rs index 744304a62c216..990bbb5523ddf 100644 --- a/src/test/rustdoc/deprecated.rs +++ b/src/test/rustdoc/deprecated.rs @@ -8,9 +8,21 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![feature(deprecated)] // @has deprecated/struct.S.html '//*[@class="stab deprecated"]' \ // 'Deprecated since 1.0.0: text' #[deprecated(since = "1.0.0", note = "text")] pub struct S; + +/* !search-index +{ + "deprecated": { + "deprecated::S": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/extern-default-method.rs b/src/test/rustdoc/extern-default-method.rs index 10d2884ebae07..7f94c6c35afe2 100644 --- a/src/test/rustdoc/extern-default-method.rs +++ b/src/test/rustdoc/extern-default-method.rs @@ -10,8 +10,22 @@ // aux-build:rustdoc-extern-default-method.rs // ignore-cross-compile +// check-search-index extern crate rustdoc_extern_default_method as ext; // @count extern_default_method/struct.Struct.html '//*[@id="method.provided"]' 1 pub use ext::Struct; + +/* !search-index +{ + "extern_default_method": { + "extern_default_method::Struct": [ + "Struct" + ], + "rustdoc_extern_default_method::Struct::provided": [ + "Method()" + ] + } +} +*/ diff --git a/src/test/rustdoc/extern-method.rs b/src/test/rustdoc/extern-method.rs index c422871867d5d..52ae37ef0f800 100644 --- a/src/test/rustdoc/extern-method.rs +++ b/src/test/rustdoc/extern-method.rs @@ -10,6 +10,7 @@ // aux-build:rustdoc-extern-method.rs // ignore-cross-compile +// check-search-index #![feature(unboxed_closures)] @@ -27,3 +28,28 @@ pub trait Bar { // @has - '//*[@id="method.bar_"]//code' 'extern "rust-call" fn bar_' extern "rust-call" fn bar_(&self, _: ()) { } } + +/* !search-index +{ + "extern_method": { + "extern_method::Bar": [ + "Trait" + ], + "extern_method::Bar::bar": [ + "TyMethod()" + ], + "extern_method::Bar::bar_": [ + "Method()" + ], + "extern_method::Foo": [ + "Trait" + ], + "extern_method::Foo::foo": [ + "TyMethod()" + ], + "extern_method::Foo::foo_": [ + "Method()" + ] + } +} +*/ diff --git a/src/test/rustdoc/ffi.rs b/src/test/rustdoc/ffi.rs index 3997dcd81e153..68e9b3980c18d 100644 --- a/src/test/rustdoc/ffi.rs +++ b/src/test/rustdoc/ffi.rs @@ -10,6 +10,7 @@ // aux-build:rustdoc-ffi.rs // ignore-cross-compile +// check-search-index extern crate rustdoc_ffi as lib; @@ -20,3 +21,15 @@ extern "C" { // @has ffi/fn.another.html //pre 'pub unsafe extern fn another(cold_as_ice: u32)' pub fn another(cold_as_ice: u32); } +/* !search-index +{ + "ffi": { + "ffi::another": [ + "Function()" + ], + "ffi::foreigner": [ + "Function()" + ] + } +} +*/ diff --git a/src/test/rustdoc/hidden-line.rs b/src/test/rustdoc/hidden-line.rs index e05d51c2bac58..8667da643b3b3 100644 --- a/src/test/rustdoc/hidden-line.rs +++ b/src/test/rustdoc/hidden-line.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + /// The '# ' lines should be removed from the output, but the #[derive] should be /// retained. /// @@ -27,3 +29,14 @@ pub fn foo() {} // @!has hidden_line/fn.foo.html invisible // @matches - //pre "#\[derive\(PartialEq\)\] // Bar" + +/* !search-index +{ + "hidden_line": { + "hidden_line::foo": [ + "Function()", +"The '# ' lines should be removed from the output, but the #[derive] should be\nretained." + ] + } +} +*/ diff --git a/src/test/rustdoc/impl-parts-crosscrate.rs b/src/test/rustdoc/impl-parts-crosscrate.rs index 5fa2e03e0a884..31a2075e34189 100644 --- a/src/test/rustdoc/impl-parts-crosscrate.rs +++ b/src/test/rustdoc/impl-parts-crosscrate.rs @@ -10,6 +10,7 @@ // aux-build:rustdoc-impl-parts-crosscrate.rs // ignore-cross-compile +// check-search-index #![feature(optin_builtin_traits)] @@ -28,3 +29,13 @@ pub struct Bar { t: T } // @has - Copy impl !rustdoc_impl_parts_crosscrate::AnOibit for Bar where T: Copy {} + +/* !search-index +{ + "impl_parts_crosscrate": { + "impl_parts_crosscrate::Bar": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/impl-parts.rs b/src/test/rustdoc/impl-parts.rs index 89c5e60e34314..bcff4a0345250 100644 --- a/src/test/rustdoc/impl-parts.rs +++ b/src/test/rustdoc/impl-parts.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![feature(optin_builtin_traits)] pub trait AnOibit {} @@ -21,3 +23,16 @@ pub struct Foo { field: T } // @has impl_parts/trait.AnOibit.html '//*[@class="item-list"]//code' \ // "impl !AnOibit for Foo where T: Sync" impl !AnOibit for Foo where T: Sync {} + +/* !search-index +{ + "impl_parts": { + "impl_parts::AnOibit": [ + "Trait" + ], + "impl_parts::Foo": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/inline-default-methods.rs b/src/test/rustdoc/inline-default-methods.rs index 055af0160f54c..850ae9d4f8949 100644 --- a/src/test/rustdoc/inline-default-methods.rs +++ b/src/test/rustdoc/inline-default-methods.rs @@ -10,6 +10,7 @@ // aux-build:inline-default-methods.rs // ignore-cross-compile +// check-search-index extern crate inline_default_methods; @@ -17,3 +18,19 @@ extern crate inline_default_methods; // @has - '//*[@class="rust trait"]' 'fn bar(&self);' // @has - '//*[@class="rust trait"]' 'fn foo(&mut self) { ... }' pub use inline_default_methods::Foo; + +/* !search-index +{ + "inline_default_methods": { + "inline_default_methods::Foo": [ + "Trait" + ], + "inline_default_methods::Foo::bar": [ + "TyMethod()" + ], + "inline_default_methods::Foo::foo": [ + "Method()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-13698.rs b/src/test/rustdoc/issue-13698.rs index cf9b30a0fe987..4788dddbab98a 100644 --- a/src/test/rustdoc/issue-13698.rs +++ b/src/test/rustdoc/issue-13698.rs @@ -10,6 +10,7 @@ // aux-build:issue-13698.rs // ignore-cross-compile +// check-search-index extern crate issue_13698; @@ -24,3 +25,16 @@ pub trait Bar { // @!has issue_13698/struct.Foo.html '//*[@id="method.foo"]' 'fn bar' impl Bar for Foo {} + +/* !search-index +{ + "issue_13698": { + "issue_13698::Bar": [ + "Trait" + ], + "issue_13698::Foo": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-15169.rs b/src/test/rustdoc/issue-15169.rs index 6ab848b92dbbd..51a85e18dae43 100644 --- a/src/test/rustdoc/issue-15169.rs +++ b/src/test/rustdoc/issue-15169.rs @@ -8,6 +8,24 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + // @has issue_15169/struct.Foo.html '//*[@id="method.eq"]' 'fn eq' #[derive(PartialEq)] pub struct Foo; + +/* !search-index +{ + "issue_15169": { + "issue_15169::Foo": [ + "Struct" + ], + "issue_15169::Foo::eq": [ + "Method(foo, foo) -> bool" + ], + "issue_15169::Foo::ne": [ + "Method(foo, foo) -> bool" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-15318-2.rs b/src/test/rustdoc/issue-15318-2.rs index 7999af46eebb6..bd77c1123e93b 100644 --- a/src/test/rustdoc/issue-15318-2.rs +++ b/src/test/rustdoc/issue-15318-2.rs @@ -10,6 +10,7 @@ // aux-build:issue-15318.rs // ignore-cross-compile +// check-search-index extern crate issue_15318; @@ -20,3 +21,20 @@ pub use issue_15318::ptr; // '*mut T' pub fn bar(ptr: *mut T) {} +/* !search-index +{ + "issue_15318_2": { + "issue_15318_2::bar": [ + "Function()" + ], + "issue_15318_2::pointer": [ + "Primitive", + "dox" + ], + "issue_15318_2::ptr": [ + "Module", + "dox" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-15318-3.rs b/src/test/rustdoc/issue-15318-3.rs index a54824970c751..6a2bf651c9dde 100644 --- a/src/test/rustdoc/issue-15318-3.rs +++ b/src/test/rustdoc/issue-15318-3.rs @@ -8,8 +8,25 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + // @has issue_15318_3/primitive.pointer.html /// dox #[doc(primitive = "pointer")] pub mod ptr {} + +/* !search-index +{ + "issue_15318_3": { + "issue_15318_3::pointer": [ + "Primitive", + "dox" + ], + "issue_15318_3::ptr": [ + "Module", + "dox" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-15318.rs b/src/test/rustdoc/issue-15318.rs index bd22548a88805..417ce1cbd7bc3 100644 --- a/src/test/rustdoc/issue-15318.rs +++ b/src/test/rustdoc/issue-15318.rs @@ -10,6 +10,7 @@ // aux-build:issue-15318.rs // ignore-cross-compile +// check-search-index #![no_std] @@ -19,3 +20,13 @@ extern crate issue_15318; // '//*[@href="http://example.com/issue_15318/primitive.pointer.html"]' \ // '*mut T' pub fn bar(ptr: *mut T) {} + +/* !search-index +{ + "issue_15318": { + "issue_15318::bar": [ + "Function()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-15347.rs b/src/test/rustdoc/issue-15347.rs index 97c37bbc1eda0..38eae6d5b969c 100644 --- a/src/test/rustdoc/issue-15347.rs +++ b/src/test/rustdoc/issue-15347.rs @@ -9,7 +9,18 @@ // except according to those terms. // compile-flags:--no-defaults --passes "collapse-docs" --passes "unindent-comments" +// check-search-index // @has issue_15347/fn.foo.html #[doc(hidden)] pub fn foo() {} + +/* !search-index +{ + "issue_15347": { + "issue_15347::foo": [ + "Function()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-16019.rs b/src/test/rustdoc/issue-16019.rs index 7aae6a0595024..947fb23e4257f 100644 --- a/src/test/rustdoc/issue-16019.rs +++ b/src/test/rustdoc/issue-16019.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + macro_rules! define_struct { ($rounds:expr) => ( struct Struct { @@ -17,3 +19,9 @@ macro_rules! define_struct { } define_struct!(2); + +/* !search-index +{ + "issue_16019": {} +} +*/ diff --git a/src/test/rustdoc/issue-16265-1.rs b/src/test/rustdoc/issue-16265-1.rs index c0b99a627ea30..9a215e58ce0a8 100644 --- a/src/test/rustdoc/issue-16265-1.rs +++ b/src/test/rustdoc/issue-16265-1.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + pub struct Foo; // @has issue_16265_1/traits/index.html '[src]' @@ -16,3 +18,19 @@ pub mod traits { fn eq(&self, _: &super::Foo) -> bool { true } } } + +/* !search-index +{ + "issue_16265_1": { + "issue_16265_1::Foo": [ + "Struct" + ], + "issue_16265_1::Foo::eq": [ + "Method(foo, foo) -> bool" + ], + "issue_16265_1::traits": [ + "Module" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-16265-2.rs b/src/test/rustdoc/issue-16265-2.rs index 22a8df407e095..7a8d2b351a4aa 100644 --- a/src/test/rustdoc/issue-16265-2.rs +++ b/src/test/rustdoc/issue-16265-2.rs @@ -8,8 +8,15 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index // @has issue_16265_2/index.html '[src]' trait Y {} impl Y for Option{} + +/* !search-index +{ + "issue_16265_2": {} +} +*/ diff --git a/src/test/rustdoc/issue-17476.rs b/src/test/rustdoc/issue-17476.rs index dcd3f2a2ba5b8..eae3ba0d854e7 100644 --- a/src/test/rustdoc/issue-17476.rs +++ b/src/test/rustdoc/issue-17476.rs @@ -10,6 +10,7 @@ // aux-build:issue-17476.rs // ignore-cross-compile +// check-search-index extern crate issue_17476; @@ -19,3 +20,13 @@ pub struct Foo; // '//*[@href="http://example.com/issue_17476/trait.Foo.html#method.foo"]' \ // 'foo' impl issue_17476::Foo for Foo {} + +/* !search-index +{ + "issue_17476": { + "issue_17476::Foo": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-19055.rs b/src/test/rustdoc/issue-19055.rs index 609ae22be104b..894d4120e59cd 100644 --- a/src/test/rustdoc/issue-19055.rs +++ b/src/test/rustdoc/issue-19055.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + // @has issue_19055/trait.Any.html pub trait Any {} @@ -28,3 +30,28 @@ pub trait Foo { // @has - '//*[@id="method.foo"]' 'fn foo' impl Foo for Any {} + +/* !search-index +{ + "issue_19055": { + "issue_19055::Any": [ + "Trait" + ], + "issue_19055::Any::downcast_mut": [ + "Method(any) -> option" + ], + "issue_19055::Any::downcast_ref": [ + "Method(any) -> option" + ], + "issue_19055::Any::is": [ + "Method(any) -> bool" + ], + "issue_19055::Foo": [ + "Trait" + ], + "issue_19055::Foo::foo": [ + "Method(foo)" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-19190-2.rs b/src/test/rustdoc/issue-19190-2.rs index 8835e18f1c5ce..c3e0edfb4717b 100644 --- a/src/test/rustdoc/issue-19190-2.rs +++ b/src/test/rustdoc/issue-19190-2.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + use std::ops::Deref; pub struct Bar; @@ -20,3 +22,16 @@ impl Deref for Bar { // @has issue_19190_2/struct.Bar.html // @has - '//*[@id="method.count_ones"]' 'fn count_ones(self) -> u32' // @!has - '//*[@id="method.min_value"]' 'fn min_value() -> i32' + +/* !search-index +{ + "issue_19190_2": { + "issue_19190_2::Bar": [ + "Struct" + ], + "issue_19190_2::Bar::deref": [ + "Method(bar) -> i32" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-19190-3.rs b/src/test/rustdoc/issue-19190-3.rs index 64c396b29f27e..4d9d8667d249f 100644 --- a/src/test/rustdoc/issue-19190-3.rs +++ b/src/test/rustdoc/issue-19190-3.rs @@ -10,6 +10,7 @@ // aux-build:issue-19190-3.rs // ignore-cross-compile +// check-search-index extern crate issue_19190_3; @@ -36,3 +37,33 @@ impl Deref for MyBar { fn deref(&self) -> &Baz { loop {} } } +/* !search-index +{ + "issue_19190_3": { + "issue_19190_3::Bar": [ + "Struct" + ], + "issue_19190_3::Bar::deref": [ + "Method(bar) -> baz" + ], + "issue_19190_3::Baz::baz": [ + "Method()" + ], + "issue_19190_3::Baz::static_baz": [ + "Method()" + ], + "issue_19190_3::Foo": [ + "Struct" + ], + "issue_19190_3::Foo::deref": [ + "Method(foo) -> i32" + ], + "issue_19190_3::MyBar": [ + "Struct" + ], + "issue_19190_3::MyBar::deref": [ + "Method(mybar) -> baz" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-19190.rs b/src/test/rustdoc/issue-19190.rs index 6289fcc6fe526..bf1187e77ffc4 100644 --- a/src/test/rustdoc/issue-19190.rs +++ b/src/test/rustdoc/issue-19190.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + use std::ops::Deref; pub struct Foo; @@ -26,3 +28,25 @@ impl Deref for Bar { // @has issue_19190/struct.Bar.html // @has - '//*[@id="method.foo"]' 'fn foo(&self)' // @!has - '//*[@id="method.static_foo"]' 'fn static_foo()' + +/* !search-index +{ + "issue_19190": { + "issue_19190::Bar": [ + "Struct" + ], + "issue_19190::Bar::deref": [ + "Method(bar) -> foo" + ], + "issue_19190::Foo": [ + "Struct" + ], + "issue_19190::Foo::foo": [ + "Method(foo)" + ], + "issue_19190::Foo::static_foo": [ + "Method(foo)" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-20175.rs b/src/test/rustdoc/issue-20175.rs index 33ec4b75c413d..f6dbc3d3e8aec 100644 --- a/src/test/rustdoc/issue-20175.rs +++ b/src/test/rustdoc/issue-20175.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + pub trait Foo { fn foo(&self) {} } @@ -18,3 +20,19 @@ pub struct Bar; // '//*[@id="method.foo"]' \ // 'fn foo' impl<'a> Foo for &'a Bar {} + +/* !search-index +{ + "issue_20175": { + "issue_20175::Bar": [ + "Struct" + ], + "issue_20175::Foo": [ + "Trait" + ], + "issue_20175::Foo::foo": [ + "Method(foo)" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-20646.rs b/src/test/rustdoc/issue-20646.rs index 87c40d1157974..98f1401df0d4e 100644 --- a/src/test/rustdoc/issue-20646.rs +++ b/src/test/rustdoc/issue-20646.rs @@ -10,6 +10,7 @@ // aux-build:issue-20646.rs // ignore-cross-compile +// check-search-index #![feature(associated_types)] @@ -34,3 +35,31 @@ pub mod reexport { // '//*[@class="rust fn"]' 'where T: Trait' pub use issue_20646::{Trait, fun}; } + +/* !search-index +{ + "issue_20646": { + "issue_20646::Trait": [ + "Trait" + ], + "issue_20646::Trait::Output": [ + "AssociatedType" + ], + "issue_20646::fun": [ + "Function(t)" + ], + "issue_20646::reexport": [ + "Module" + ], + "issue_20646::reexport::Trait": [ + "Trait" + ], + "issue_20646::reexport::Trait::Output": [ + "AssociatedType" + ], + "issue_20646::reexport::fun": [ + "Function()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-20727-2.rs b/src/test/rustdoc/issue-20727-2.rs index 1f29a9c97972c..7c5f947118ee1 100644 --- a/src/test/rustdoc/issue-20727-2.rs +++ b/src/test/rustdoc/issue-20727-2.rs @@ -10,6 +10,7 @@ // aux-build:issue-20727.rs // ignore-cross-compile +// check-search-index extern crate issue_20727; @@ -31,3 +32,30 @@ pub mod reexport { pub use issue_20727::Add; } +/* !search-index +{ + "issue_20727_2": { + "issue_20727_2::Add": [ + "Trait" + ], + "issue_20727_2::Add::Output": [ + "AssociatedType" + ], + "issue_20727_2::Add::add": [ + "TyMethod(add, rhs) -> output" + ], + "issue_20727_2::reexport": [ + "Module" + ], + "issue_20727_2::reexport::Add": [ + "Trait" + ], + "issue_20727_2::reexport::Add::Output": [ + "AssociatedType" + ], + "issue_20727_2::reexport::Add::add": [ + "TyMethod()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-20727-3.rs b/src/test/rustdoc/issue-20727-3.rs index e4a9dd7e7f142..8d19e31015c28 100644 --- a/src/test/rustdoc/issue-20727-3.rs +++ b/src/test/rustdoc/issue-20727-3.rs @@ -10,6 +10,7 @@ // aux-build:issue-20727.rs // ignore-cross-compile +// check-search-index extern crate issue_20727; @@ -32,3 +33,34 @@ pub mod reexport { // @has - '//*[@class="rust trait"]' 'fn deref(&self) -> Self::Target;' pub use issue_20727::Deref2; } + +/* !search-index +{ + "issue_20727_3": { + "issue_20727_3::Bar": [ + "Trait" + ], + "issue_20727_3::Deref2": [ + "Trait" + ], + "issue_20727_3::Deref2::Target": [ + "AssociatedType" + ], + "issue_20727_3::Deref2::deref": [ + "TyMethod(deref2) -> target" + ], + "issue_20727_3::reexport": [ + "Module" + ], + "issue_20727_3::reexport::Deref2": [ + "Trait" + ], + "issue_20727_3::reexport::Deref2::Target": [ + "AssociatedType" + ], + "issue_20727_3::reexport::Deref2::deref": [ + "TyMethod()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-20727-4.rs b/src/test/rustdoc/issue-20727-4.rs index 9ebd1c448eeb0..c2977ee283752 100644 --- a/src/test/rustdoc/issue-20727-4.rs +++ b/src/test/rustdoc/issue-20727-4.rs @@ -10,6 +10,7 @@ // aux-build:issue-20727.rs // ignore-cross-compile +// check-search-index extern crate issue_20727; @@ -48,3 +49,43 @@ pub mod reexport { // 'fn index_mut(&mut self, index: Idx) -> &mut Self::Output;' pub use issue_20727::IndexMut; } + +/* !search-index +{ + "issue_20727_4": { + "issue_20727_4::Index": [ + "Trait" + ], + "issue_20727_4::Index::Output": [ + "AssociatedType" + ], + "issue_20727_4::Index::index": [ + "TyMethod(index, idx) -> output" + ], + "issue_20727_4::IndexMut": [ + "Trait" + ], + "issue_20727_4::IndexMut::index_mut": [ + "TyMethod(indexmut, idx) -> output" + ], + "issue_20727_4::reexport": [ + "Module" + ], + "issue_20727_4::reexport::Index": [ + "Trait" + ], + "issue_20727_4::reexport::Index::Output": [ + "AssociatedType" + ], + "issue_20727_4::reexport::Index::index": [ + "TyMethod()" + ], + "issue_20727_4::reexport::IndexMut": [ + "Trait" + ], + "issue_20727_4::reexport::IndexMut::index_mut": [ + "TyMethod()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-20727.rs b/src/test/rustdoc/issue-20727.rs index e38f06c4b317a..1796f66203d0b 100644 --- a/src/test/rustdoc/issue-20727.rs +++ b/src/test/rustdoc/issue-20727.rs @@ -10,6 +10,7 @@ // aux-build:issue-20727.rs // ignore-cross-compile +// check-search-index extern crate issue_20727; @@ -32,3 +33,31 @@ pub mod reexport { // "fn deref(&'a self) -> &'a Self::Target;" pub use issue_20727::Deref; } + +/* !search-index +{ + "issue_20727": { + "issue_20727::Deref": [ + "Trait" + ], + "issue_20727::Deref::Target": [ + "AssociatedType" + ], + "issue_20727::Deref::deref": [ + "TyMethod(deref) -> target" + ], + "issue_20727::reexport": [ + "Module" + ], + "issue_20727::reexport::Deref": [ + "Trait" + ], + "issue_20727::reexport::Deref::Target": [ + "AssociatedType" + ], + "issue_20727::reexport::Deref::deref": [ + "TyMethod()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-21092.rs b/src/test/rustdoc/issue-21092.rs index ff48c70fc58dc..ba9471f1445fe 100644 --- a/src/test/rustdoc/issue-21092.rs +++ b/src/test/rustdoc/issue-21092.rs @@ -10,9 +10,29 @@ // aux-build:issue-21092.rs // ignore-cross-compile +// check-search-index extern crate issue_21092; // @has issue_21092/struct.Bar.html // @has - '//*[@id="associatedtype.Bar"]' 'type Bar = i32' pub use issue_21092::{Foo, Bar}; + +/* !search-index +{ + "issue_21092": { + "issue_21092::Bar": [ + "Struct" + ], + "issue_21092::Foo": [ + "Trait" + ], + "issue_21092::Foo::Bar": [ + "AssociatedType" + ], + "issue_21092::Foo::foo": [ + "Method()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-21474.rs b/src/test/rustdoc/issue-21474.rs index 36f160acf1cf8..356e6b4826a1b 100644 --- a/src/test/rustdoc/issue-21474.rs +++ b/src/test/rustdoc/issue-21474.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + pub use inner::*; mod inner { @@ -19,3 +21,16 @@ pub trait Blah { } // @count issue_21474/struct.What.html \ // '//*[@class="impl"]' 1 pub struct What; + +/* !search-index +{ + "issue_21474": { + "issue_21474::Blah": [ + "Trait" + ], + "issue_21474::What": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-21801.rs b/src/test/rustdoc/issue-21801.rs index 4e2c77826b6c0..a36608cf33974 100644 --- a/src/test/rustdoc/issue-21801.rs +++ b/src/test/rustdoc/issue-21801.rs @@ -10,6 +10,7 @@ // aux-build:issue-21801.rs // ignore-cross-compile +// check-search-index extern crate issue_21801; @@ -17,3 +18,16 @@ extern crate issue_21801; // @has - '//*[@id="method.new"]' \ // 'fn new(f: F) -> Foo where F: FnMut() -> i32' pub use issue_21801::Foo; + +/* !search-index +{ + "issue_21801": { + "issue_21801::Foo": [ + "Struct" + ], + "issue_21801::Foo::new": [ + "Method(foo, f) -> foo" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-22025.rs b/src/test/rustdoc/issue-22025.rs index c0e4e673f94d8..c1e611361a538 100644 --- a/src/test/rustdoc/issue-22025.rs +++ b/src/test/rustdoc/issue-22025.rs @@ -10,7 +10,21 @@ // aux-build:issue-22025.rs // ignore-cross-compile +// check-search-index extern crate issue_22025; pub use issue_22025::foo::{Foo, Bar}; + +/* !search-index +{ + "issue_22025": { + "issue_22025::Bar": [ + "Struct" + ], + "issue_22025::Foo": [ + "Trait" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-22038.rs b/src/test/rustdoc/issue-22038.rs index 6f84428b0798f..5a0d0d0a79dd3 100644 --- a/src/test/rustdoc/issue-22038.rs +++ b/src/test/rustdoc/issue-22038.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + extern { // @has issue_22038/fn.foo1.html \ // '//*[@class="rust fn"]' 'pub unsafe extern fn foo1()' @@ -27,3 +29,22 @@ pub extern fn bar() {} // @has issue_22038/fn.baz.html \ // '//*[@class="rust fn"]' 'pub extern "system" fn baz()' pub extern "system" fn baz() {} + +/* !search-index +{ + "issue_22038": { + "issue_22038::bar": [ + "Function()" + ], + "issue_22038::baz": [ + "Function()" + ], + "issue_22038::foo1": [ + "Function()" + ], + "issue_22038::foo2": [ + "Function()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-23207.rs b/src/test/rustdoc/issue-23207.rs index 4931d158ac3e4..a24f22e1f16e9 100644 --- a/src/test/rustdoc/issue-23207.rs +++ b/src/test/rustdoc/issue-23207.rs @@ -11,6 +11,7 @@ // aux-build:issue-23207-1.rs // aux-build:issue-23207-2.rs // ignore-cross-compile +// check-search-index extern crate issue_23207_2; @@ -18,3 +19,15 @@ extern crate issue_23207_2; // @count - '//*[@class="struct"]' 1 pub use issue_23207_2::fmt; +/* !search-index +{ + "issue_23207": { + "issue_23207::fmt": [ + "Module" + ], + "issue_23207::fmt::Error": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-23511.rs b/src/test/rustdoc/issue-23511.rs index 50c31d309eec1..4f22e0c527a7d 100644 --- a/src/test/rustdoc/issue-23511.rs +++ b/src/test/rustdoc/issue-23511.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![feature(lang_items)] #![no_std] @@ -20,3 +22,16 @@ pub mod str { pub fn foo(&self) {} } } + +/* !search-index +{ + "issue_23511": { + "issue_23511::str": [ + "Primitive" + ], + "issue_23511::str::foo": [ + "Method(str)" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-23812.rs b/src/test/rustdoc/issue-23812.rs index 37f6749694c40..c98ea7c976fff 100644 --- a/src/test/rustdoc/issue-23812.rs +++ b/src/test/rustdoc/issue-23812.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + macro_rules! doc { (#[$outer:meta] mod $i:ident { #![$inner:meta] }) => ( @@ -44,3 +46,18 @@ doc! { // @!has - '/** Outer block comment */' // @has - 'Inner block comment' // @!has - '/*! Inner block comment */' + +/* !search-index +{ + "issue_23812": { + "issue_23812::Bar": [ + "Module", + "Outer block comment\nInner block comment " + ], + "issue_23812::Foo": [ + "Module", + "Outer comment\nInner comment" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-25001.rs b/src/test/rustdoc/issue-25001.rs index 2343b610ce448..ebb1e20942eaa 100644 --- a/src/test/rustdoc/issue-25001.rs +++ b/src/test/rustdoc/issue-25001.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + // @has issue_25001/struct.Foo.html pub struct Foo(T); @@ -51,3 +53,28 @@ impl<'a, T> Bar for &'a mut Foo { // @has - '//*[@id="method.quux-2"]//code' 'fn quux(self)' fn quux(self) {} } + +/* !search-index +{ + "issue_25001": { + "issue_25001::Bar": [ + "Trait" + ], + "issue_25001::Bar::Item": [ + "AssociatedType" + ], + "issue_25001::Bar::quux": [ + "TyMethod(bar)" + ], + "issue_25001::Foo": [ + "Struct" + ], + "issue_25001::Foo::pass": [ + "Method(foo) -> isize" + ], + "issue_25001::Foo::quux": [ + "Method(foo)" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-27362.rs b/src/test/rustdoc/issue-27362.rs index 179778fd1283f..28b80f31d1332 100644 --- a/src/test/rustdoc/issue-27362.rs +++ b/src/test/rustdoc/issue-27362.rs @@ -10,6 +10,7 @@ // aux-build:issue-27362.rs // ignore-cross-compile +// check-search-index extern crate issue_27362; pub use issue_27362 as quux; @@ -17,3 +18,22 @@ pub use issue_27362 as quux; // @matches issue_27362/quux/fn.foo.html '//pre' "pub const fn foo()" // @matches issue_27362/quux/fn.bar.html '//pre' "pub const unsafe fn bar()" // @matches issue_27362/quux/struct.Foo.html '//code' "const unsafe fn baz()" + +/* !search-index +{ + "issue_27362": { + "issue_27362::Foo::baz": [ + "Method()" + ], + "issue_27362::quux::Foo": [ + "Struct" + ], + "issue_27362::quux::bar": [ + "Function()" + ], + "issue_27362::quux::foo": [ + "Function()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-27759.rs b/src/test/rustdoc/issue-27759.rs index fe40ce2bd7ddb..68c85e173d15d 100644 --- a/src/test/rustdoc/issue-27759.rs +++ b/src/test/rustdoc/issue-27759.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![feature(staged_api)] #![doc(issue_tracker_base_url = "http://issue_url/")] @@ -24,3 +26,16 @@ pub mod unstable { #[unstable(feature="test_function", issue="1234567890")] pub fn issue() {} } + +/* !search-index +{ + "issue_27759": { + "issue_27759::unstable": [ + "Module" + ], + "issue_27759::unstable::issue": [ + "Function()" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-27862.rs b/src/test/rustdoc/issue-27862.rs index 6b56585ae8aba..c4e75d5b4c6e3 100644 --- a/src/test/rustdoc/issue-27862.rs +++ b/src/test/rustdoc/issue-27862.rs @@ -8,8 +8,20 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index /// Test | Table /// ------|------------- /// t = b | id = \|x\| x pub struct Foo; // @has issue_27862/struct.Foo.html //td 'id = |x| x' + +/* !search-index +{ + "issue_27862": { + "issue_27862::Foo": [ + "Struct", + "Test | Table\n------|-------------\nt = b | id = \\|x\\| x" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-28927.rs b/src/test/rustdoc/issue-28927.rs index b3096a949625f..d0a07cbd9e767 100644 --- a/src/test/rustdoc/issue-28927.rs +++ b/src/test/rustdoc/issue-28927.rs @@ -11,6 +11,17 @@ // aux-build:issue-28927-2.rs // aux-build:issue-28927-1.rs // ignore-cross-compile +// check-search-index extern crate issue_28927_1 as inner1; pub use inner1 as foo; + +/* !search-index +{ + "issue_28927": { + "issue_28927::foo::issue_28927_2::Baz": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-29449.rs b/src/test/rustdoc/issue-29449.rs index f296048e30b54..eb67293f04642 100644 --- a/src/test/rustdoc/issue-29449.rs +++ b/src/test/rustdoc/issue-29449.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + // @has issue_29449/struct.Foo.html pub struct Foo; @@ -28,3 +30,25 @@ impl Foo { /// # Panics pub fn bar_2() {} } + +/* !search-index +{ + "issue_29449": { + "issue_29449::Foo": [ + "Struct" + ], + "issue_29449::Foo::bar": [ + "Method(foo)", + "# Examples\n# Panics" + ], + "issue_29449::Foo::bar_1": [ + "Method(foo)", + "# Examples" + ], + "issue_29449::Foo::bar_2": [ + "Method(foo)", + "# Examples\n# Panics" + ] + } +} +*/ diff --git a/src/test/rustdoc/issue-30109.rs b/src/test/rustdoc/issue-30109.rs index 2d33e9323d149..7e535bc28bf12 100644 --- a/src/test/rustdoc/issue-30109.rs +++ b/src/test/rustdoc/issue-30109.rs @@ -11,6 +11,7 @@ // build-aux-docs // aux-build:issue-30109-1.rs // ignore-cross-compile +// check-search-index pub mod quux { extern crate issue_30109_1 as bar; @@ -22,3 +23,21 @@ pub mod quux { // '//a/@href' '../issue_30109_1/struct.Bar.html' impl Foo for Bar {} } + +/* !search-index +{ + "issue_30109": { + "issue_30109::quux": [ + "Module" + ], + "issue_30109::quux::Foo": [ + "Trait" + ] + }, + "issue_30109_1": { + "issue_30109_1::Bar": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/macros.rs b/src/test/rustdoc/macros.rs index b052ad2da2fa9..c94ff18faa3d1 100644 --- a/src/test/rustdoc/macros.rs +++ b/src/test/rustdoc/macros.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + // @has macros/macro.my_macro!.html //pre 'macro_rules! my_macro {' // @has - //pre '() => { ... };' // @has - //pre '($a:tt) => { ... };' @@ -18,3 +20,13 @@ macro_rules! my_macro { ($a:tt) => (); ($e:expr) => {}; } + +/* !search-index +{ + "macros": { + "macros::my_macro!": [ + "Macro" + ] + } +} +*/ diff --git a/src/test/rustdoc/must-use.rs b/src/test/rustdoc/must-use.rs index e293675f5b05d..533601cfc4d4a 100644 --- a/src/test/rustdoc/must-use.rs +++ b/src/test/rustdoc/must-use.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + // @has must_use/struct.Struct.html //pre '#[must_use]' #[must_use] pub struct Struct { @@ -19,3 +21,19 @@ pub struct Struct { pub enum Enum { Variant(i32), } + +/* !search-index +{ + "must_use": { + "must_use::Enum": [ + "Enum" + ], + "must_use::Enum::Variant": [ + "Variant" + ], + "must_use::Struct": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/negative-impl.rs b/src/test/rustdoc/negative-impl.rs index aadabb15d1d2d..3a304d7a66c13 100644 --- a/src/test/rustdoc/negative-impl.rs +++ b/src/test/rustdoc/negative-impl.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![feature(optin_builtin_traits)] // @matches negative_impl/struct.Alpha.html '//pre' "pub struct Alpha" @@ -20,3 +22,16 @@ impl !Send for Alpha {} // @matches negative_impl/struct.Bravo.html '//*[@class="impl"]//code' "impl !Send for Bravo" impl !Send for Bravo {} + +/* !search-index +{ + "negative_impl": { + "negative_impl::Alpha": [ + "Struct" + ], + "negative_impl::Bravo": [ + "Struct" + ] + } +} +*/ diff --git a/src/test/rustdoc/recursion1.rs b/src/test/rustdoc/recursion1.rs index 7505d20566dbb..4c2f4297a7598 100644 --- a/src/test/rustdoc/recursion1.rs +++ b/src/test/rustdoc/recursion1.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![crate_type = "lib"] #![feature(globs)] @@ -22,3 +24,9 @@ mod m { pub use super::*; } } + +/* !search-index +{ + "recursion1": {} +} +*/ diff --git a/src/test/rustdoc/recursion2.rs b/src/test/rustdoc/recursion2.rs index 7505d20566dbb..82e14b4f992bf 100644 --- a/src/test/rustdoc/recursion2.rs +++ b/src/test/rustdoc/recursion2.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![crate_type = "lib"] #![feature(globs)] @@ -22,3 +24,9 @@ mod m { pub use super::*; } } + +/* !search-index +{ + "recursion2": {} +} +*/ diff --git a/src/test/rustdoc/recursion3.rs b/src/test/rustdoc/recursion3.rs index 62a13f76ca4f0..8ed4744daf73c 100644 --- a/src/test/rustdoc/recursion3.rs +++ b/src/test/rustdoc/recursion3.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![feature(globs)] pub mod longhands { @@ -23,3 +25,22 @@ pub mod common_types { pub use super::super::longhands::computed_as_specified as compute_CSSColor; } } + +/* !search-index +{ + "recursion3": { + "recursion3::common_types": [ + "Module" + ], + "recursion3::common_types::computed": [ + "Module" + ], + "recursion3::longhands": [ + "Module" + ], + "recursion3::longhands::computed_as_specified": [ + "Function()" + ] + } +} +*/ diff --git a/src/test/rustdoc/search-index.rs b/src/test/rustdoc/search-index.rs index 70b77f6760d8b..19affc41dbc3e 100644 --- a/src/test/rustdoc/search-index.rs +++ b/src/test/rustdoc/search-index.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![crate_name = "rustdoc_test"] use std::ops::Deref; @@ -34,3 +36,22 @@ impl Deref for Bar { type Target = Bar; fn deref(&self) -> &Bar { self } } + +/* !search-index +{ + "rustdoc_test": { + "rustdoc_test::Bar": [ + "Struct" + ], + "rustdoc_test::Bar::deref": [ + "Method(bar) -> bar" + ], + "rustdoc_test::Foo": [ + "Struct" + ], + "rustdoc_test::Foo::test_method": [ + "Method(foo)" + ] + } +} +*/ diff --git a/src/test/rustdoc/smoke.rs b/src/test/rustdoc/smoke.rs index 6ba7018bf226f..ff08f3a411133 100644 --- a/src/test/rustdoc/smoke.rs +++ b/src/test/rustdoc/smoke.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + // @has smoke/index.html //! Very docs @@ -33,3 +35,34 @@ pub mod bar { // @has smoke/bar/fn.prawns.html pub fn prawns((a, b): (isize, usize), Foo { x, y }: Foo) { } } + +/* !search-index +{ + "smoke": { + "smoke::bar": [ + "Module" + ], + "smoke::bar::Doge": [ + "Trait", + "*wow*" + ], + "smoke::bar::Doge::dummy": [ + "Method(doge)" + ], + "smoke::bar::Foo": [ + "Struct" + ], + "smoke::bar::baz": [ + "Module", + "So correct" + ], + "smoke::bar::baz::baz": [ + "Function()", + "Much detail" + ], + "smoke::bar::prawns": [ + "Function()" + ] + } +} +*/ diff --git a/src/test/rustdoc/src-links.rs b/src/test/rustdoc/src-links.rs index 4d7dad64b47ae..447f3ba1b9ada 100644 --- a/src/test/rustdoc/src-links.rs +++ b/src/test/rustdoc/src-links.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![crate_name = "foo"] //! Dox @@ -54,3 +56,70 @@ pub fn modfn() { } // @has foo/qux/bar/struct.Foo.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' // @has foo/qux/bar/fn.prawns.html '//a/@href' '../../../src/foo/src-links/mod.rs.html' // @has foo/qux/fn.modfn.html '//a/@href' '../../src/foo/src-links/mod.rs.html' + +/* !search-index +{ + "foo": { + "foo::bar": [ + "Module" + ], + "foo::bar::Foo": [ + "Struct" + ], + "foo::bar::Foobar": [ + "Trait", + "Dox" + ], + "foo::bar::Foobar::dummy": [ + "Method(foobar)" + ], + "foo::bar::baz": [ + "Module", + "Dox" + ], + "foo::bar::baz::baz": [ + "Function()", + "Dox" + ], + "foo::bar::prawns": [ + "Function()" + ], + "foo::modfn": [ + "Function()", + "Dox" + ], + "foo::qux": [ + "Module", + "Dox" + ], + "foo::qux::bar": [ + "Module" + ], + "foo::qux::bar::Foo": [ + "Struct" + ], + "foo::qux::bar::Foobar": [ + "Trait", + "Dox" + ], + "foo::qux::bar::Foobar::dummy": [ + "Method(foobar)" + ], + "foo::qux::bar::baz": [ + "Module", + "Dox" + ], + "foo::qux::bar::baz::baz": [ + "Function()", + "Dox" + ], + "foo::qux::bar::prawns": [ + "Function()" + ], + "foo::qux::modfn": [ + "Function()", + "Dox" + ] + } +} +*/ diff --git a/src/test/rustdoc/tuples.rs b/src/test/rustdoc/tuples.rs index 2269b38780df0..93adbb92000bd 100644 --- a/src/test/rustdoc/tuples.rs +++ b/src/test/rustdoc/tuples.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![crate_name = "foo"] // @has foo/fn.tuple0.html //pre 'pub fn tuple0(x: ())' @@ -16,3 +18,19 @@ pub fn tuple0(x: ()) -> () { x } pub fn tuple1(x: (i32,)) -> (i32,) { x } // @has foo/fn.tuple2.html //pre 'pub fn tuple2(x: (i32, i32)) -> (i32, i32)' pub fn tuple2(x: (i32, i32)) -> (i32, i32) { x } + +/* !search-index +{ + "foo": { + "foo::tuple0": [ + "Function()" + ], + "foo::tuple1": [ + "Function()" + ], + "foo::tuple2": [ + "Function()" + ] + } +} +*/ diff --git a/src/test/rustdoc/variadic.rs b/src/test/rustdoc/variadic.rs index 1b60c2a334fa5..158e66da77f20 100644 --- a/src/test/rustdoc/variadic.rs +++ b/src/test/rustdoc/variadic.rs @@ -8,7 +8,19 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + extern "C" { // @has variadic/fn.foo.html //pre 'pub unsafe extern fn foo(x: i32, ...)' pub fn foo(x: i32, ...); } + +/* !search-index +{ + "variadic": { + "variadic::foo": [ + "Function()" + ] + } +} +*/ diff --git a/src/test/rustdoc/viewpath-rename.rs b/src/test/rustdoc/viewpath-rename.rs index ccc0acab7f379..7d38bbf06d14b 100644 --- a/src/test/rustdoc/viewpath-rename.rs +++ b/src/test/rustdoc/viewpath-rename.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![crate_name = "foo"] pub mod io { @@ -26,3 +28,31 @@ pub mod prelude { // @has foo/prelude/index.html '//code' 'pub use Maybe::{self, Just as MaybeJust, Nothing}' #[doc(no_inline)] pub use Maybe::{self, Just as MaybeJust, Nothing}; } + +/* !search-index +{ + "foo": { + "foo::Maybe": [ + "Enum" + ], + "foo::Maybe::Just": [ + "Variant" + ], + "foo::Maybe::Nothing": [ + "Variant" + ], + "foo::io": [ + "Module" + ], + "foo::io::Reader": [ + "Trait" + ], + "foo::io::Reader::dummy": [ + "Method(reader)" + ], + "foo::prelude": [ + "Module" + ] + } +} +*/ diff --git a/src/test/rustdoc/viewpath-self.rs b/src/test/rustdoc/viewpath-self.rs index 65a981353f0df..e4a061147eac4 100644 --- a/src/test/rustdoc/viewpath-self.rs +++ b/src/test/rustdoc/viewpath-self.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![crate_name = "foo"] pub mod io { @@ -26,3 +28,31 @@ pub mod prelude { // @has foo/prelude/index.html '//code' 'pub use Maybe::{self, Just, Nothing}' #[doc(no_inline)] pub use Maybe::{self, Just, Nothing}; } + +/* !search-index +{ + "foo": { + "foo::Maybe": [ + "Enum" + ], + "foo::Maybe::Just": [ + "Variant" + ], + "foo::Maybe::Nothing": [ + "Variant" + ], + "foo::io": [ + "Module" + ], + "foo::io::Reader": [ + "Trait" + ], + "foo::io::Reader::dummy": [ + "Method(reader)" + ], + "foo::prelude": [ + "Module" + ] + } +} +*/ diff --git a/src/test/rustdoc/where.rs b/src/test/rustdoc/where.rs index 91ec69d9a3cbb..bae84176ca0ce 100644 --- a/src/test/rustdoc/where.rs +++ b/src/test/rustdoc/where.rs @@ -8,6 +8,8 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. +// check-search-index + #![crate_name = "foo"] pub trait MyTrait { fn dummy(&self) { } } @@ -46,3 +48,46 @@ impl MyTrait for Foxtrot where F: MyTrait {} // @has foo/type.Golf.html '//pre[@class="rust typedef"]' \ // "type Golf where T: Clone = (T, T)" pub type Golf where T: Clone = (T, T); + +/* !search-index +{ + "foo": { + "foo::Alpha": [ + "Struct" + ], + "foo::Bravo": [ + "Trait" + ], + "foo::Bravo::get": [ + "TyMethod(bravo, b)" + ], + "foo::Delta": [ + "Struct" + ], + "foo::Delta::delta": [ + "Method(delta)" + ], + "foo::Echo": [ + "Struct" + ], + "foo::Foxtrot": [ + "Enum" + ], + "foo::Foxtrot::Foxtrot1": [ + "Variant" + ], + "foo::Golf": [ + "Typedef" + ], + "foo::MyTrait": [ + "Trait" + ], + "foo::MyTrait::dummy": [ + "Method(mytrait)" + ], + "foo::charlie": [ + "Function()" + ] + } +} +*/