rustdoc-search: add test case for indexing every item type
Test case for7b35d8e1abandad2e096136
This commit is contained in:
parent
94722cabf4
commit
e7674cb1e6
4 changed files with 170 additions and 0 deletions
27
tests/run-make/rustdoc-search-load-itemtype/bar.rs
Normal file
27
tests/run-make/rustdoc-search-load-itemtype/bar.rs
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
#![crate_type = "proc-macro"]
|
||||
|
||||
extern crate proc_macro;
|
||||
use proc_macro::*;
|
||||
|
||||
//@ has bar/macro.a_procmacro.html
|
||||
//@ hasraw search.index/name/*.js a_procmacro
|
||||
#[proc_macro]
|
||||
pub fn a_procmacro(_: TokenStream) -> TokenStream {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
//@ has bar/attr.a_procattribute.html
|
||||
//@ hasraw search.index/name/*.js a_procattribute
|
||||
#[proc_macro_attribute]
|
||||
pub fn a_procattribute(_: TokenStream, _: TokenStream) -> TokenStream {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
//@ has bar/derive.AProcDerive.html
|
||||
//@ !has bar/derive.a_procderive.html
|
||||
//@ hasraw search.index/name/*.js AProcDerive
|
||||
//@ !hasraw search.index/name/*.js a_procderive
|
||||
#[proc_macro_derive(AProcDerive)]
|
||||
pub fn a_procderive(_: TokenStream) -> TokenStream {
|
||||
unimplemented!()
|
||||
}
|
||||
3
tests/run-make/rustdoc-search-load-itemtype/baz.rs
Normal file
3
tests/run-make/rustdoc-search-load-itemtype/baz.rs
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
//@ has baz/struct.Baz.html
|
||||
//@ hasraw search.index/name/*.js Baz
|
||||
pub struct Baz;
|
||||
119
tests/run-make/rustdoc-search-load-itemtype/foo.rs
Normal file
119
tests/run-make/rustdoc-search-load-itemtype/foo.rs
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
#![feature(extern_types, rustc_attrs, rustdoc_internals, trait_alias)]
|
||||
#![allow(internal_features)]
|
||||
#![no_std]
|
||||
|
||||
//@ has foo/keyword.while.html
|
||||
//@ hasraw search.index/name/*.js while
|
||||
//@ !hasraw search.index/name/*.js w_keyword
|
||||
#[doc(keyword = "while")]
|
||||
mod w_keyword {}
|
||||
|
||||
//@ has foo/primitive.u32.html
|
||||
//@ hasraw search.index/name/*.js u32
|
||||
//@ !hasraw search.index/name/*.js u_primitive
|
||||
#[rustc_doc_primitive = "u32"]
|
||||
mod u_primitive {}
|
||||
|
||||
//@ has foo/x_mod/index.html
|
||||
//@ hasraw search.index/name/*.js x_mod
|
||||
pub mod x_mod {}
|
||||
|
||||
//@ hasraw foo/index.html y_crate
|
||||
//@ hasraw search.index/name/*.js y_crate
|
||||
#[doc(no_inline)]
|
||||
pub extern crate core as y_crate;
|
||||
|
||||
//@ hasraw foo/index.html z_import
|
||||
//@ hasraw search.index/name/*.js z_import
|
||||
#[doc(no_inline)]
|
||||
pub use core::option as z_import;
|
||||
|
||||
//@ has foo/struct.AStruct.html
|
||||
//@ hasraw search.index/name/*.js AStruct
|
||||
pub struct AStruct {
|
||||
//@ hasraw foo/struct.AStruct.html a_structfield
|
||||
//@ hasraw search.index/name/*.js a_structfield
|
||||
pub a_structfield: i32,
|
||||
}
|
||||
|
||||
//@ has foo/enum.AEnum.html
|
||||
//@ hasraw search.index/name/*.js AEnum
|
||||
pub enum AEnum {
|
||||
//@ hasraw foo/enum.AEnum.html AVariant
|
||||
//@ hasraw search.index/name/*.js AVariant
|
||||
AVariant,
|
||||
}
|
||||
|
||||
//@ has foo/fn.a_fn.html
|
||||
//@ hasraw search.index/name/*.js a_fn
|
||||
pub fn a_fn() {}
|
||||
|
||||
//@ has foo/type.AType.html
|
||||
//@ hasraw search.index/name/*.js AType
|
||||
pub type AType = AStruct;
|
||||
|
||||
//@ has foo/static.a_static.html
|
||||
//@ hasraw search.index/name/*.js a_static
|
||||
pub static a_static: i32 = 1;
|
||||
|
||||
//@ has foo/trait.ATrait.html
|
||||
//@ hasraw search.index/name/*.js ATrait
|
||||
pub trait ATrait {
|
||||
//@ hasraw foo/trait.ATrait.html a_tymethod
|
||||
//@ hasraw search.index/name/*.js a_tymethod
|
||||
fn a_tymethod();
|
||||
//@ hasraw foo/trait.ATrait.html AAssocType
|
||||
//@ hasraw search.index/name/*.js AAssocType
|
||||
type AAssocType;
|
||||
//@ hasraw foo/trait.ATrait.html AAssocConst
|
||||
//@ hasraw search.index/name/*.js AAssocConst
|
||||
const AAssocConst: bool;
|
||||
}
|
||||
|
||||
// skip ItemType::Impl, since impls are anonymous
|
||||
// and have no search entry
|
||||
|
||||
impl AStruct {
|
||||
//@ hasraw foo/struct.AStruct.html a_method
|
||||
//@ hasraw search.index/name/*.js a_method
|
||||
pub fn a_method() {}
|
||||
}
|
||||
|
||||
//@ has foo/macro.a_macro.html
|
||||
//@ hasraw search.index/name/*.js a_macro
|
||||
#[macro_export]
|
||||
macro_rules! a_macro {
|
||||
() => {};
|
||||
}
|
||||
|
||||
//@ has foo/constant.A_CONSTANT.html
|
||||
//@ hasraw search.index/name/*.js A_CONSTANT
|
||||
pub const A_CONSTANT: i32 = 1;
|
||||
|
||||
//@ has foo/union.AUnion.html
|
||||
//@ hasraw search.index/name/*.js AUnion
|
||||
pub union AUnion {
|
||||
//@ hasraw foo/union.AUnion.html a_unionfield
|
||||
//@ hasraw search.index/name/*.js a_unionfield
|
||||
pub a_unionfield: i32,
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
//@ has foo/foreigntype.AForeignType.html
|
||||
//@ hasraw search.index/name/*.js AForeignType
|
||||
pub type AForeignType;
|
||||
}
|
||||
|
||||
// procattribute and procderive are defined in
|
||||
// bar.rs, because they only work with proc_macro
|
||||
// crate type.
|
||||
|
||||
//@ has foo/traitalias.ATraitAlias.html
|
||||
//@ hasraw search.index/name/*.js ATraitAlias
|
||||
pub trait ATraitAlias = ATrait;
|
||||
|
||||
//@ has foo/attribute.doc.html
|
||||
//@ hasraw search.index/name/*.js doc
|
||||
//@ !hasraw search.index/name/*.js aa_mod
|
||||
#[doc(attribute = "doc")]
|
||||
mod aa_mod {}
|
||||
21
tests/run-make/rustdoc-search-load-itemtype/rmake.rs
Normal file
21
tests/run-make/rustdoc-search-load-itemtype/rmake.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//@ ignore-cross-compile
|
||||
//@ needs-crate-type: proc-macro
|
||||
|
||||
// Test that rustdoc can deserialize a search index with every itemtype.
|
||||
// https://github.com/rust-lang/rust/pull/146117
|
||||
|
||||
use std::path::Path;
|
||||
|
||||
use run_make_support::{htmldocck, rfs, rustdoc, source_root};
|
||||
|
||||
fn main() {
|
||||
let out_dir = Path::new("rustdoc-search-load-itemtype");
|
||||
|
||||
rfs::create_dir_all(&out_dir);
|
||||
rustdoc().out_dir(&out_dir).input("foo.rs").run();
|
||||
rustdoc().out_dir(&out_dir).input("bar.rs").arg("--crate-type=proc-macro").run();
|
||||
rustdoc().out_dir(&out_dir).input("baz.rs").run();
|
||||
htmldocck().arg(out_dir).arg("foo.rs").run();
|
||||
htmldocck().arg(out_dir).arg("bar.rs").run();
|
||||
htmldocck().arg(out_dir).arg("baz.rs").run();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue