File tree Expand file tree Collapse file tree 14 files changed +251
-0
lines changed
src/test/rustdoc-ui/coverage Expand file tree Collapse file tree 14 files changed +251
-0
lines changed Original file line number Diff line number Diff line change
1
+ // compile-flags:-Z unstable-options --show-coverage
2
+ // compile-pass
3
+
4
+ #![ feature( extern_types) ]
5
+
6
+ //! Make sure to have some docs on your crate root
7
+
8
+ /// This struct is documented, but its fields are not.
9
+ ///
10
+ /// However, one field is private, so it shouldn't show in the total.
11
+ pub struct SomeStruct {
12
+ pub some_field : usize ,
13
+ other_field : usize ,
14
+ }
15
+
16
+ impl SomeStruct {
17
+ /// Method with docs
18
+ pub fn this_fn ( & self ) { }
19
+
20
+ // Method without docs
21
+ pub fn other_method ( & self ) { }
22
+ }
23
+
24
+ // struct without docs
25
+ pub struct OtherStruct ;
26
+
27
+ // function with no docs
28
+ pub fn some_fn ( ) { }
29
+
30
+ /// Function with docs
31
+ pub fn other_fn ( ) { }
32
+
33
+ pub enum SomeEnum {
34
+ /// Some of these variants are documented...
35
+ VarOne ,
36
+ /// ...but some of them are not.
37
+ VarTwo ,
38
+ // (like this one)
39
+ VarThree ,
40
+ }
41
+
42
+ /// There's a macro here, too
43
+ #[ macro_export]
44
+ macro_rules! some_macro {
45
+ ( ) => { } ;
46
+ }
47
+
48
+ extern {
49
+ pub type ExternType ;
50
+ }
Original file line number Diff line number Diff line change
1
+ +---------------------------+------------+------------+------------+
2
+ | Item Type | Documented | Total | Percentage |
3
+ +---------------------------+------------+------------+------------+
4
+ | Modules | 1 | 1 | 100.0% |
5
+ | Functions | 1 | 2 | 50.0% |
6
+ | Structs | 1 | 2 | 50.0% |
7
+ | Struct Fields | 0 | 1 | 0.0% |
8
+ | Enums | 0 | 1 | 0.0% |
9
+ | Enum Variants | 2 | 3 | 66.7% |
10
+ | Methods | 1 | 2 | 50.0% |
11
+ | Macros | 1 | 1 | 100.0% |
12
+ | Extern Types | 0 | 1 | 0.0% |
13
+ +---------------------------+------------+------------+------------+
14
+ | Total | 7 | 14 | 50.0% |
15
+ +---------------------------+------------+------------+------------+
Original file line number Diff line number Diff line change
1
+ // compile-flags:-Z unstable-options --show-coverage
2
+ // compile-pass
3
+
4
+ // an empty crate still has one item to document: the crate root
Original file line number Diff line number Diff line change
1
+ +---------------------------+------------+------------+------------+
2
+ | Item Type | Documented | Total | Percentage |
3
+ +---------------------------+------------+------------+------------+
4
+ | Modules | 0 | 1 | 0.0% |
5
+ +---------------------------+------------+------------+------------+
6
+ | Total | 0 | 1 | 0.0% |
7
+ +---------------------------+------------+------------+------------+
Original file line number Diff line number Diff line change
1
+ // compile-flags:-Z unstable-options --show-coverage
2
+ // compile-pass
3
+
4
+ //! (remember the crate root is still a module)
5
+
6
+ /// so check out this enum here
7
+ pub enum ThisEnum {
8
+ /// this variant has some weird stuff going on
9
+ VarOne {
10
+ /// like, it has some named fields inside
11
+ field_one : usize ,
12
+ // (these show up as struct fields)
13
+ field_two : usize ,
14
+ } ,
15
+ /// here's another variant for you
16
+ VarTwo ( String ) ,
17
+ // but not all of them need to be documented as thoroughly
18
+ VarThree ,
19
+ }
20
+
21
+ /// uninhabited enums? sure, let's throw one of those around
22
+ pub enum OtherEnum { }
Original file line number Diff line number Diff line change
1
+ +---------------------------+------------+------------+------------+
2
+ | Item Type | Documented | Total | Percentage |
3
+ +---------------------------+------------+------------+------------+
4
+ | Modules | 1 | 1 | 100.0% |
5
+ | Struct Fields | 1 | 2 | 50.0% |
6
+ | Enums | 2 | 2 | 100.0% |
7
+ | Enum Variants | 2 | 3 | 66.7% |
8
+ +---------------------------+------------+------------+------------+
9
+ | Total | 6 | 8 | 75.0% |
10
+ +---------------------------+------------+------------+------------+
Original file line number Diff line number Diff line change
1
+ // compile-flags:-Z unstable-options --show-coverage
2
+ // compile-pass
3
+
4
+ #![ feature( doc_keyword) ]
5
+
6
+ //! the features only used in std also have entries in the table, so make sure those get pulled out
7
+ //! properly as well
8
+
9
+ /// woo, check it out, we can write our own primitive docs lol
10
+ #[ doc( primitive="unit" ) ]
11
+ mod prim_unit { }
12
+
13
+ /// keywords? sure, pile them on
14
+ #[ doc( keyword="where" ) ]
15
+ mod where_keyword { }
Original file line number Diff line number Diff line change
1
+ +---------------------------+------------+------------+------------+
2
+ | Item Type | Documented | Total | Percentage |
3
+ +---------------------------+------------+------------+------------+
4
+ | Modules | 1 | 1 | 100.0% |
5
+ | Primitives | 1 | 1 | 100.0% |
6
+ | Keywords | 1 | 1 | 100.0% |
7
+ +---------------------------+------------+------------+------------+
8
+ | Total | 3 | 3 | 100.0% |
9
+ +---------------------------+------------+------------+------------+
Original file line number Diff line number Diff line change
1
+ // compile-flags:-Z unstable-options --show-coverage --document-private-items
2
+ // compile-pass
3
+
4
+ #![ allow( unused) ]
5
+
6
+ //! when `--document-private-items` is passed, nothing is safe. everything must have docs or your
7
+ //! score will suffer the consequences
8
+
9
+ mod this_mod {
10
+ fn private_fn ( ) { }
11
+ }
12
+
13
+ /// See, our public items have docs!
14
+ pub struct SomeStruct {
15
+ /// Look, all perfectly documented!
16
+ pub field : usize ,
17
+ other : usize ,
18
+ }
19
+
20
+ /// Nothing shady going on here. Just a bunch of well-documented code. (cough)
21
+ pub fn public_fn ( ) { }
Original file line number Diff line number Diff line change
1
+ +---------------------------+------------+------------+------------+
2
+ | Item Type | Documented | Total | Percentage |
3
+ +---------------------------+------------+------------+------------+
4
+ | Modules | 1 | 2 | 50.0% |
5
+ | Functions | 1 | 2 | 50.0% |
6
+ | Structs | 1 | 1 | 100.0% |
7
+ | Struct Fields | 1 | 2 | 50.0% |
8
+ +---------------------------+------------+------------+------------+
9
+ | Total | 4 | 7 | 57.1% |
10
+ +---------------------------+------------+------------+------------+
Original file line number Diff line number Diff line change
1
+ // compile-flags:-Z unstable-options --show-coverage
2
+ // compile-pass
3
+
4
+ //! gotta make sure we can count statics and consts correctly, too
5
+
6
+ /// static like electricity, right?
7
+ pub static THIS_STATIC : usize = 0 ;
8
+
9
+ /// (it's not electricity, is it)
10
+ pub const THIS_CONST : usize = 1 ;
11
+
12
+ /// associated consts show up separately, but let's throw them in as well
13
+ pub trait SomeTrait {
14
+ /// just like that, yeah
15
+ const ASSOC_CONST : usize ;
16
+ }
17
+
18
+ pub struct SomeStruct ;
19
+
20
+ impl SomeStruct {
21
+ /// wait, structs can have them too, can't forget those
22
+ pub const ASSOC_CONST : usize = 100 ;
23
+ }
Original file line number Diff line number Diff line change
1
+ +---------------------------+------------+------------+------------+
2
+ | Item Type | Documented | Total | Percentage |
3
+ +---------------------------+------------+------------+------------+
4
+ | Modules | 1 | 1 | 100.0% |
5
+ | Structs | 0 | 1 | 0.0% |
6
+ | Traits | 1 | 1 | 100.0% |
7
+ | Associated Constants | 2 | 2 | 100.0% |
8
+ | Statics | 1 | 1 | 100.0% |
9
+ | Constants | 1 | 1 | 100.0% |
10
+ +---------------------------+------------+------------+------------+
11
+ | Total | 6 | 7 | 85.7% |
12
+ +---------------------------+------------+------------+------------+
Original file line number Diff line number Diff line change
1
+ // compile-flags:-Z unstable-options --show-coverage
2
+ // compile-pass
3
+
4
+ #![ feature( trait_alias) ]
5
+
6
+ /// look at this trait right here
7
+ pub trait ThisTrait {
8
+ /// that's a trait all right
9
+ fn right_here ( & self ) ;
10
+
11
+ /// even the provided functions show up as trait methods
12
+ fn aww_yeah ( & self ) { }
13
+
14
+ /// gotta check those associated types, they're slippery
15
+ type SomeType ;
16
+ }
17
+
18
+ /// so what happens if we take some struct...
19
+ pub struct SomeStruct ;
20
+
21
+ /// ...and slap this trait on it?
22
+ impl ThisTrait for SomeStruct {
23
+ /// what we get is a perfect combo!
24
+ fn right_here ( & self ) { }
25
+
26
+ type SomeType = String ;
27
+ }
28
+
29
+ /// but what about those aliases? i hear they're pretty exotic
30
+ pub trait MyAlias = ThisTrait + Send + Sync ;
31
+
32
+ // FIXME(58624): once rustdoc can process existential types, we need to make sure they're counted
33
+ // /// woah, getting all existential in here
34
+ // pub existential type ThisExists: ThisTrait;
35
+ //
36
+ // /// why don't we get a little more concrete
37
+ // pub fn defines() -> ThisExists { SomeStruct {} }
Original file line number Diff line number Diff line change
1
+ +---------------------------+------------+------------+------------+
2
+ | Item Type | Documented | Total | Percentage |
3
+ +---------------------------+------------+------------+------------+
4
+ | Modules | 0 | 1 | 0.0% |
5
+ | Structs | 1 | 1 | 100.0% |
6
+ | Traits | 1 | 1 | 100.0% |
7
+ | Trait Methods | 2 | 2 | 100.0% |
8
+ | Associated Types | 1 | 1 | 100.0% |
9
+ | Trait Aliases | 1 | 1 | 100.0% |
10
+ +---------------------------+------------+------------+------------+
11
+ | Total (non trait impls) | 6 | 7 | 85.7% |
12
+ +---------------------------+------------+------------+------------+
13
+ | Trait Impl Items | 2 | 3 | 66.7% |
14
+ +---------------------------+------------+------------+------------+
15
+ | Total | 8 | 10 | 80.0% |
16
+ +---------------------------+------------+------------+------------+
You can’t perform that action at this time.
0 commit comments