2021-02-21 14:25:12 +01:00
|
|
|
//! The point of this crate is to be able to have enough different "kinds" of
|
|
|
|
|
//! documentation generated so we can test each different features.
|
2021-12-17 22:38:18 -08:00
|
|
|
#![doc(html_playground_url="https://play.rust-lang.org/")]
|
2021-02-21 14:25:12 +01:00
|
|
|
|
|
|
|
|
#![crate_name = "test_docs"]
|
2023-03-09 20:54:53 +00:00
|
|
|
#![allow(internal_features)]
|
2021-10-30 17:44:50 +02:00
|
|
|
#![feature(rustdoc_internals)]
|
2021-06-24 14:30:01 +02:00
|
|
|
#![feature(doc_cfg)]
|
2022-10-19 17:15:11 +02:00
|
|
|
#![feature(associated_type_defaults)]
|
2021-02-21 14:25:12 +01:00
|
|
|
|
2022-09-21 16:08:54 +02:00
|
|
|
/*!
|
|
|
|
|
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
|
|
|
|
|
this crate even more!
|
|
|
|
|
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
|
|
|
|
|
this crate even more!
|
|
|
|
|
Enable the feature <span class="stab portability"><code>some-feature</code></span> to enjoy
|
|
|
|
|
this crate even more!
|
|
|
|
|
|
|
|
|
|
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
|
|
|
|
|
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
|
|
|
|
|
Also, stop using `bar` as it's <span class="stab deprecated" title="">deprecated</span>.
|
|
|
|
|
|
|
|
|
|
Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code>
|
|
|
|
|
</span>.
|
|
|
|
|
Finally, you can use `quz` only on <span class="stab portability"><code>Unix or x86-64</code>
|
|
|
|
|
</span>.
|
|
|
|
|
*/
|
|
|
|
|
|
2021-07-16 15:15:23 +02:00
|
|
|
use std::convert::AsRef;
|
2021-02-21 14:25:12 +01:00
|
|
|
use std::fmt;
|
|
|
|
|
|
|
|
|
|
/// Basic function with some code examples:
|
|
|
|
|
///
|
|
|
|
|
/// ```
|
|
|
|
|
/// println!("nothing fancy");
|
2021-10-19 11:42:59 +02:00
|
|
|
/// println!("but with two lines!");
|
2021-02-21 14:25:12 +01:00
|
|
|
/// ```
|
|
|
|
|
///
|
|
|
|
|
/// A failing to compile one:
|
|
|
|
|
///
|
|
|
|
|
/// ```compile_fail
|
|
|
|
|
/// println!("where did my argument {} go? :'(");
|
|
|
|
|
/// ```
|
|
|
|
|
///
|
|
|
|
|
/// An ignored one:
|
|
|
|
|
///
|
|
|
|
|
/// ```ignore (it's a test)
|
|
|
|
|
/// Let's say I'm just some text will ya?
|
|
|
|
|
/// ```
|
2021-08-28 11:43:21 +02:00
|
|
|
///
|
2022-09-08 23:40:13 +02:00
|
|
|
/// A failing to run one:
|
|
|
|
|
///
|
|
|
|
|
/// ```should_panic
|
|
|
|
|
/// panic!("tadam");
|
|
|
|
|
/// ```
|
|
|
|
|
///
|
2021-08-28 11:43:21 +02:00
|
|
|
/// An inlined `code`!
|
2021-02-21 14:25:12 +01:00
|
|
|
pub fn foo() {}
|
|
|
|
|
|
|
|
|
|
/// Just a normal struct.
|
|
|
|
|
pub struct Foo;
|
|
|
|
|
|
2021-03-09 21:33:39 +01:00
|
|
|
impl Foo {
|
|
|
|
|
#[must_use]
|
2021-04-19 22:59:23 +02:00
|
|
|
pub fn must_use(&self) -> bool {
|
|
|
|
|
true
|
|
|
|
|
}
|
2023-01-07 14:50:03 +01:00
|
|
|
|
|
|
|
|
/// hello
|
|
|
|
|
///
|
|
|
|
|
/// <div id="doc-warning-1" class="warning">this is a warning</div>
|
|
|
|
|
///
|
|
|
|
|
/// done
|
|
|
|
|
pub fn warning1() {}
|
|
|
|
|
|
|
|
|
|
/// Checking there is no bottom margin if "warning" is the last element.
|
|
|
|
|
///
|
|
|
|
|
/// <div id="doc-warning-2" class="warning">this is a warning</div>
|
|
|
|
|
pub fn warning2() {}
|
2021-03-09 21:33:39 +01:00
|
|
|
}
|
|
|
|
|
|
2021-07-16 15:15:23 +02:00
|
|
|
impl AsRef<str> for Foo {
|
|
|
|
|
fn as_ref(&self) -> &str {
|
|
|
|
|
"hello"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-02-21 14:25:12 +01:00
|
|
|
/// Just a normal enum.
|
2021-11-25 15:39:04 +01:00
|
|
|
///
|
|
|
|
|
/// # title!
|
2021-05-25 17:48:57 +02:00
|
|
|
#[doc(alias = "ThisIsAnAlias")]
|
2022-12-05 11:15:09 -07:00
|
|
|
#[non_exhaustive]
|
2021-02-21 14:25:12 +01:00
|
|
|
pub enum WhoLetTheDogOut {
|
|
|
|
|
/// Woof!
|
|
|
|
|
Woof,
|
|
|
|
|
/// Meoooooooow...
|
|
|
|
|
Meow,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Who doesn't love to wrap a `format!` call?
|
|
|
|
|
pub fn some_more_function<T: fmt::Debug>(t: &T) -> String {
|
|
|
|
|
format!("{:?}", t)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Woohoo! A trait!
|
|
|
|
|
pub trait AnotherOne {
|
2021-03-12 14:25:01 +01:00
|
|
|
/// Some func 3.
|
|
|
|
|
fn func3();
|
|
|
|
|
|
2021-02-21 14:25:12 +01:00
|
|
|
/// Some func 1.
|
|
|
|
|
fn func1();
|
|
|
|
|
|
2021-03-12 14:25:01 +01:00
|
|
|
fn another();
|
|
|
|
|
fn why_not();
|
|
|
|
|
|
2021-02-21 14:25:12 +01:00
|
|
|
/// Some func 2.
|
|
|
|
|
fn func2();
|
|
|
|
|
|
2021-03-12 14:25:01 +01:00
|
|
|
fn hello();
|
2021-02-21 14:25:12 +01:00
|
|
|
}
|
|
|
|
|
|
2021-03-22 22:17:43 +01:00
|
|
|
/// ```compile_fail
|
|
|
|
|
/// whatever
|
|
|
|
|
/// ```
|
|
|
|
|
///
|
2021-02-21 14:25:12 +01:00
|
|
|
/// Check for "i" signs in lists!
|
|
|
|
|
///
|
|
|
|
|
/// 1. elem 1
|
2021-03-22 22:17:43 +01:00
|
|
|
/// 2. test 1
|
|
|
|
|
/// ```compile_fail
|
|
|
|
|
/// fn foo() {}
|
|
|
|
|
/// ```
|
2021-02-21 14:25:12 +01:00
|
|
|
/// 3. elem 3
|
|
|
|
|
/// 4. ```ignore (it's a test)
|
|
|
|
|
/// fn foo() {}
|
|
|
|
|
/// ```
|
|
|
|
|
/// 5. elem 5
|
2021-03-22 22:17:43 +01:00
|
|
|
///
|
|
|
|
|
/// Final one:
|
|
|
|
|
///
|
|
|
|
|
/// ```ignore (still a test)
|
|
|
|
|
/// let x = 12;
|
|
|
|
|
/// ```
|
2021-02-21 14:25:12 +01:00
|
|
|
pub fn check_list_code_block() {}
|
2021-04-19 22:59:23 +02:00
|
|
|
|
2021-06-24 14:30:01 +02:00
|
|
|
/// a thing with a label
|
|
|
|
|
#[deprecated(since = "1.0.0", note = "text why this deprecated")]
|
|
|
|
|
#[doc(cfg(unix))]
|
|
|
|
|
pub fn replaced_function() {}
|
|
|
|
|
|
2021-07-14 15:00:12 +02:00
|
|
|
/// Some doc with `code`!
|
2021-04-19 22:59:23 +02:00
|
|
|
pub enum AnEnum {
|
|
|
|
|
WithVariants { and: usize, sub: usize, variants: usize },
|
|
|
|
|
}
|
2021-05-21 22:53:50 +02:00
|
|
|
|
|
|
|
|
#[doc(keyword = "CookieMonster")]
|
2021-07-12 17:42:59 +02:00
|
|
|
/// Some keyword.
|
2021-05-21 22:53:50 +02:00
|
|
|
pub mod keyword {}
|
2021-06-06 23:06:49 +02:00
|
|
|
|
|
|
|
|
/// Just some type alias.
|
|
|
|
|
pub type SomeType = u32;
|
2021-09-10 13:40:38 +02:00
|
|
|
|
rustdoc: use JS to inline target type impl docs into alias
This is an attempt to balance three problems, each of which would
be violated by a simpler implementation:
- A type alias should show all the `impl` blocks for the target
type, and vice versa, if they're applicable. If nothing was
done, and rustdoc continues to match them up in HIR, this
would not work.
- Copying the target type's docs into its aliases' HTML pages
directly causes far too much redundant HTML text to be generated
when a crate has large numbers of methods and large numbers
of type aliases.
- Using JavaScript exclusively for type alias impl docs would
be a functional regression, and could make some docs very hard
to find for non-JS readers.
- Making sure that only applicable docs are show in the
resulting page requires a type checkers. Do not reimplement
the type checker in JavaScript.
So, to make it work, rustdoc stashes these type-alias-inlined docs
in a JSONP "database-lite". The file is generated in `write_shared.rs`,
included in a `<script>` tag added in `print_item.rs`, and `main.js`
takes care of patching the additional docs into the DOM.
The format of `trait.impl` and `type.impl` JS files are superficially
similar. Each line, except the JSONP wrapper itself, belongs to a crate,
and they are otherwise separate (rustdoc should be idempotent). The
"meat" of the file is HTML strings, so the frontend code is very simple.
Links are relative to the doc root, though, so the frontend needs to fix
that up, and inlined docs can reuse these files.
However, there are a few differences, caused by the sophisticated
features that type aliases have. Consider this crate graph:
```text
---------------------------------
| crate A: struct Foo<T> |
| type Bar = Foo<i32> |
| impl X for Foo<i8> |
| impl Y for Foo<i32> |
---------------------------------
|
----------------------------------
| crate B: type Baz = A::Foo<i8> |
| type Xyy = A::Foo<i8> |
| impl Z for Xyy |
----------------------------------
```
The type.impl/A/struct.Foo.js JS file has a structure kinda like this:
```js
JSONP({
"A": [["impl Y for Foo<i32>", "Y", "A::Bar"]],
"B": [["impl X for Foo<i8>", "X", "B::Baz", "B::Xyy"], ["impl Z for Xyy", "Z", "B::Baz"]],
});
```
When the type.impl file is loaded, only the current crate's docs are
actually used. The main reason to bundle them together is that there's
enough duplication in them for DEFLATE to remove the redundancy.
The contents of a crate are a list of impl blocks, themselves
represented as lists. The first item in the sublist is the HTML block,
the second item is the name of the trait (which goes in the sidebar),
and all others are the names of type aliases that successfully match.
This way:
- There's no need to generate these files for types that have no aliases
in the current crate. If a dependent crate makes a type alias, it'll
take care of generating its own docs.
- There's no need to reimplement parts of the type checker in
JavaScript. The Rust backend does the checking, and includes its
results in the file.
- Docs defined directly on the type alias are dropped directly in the
HTML by `render_assoc_items`, and are accessible without JavaScript.
The JSONP file will not list impl items that are known to be part
of the main HTML file already.
[JSONP]: https://en.wikipedia.org/wiki/JSONP
2023-10-05 18:44:52 -07:00
|
|
|
/// Another type alias, this time with methods.
|
|
|
|
|
pub type SomeOtherTypeWithMethodsAndInlining = Foo;
|
|
|
|
|
|
|
|
|
|
impl SomeOtherTypeWithMethodsAndInlining {
|
|
|
|
|
pub fn some_other_method_directly(&self) {}
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-10 13:40:38 +02:00
|
|
|
pub mod huge_amount_of_consts {
|
|
|
|
|
include!(concat!(env!("OUT_DIR"), "/huge_amount_of_consts.rs"));
|
|
|
|
|
}
|
2021-10-07 17:26:24 +02:00
|
|
|
|
|
|
|
|
/// Very long code text `hereIgoWithLongTextBecauseWhyNotAndWhyWouldntI`.
|
|
|
|
|
pub mod long_code_block {}
|
2021-10-20 15:44:16 +02:00
|
|
|
|
2022-12-13 10:46:27 -07:00
|
|
|
/// Very long code text [`hereIgoWithLongTextBecauseWhyNotAndWhyWouldntI`][lnk].
|
|
|
|
|
///
|
|
|
|
|
/// [lnk]: crate::long_code_block_link
|
|
|
|
|
pub mod long_code_block_link {}
|
|
|
|
|
|
2021-10-20 15:44:16 +02:00
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules! repro {
|
|
|
|
|
() => {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub use crate::repro as repro2;
|
2021-10-22 13:45:10 -07:00
|
|
|
|
|
|
|
|
/// # Top-doc Prose title
|
|
|
|
|
///
|
|
|
|
|
/// Text below title.
|
|
|
|
|
///
|
|
|
|
|
/// ## Top-doc Prose sub-heading
|
|
|
|
|
///
|
|
|
|
|
/// Text below sub-heading.
|
|
|
|
|
///
|
|
|
|
|
/// ### Top-doc Prose sub-sub-heading
|
|
|
|
|
///
|
|
|
|
|
/// Text below sub-sub-heading
|
2022-07-27 15:36:43 +02:00
|
|
|
///
|
|
|
|
|
/// #### You know the drill.
|
|
|
|
|
///
|
|
|
|
|
/// More text.
|
2021-10-22 13:45:10 -07:00
|
|
|
pub struct HeavilyDocumentedStruct {
|
|
|
|
|
/// # Title for field
|
|
|
|
|
/// ## Sub-heading for field
|
|
|
|
|
pub nothing: (),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// # Title for struct impl doc
|
|
|
|
|
///
|
|
|
|
|
/// Text below heading.
|
|
|
|
|
///
|
|
|
|
|
/// ## Sub-heading for struct impl doc
|
|
|
|
|
///
|
|
|
|
|
/// Text below sub-heading.
|
|
|
|
|
///
|
|
|
|
|
/// ### Sub-sub-heading for struct impl doc
|
|
|
|
|
///
|
|
|
|
|
/// Text below sub-sub-heading.
|
|
|
|
|
///
|
|
|
|
|
impl HeavilyDocumentedStruct {
|
|
|
|
|
/// # Title for struct impl-item doc
|
|
|
|
|
/// Text below title.
|
|
|
|
|
/// ## Sub-heading for struct impl-item doc
|
|
|
|
|
/// Text below sub-heading.
|
|
|
|
|
/// ### Sub-sub-heading for struct impl-item doc
|
|
|
|
|
/// Text below sub-sub-heading.
|
|
|
|
|
pub fn do_nothing() {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// # Top-doc Prose title
|
|
|
|
|
///
|
|
|
|
|
/// Text below title.
|
|
|
|
|
///
|
|
|
|
|
/// ## Top-doc Prose sub-heading
|
|
|
|
|
///
|
|
|
|
|
/// Text below sub-heading.
|
|
|
|
|
///
|
|
|
|
|
/// ### Top-doc Prose sub-sub-heading
|
|
|
|
|
///
|
|
|
|
|
/// Text below sub-sub-heading
|
|
|
|
|
pub enum HeavilyDocumentedEnum {
|
|
|
|
|
/// # None prose title
|
|
|
|
|
/// ## None prose sub-heading
|
|
|
|
|
None,
|
|
|
|
|
/// # Wrapped prose title
|
|
|
|
|
/// ## Wrapped prose sub-heading
|
|
|
|
|
Wrapped(
|
|
|
|
|
/// # Wrapped.0 prose title
|
|
|
|
|
/// ## Wrapped.0 prose sub-heading
|
|
|
|
|
String,
|
|
|
|
|
String,
|
|
|
|
|
),
|
|
|
|
|
Structy {
|
|
|
|
|
/// # Structy prose title
|
|
|
|
|
/// ## Structy prose sub-heading
|
|
|
|
|
alpha: String,
|
|
|
|
|
beta: String,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// # Title for enum impl doc
|
|
|
|
|
///
|
|
|
|
|
/// Text below heading.
|
|
|
|
|
///
|
|
|
|
|
/// ## Sub-heading for enum impl doc
|
|
|
|
|
///
|
|
|
|
|
/// Text below sub-heading.
|
|
|
|
|
///
|
|
|
|
|
/// ### Sub-sub-heading for enum impl doc
|
|
|
|
|
///
|
|
|
|
|
/// Text below sub-sub-heading.
|
|
|
|
|
///
|
|
|
|
|
impl HeavilyDocumentedEnum {
|
|
|
|
|
/// # Title for enum impl-item doc
|
|
|
|
|
/// Text below title.
|
|
|
|
|
/// ## Sub-heading for enum impl-item doc
|
|
|
|
|
/// Text below sub-heading.
|
|
|
|
|
/// ### Sub-sub-heading for enum impl-item doc
|
|
|
|
|
/// Text below sub-sub-heading.
|
|
|
|
|
pub fn do_nothing() {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// # Top-doc prose title
|
|
|
|
|
///
|
|
|
|
|
/// Text below heading.
|
|
|
|
|
///
|
|
|
|
|
/// ## Top-doc prose sub-heading
|
|
|
|
|
///
|
|
|
|
|
/// Text below heading.
|
|
|
|
|
pub union HeavilyDocumentedUnion {
|
|
|
|
|
/// # Title for union variant
|
|
|
|
|
/// ## Sub-heading for union variant
|
|
|
|
|
pub nothing: (),
|
|
|
|
|
pub something: f32,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// # Title for union impl doc
|
|
|
|
|
/// ## Sub-heading for union impl doc
|
|
|
|
|
impl HeavilyDocumentedUnion {
|
|
|
|
|
/// # Title for union impl-item doc
|
|
|
|
|
/// ## Sub-heading for union impl-item doc
|
|
|
|
|
pub fn do_nothing() {}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// # Top-doc prose title
|
|
|
|
|
///
|
|
|
|
|
/// Text below heading.
|
|
|
|
|
///
|
|
|
|
|
/// ## Top-doc prose sub-heading
|
|
|
|
|
///
|
|
|
|
|
/// Text below heading.
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules! heavily_documented_macro {
|
|
|
|
|
() => {};
|
|
|
|
|
}
|
2022-02-07 22:36:51 -08:00
|
|
|
|
|
|
|
|
pub trait EmptyTrait1 {}
|
|
|
|
|
pub trait EmptyTrait2 {}
|
|
|
|
|
pub trait EmptyTrait3 {}
|
|
|
|
|
|
|
|
|
|
pub struct HasEmptyTraits{}
|
|
|
|
|
|
|
|
|
|
impl EmptyTrait1 for HasEmptyTraits {}
|
|
|
|
|
impl EmptyTrait2 for HasEmptyTraits {}
|
|
|
|
|
#[doc(cfg(feature = "some-feature"))]
|
|
|
|
|
impl EmptyTrait3 for HasEmptyTraits {}
|
2022-02-14 21:42:36 +01:00
|
|
|
|
|
|
|
|
mod macros;
|
|
|
|
|
pub use macros::*;
|
2022-05-05 21:56:40 +02:00
|
|
|
|
|
|
|
|
#[doc(alias = "AliasForTheStdReexport")]
|
|
|
|
|
pub use ::std as TheStdReexport;
|
2022-05-21 15:05:56 +02:00
|
|
|
|
|
|
|
|
pub mod details {
|
|
|
|
|
/// We check the appearance of the `<details>`/`<summary>` in here.
|
|
|
|
|
///
|
|
|
|
|
/// ## Hello
|
|
|
|
|
///
|
|
|
|
|
/// <details>
|
|
|
|
|
/// <summary><h4>I'm a summary</h4></summary>
|
|
|
|
|
/// <div>I'm the content of the details!</div>
|
|
|
|
|
/// </details>
|
|
|
|
|
pub struct Details;
|
2022-10-21 10:48:41 -07:00
|
|
|
|
|
|
|
|
impl Details {
|
|
|
|
|
/// We check the appearance of the `<details>`/`<summary>` in here.
|
|
|
|
|
///
|
|
|
|
|
/// ## Hello
|
|
|
|
|
///
|
|
|
|
|
/// <details>
|
|
|
|
|
/// <summary><h4>I'm a summary</h4></summary>
|
|
|
|
|
/// <div>I'm the content of the details!</div>
|
|
|
|
|
/// </details>
|
|
|
|
|
pub fn method() {}
|
|
|
|
|
}
|
2022-05-21 15:05:56 +02:00
|
|
|
}
|
2022-08-26 08:27:31 -07:00
|
|
|
|
|
|
|
|
pub mod doc_block_table {
|
|
|
|
|
|
|
|
|
|
pub trait DocBlockTableTrait {
|
2022-10-28 23:07:36 -07:00
|
|
|
fn foo();
|
2022-08-26 08:27:31 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Struct doc.
|
|
|
|
|
///
|
|
|
|
|
/// | header1 | header2 |
|
|
|
|
|
/// |--------------------------|--------------------------|
|
|
|
|
|
/// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum |
|
2022-12-08 09:38:27 -07:00
|
|
|
/// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum |
|
|
|
|
|
/// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum |
|
|
|
|
|
/// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum |
|
2022-08-26 08:27:31 -07:00
|
|
|
pub struct DocBlockTable {}
|
|
|
|
|
|
|
|
|
|
impl DocBlockTableTrait for DocBlockTable {
|
|
|
|
|
/// Trait impl func doc for struct.
|
|
|
|
|
///
|
|
|
|
|
/// | header1 | header2 |
|
|
|
|
|
/// |--------------------------|--------------------------|
|
|
|
|
|
/// | Lorem Ipsum, Lorem Ipsum | Lorem Ipsum, Lorem Ipsum |
|
2022-10-28 23:07:36 -07:00
|
|
|
fn foo() {
|
2022-08-26 08:27:31 -07:00
|
|
|
println!();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2022-09-19 12:32:30 +02:00
|
|
|
|
|
|
|
|
pub struct NotableStructWithLongName<R>(R);
|
|
|
|
|
|
|
|
|
|
impl<R: std::io::Read> NotableStructWithLongName<R> {
|
|
|
|
|
pub fn create_an_iterator_from_read(r: R) -> NotableStructWithLongName<R> { Self(r) }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl<R: std::io::Read> std::iter::Iterator for NotableStructWithLongName<R> {
|
|
|
|
|
type Item = ();
|
|
|
|
|
|
|
|
|
|
fn next(&mut self) -> Option<Self::Item> { () }
|
|
|
|
|
}
|
2022-09-30 10:44:15 -07:00
|
|
|
|
|
|
|
|
pub trait TraitWithNoDocblocks {
|
|
|
|
|
fn first_fn(&self);
|
|
|
|
|
fn second_fn(&self);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub struct TypeWithNoDocblocks;
|
|
|
|
|
|
2022-10-04 17:48:23 +02:00
|
|
|
impl TypeWithNoDocblocks {
|
|
|
|
|
fn x() -> Option<Self> {
|
|
|
|
|
Some(Self)
|
|
|
|
|
}
|
|
|
|
|
fn y() -> Option<u32> {
|
|
|
|
|
// code comment
|
|
|
|
|
let t = Self::x()?;
|
|
|
|
|
Some(0)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-30 10:44:15 -07:00
|
|
|
impl TypeWithNoDocblocks {
|
|
|
|
|
pub fn first_fn(&self) {}
|
2022-10-04 17:48:23 +02:00
|
|
|
pub fn second_fn<'a>(&'a self) {
|
|
|
|
|
let x = 12;
|
|
|
|
|
let y = "a";
|
|
|
|
|
let z = false;
|
|
|
|
|
}
|
2022-09-30 10:44:15 -07:00
|
|
|
}
|
2022-10-08 09:36:37 -07:00
|
|
|
|
|
|
|
|
pub unsafe fn unsafe_fn() {}
|
|
|
|
|
|
|
|
|
|
pub fn safe_fn() {}
|
2022-10-19 17:15:11 +02:00
|
|
|
|
|
|
|
|
#[repr(C)]
|
|
|
|
|
pub struct WithGenerics<T: TraitWithNoDocblocks, S = String, E = WhoLetTheDogOut, P = i8> {
|
|
|
|
|
s: S,
|
|
|
|
|
t: T,
|
|
|
|
|
e: E,
|
|
|
|
|
p: P,
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-22 14:48:58 -07:00
|
|
|
pub struct StructWithPublicUndocumentedFields {
|
|
|
|
|
pub first: u32,
|
|
|
|
|
pub second: u32,
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-19 17:15:11 +02:00
|
|
|
pub const CONST: u8 = 0;
|
|
|
|
|
|
|
|
|
|
pub trait TraitWithoutGenerics {
|
|
|
|
|
const C: u8 = CONST;
|
|
|
|
|
type T = SomeType;
|
|
|
|
|
|
|
|
|
|
fn foo();
|
|
|
|
|
}
|
2022-10-31 07:47:42 -07:00
|
|
|
|
|
|
|
|
pub mod trait_members {
|
|
|
|
|
pub trait TraitMembers {
|
|
|
|
|
/// Some type
|
|
|
|
|
type Type;
|
|
|
|
|
/// Some function
|
|
|
|
|
fn function();
|
|
|
|
|
/// Some other function
|
|
|
|
|
fn function2();
|
|
|
|
|
}
|
|
|
|
|
pub struct HasTrait;
|
|
|
|
|
impl TraitMembers for HasTrait {
|
|
|
|
|
type Type = u8;
|
|
|
|
|
fn function() {}
|
|
|
|
|
fn function2() {}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-13 16:55:45 -07:00
|
|
|
|
|
|
|
|
pub struct TypeWithImplDoc;
|
|
|
|
|
|
|
|
|
|
/// impl doc
|
|
|
|
|
impl TypeWithImplDoc {
|
|
|
|
|
/// fn doc
|
|
|
|
|
pub fn test_fn() {}
|
|
|
|
|
}
|
2022-12-19 10:18:10 -07:00
|
|
|
|
|
|
|
|
/// <sub id="codeblock-sub-1">
|
|
|
|
|
///
|
|
|
|
|
/// ```
|
|
|
|
|
/// one
|
|
|
|
|
/// ```
|
|
|
|
|
///
|
|
|
|
|
/// </sub>
|
|
|
|
|
///
|
|
|
|
|
/// <sub id="codeblock-sub-3">
|
|
|
|
|
///
|
|
|
|
|
/// ```
|
|
|
|
|
/// one
|
|
|
|
|
/// two
|
|
|
|
|
/// three
|
|
|
|
|
/// ```
|
|
|
|
|
///
|
|
|
|
|
/// </sub>
|
|
|
|
|
pub mod codeblock_sub {}
|
2022-10-28 23:07:36 -07:00
|
|
|
pub mod search_results {
|
|
|
|
|
|
|
|
|
|
pub struct SearchResults {
|
|
|
|
|
pub foo: i32,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[macro_export]
|
|
|
|
|
macro_rules! foo {
|
|
|
|
|
() => {};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2023-06-21 17:42:53 +02:00
|
|
|
|
|
|
|
|
pub mod fields {
|
|
|
|
|
pub struct Struct {
|
|
|
|
|
pub a: u8,
|
|
|
|
|
pub b: u32,
|
|
|
|
|
}
|
|
|
|
|
pub union Union {
|
|
|
|
|
pub a: u8,
|
|
|
|
|
pub b: u32,
|
|
|
|
|
}
|
|
|
|
|
pub enum Enum {
|
|
|
|
|
A {
|
|
|
|
|
a: u8,
|
|
|
|
|
b: u32,
|
|
|
|
|
},
|
|
|
|
|
B {
|
|
|
|
|
a: u8,
|
|
|
|
|
b: u32,
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-03 13:26:28 +02:00
|
|
|
|
|
|
|
|
pub mod cfgs {
|
|
|
|
|
#[doc(cfg(all(
|
|
|
|
|
any(not(feature = "appservice-api-c"), not(feature = "appservice-api-s")),
|
|
|
|
|
any(not(feature = "client"), not(feature = "server")),
|
|
|
|
|
)))]
|
|
|
|
|
/// Some docs.
|
|
|
|
|
pub mod cfgs {}
|
|
|
|
|
}
|
rustdoc-search: add impl disambiguator to duplicate assoc items
Helps with #90929
This changes the search results, specifically, when there's more than
one impl with an associated item with the same name. For example,
the search queries `simd<i8> -> simd<i8>` and `simd<i64> -> simd<i64>`
don't link to the same function, but most of the functions have the
same names.
This change should probably be FCP-ed, especially since it adds a new
anchor link format for `main.js` to handle, so that URLs like
`struct.Vec.html#impl-AsMut<[T]>-for-Vec<T,+A>/method.as_mut` redirect
to `struct.Vec.html#method.as_mut-2`. It's a strange design, but there
are a few reasons for it:
* I'd like to avoid making the HTML bigger. Obviously, fixing this bug
is going to add at least a little more data to the search index, but
adding more HTML penalises viewers for the benefit of searchers.
* Breaking `struct.Vec.html#method.len` would also be a disappointment.
On the other hand:
* The path-style anchors might be less prone to link rot than the numbered
anchors. It's definitely less likely to have URLs that appear to "work",
but silently point at the wrong thing.
* This commit arranges the path-style anchor to redirect to the numbered
anchor. Nothing stops rustdoc from doing the opposite, making path-style
anchors the default and redirecting the "legacy" numbered ones.
2023-03-20 16:02:51 -07:00
|
|
|
|
|
|
|
|
pub struct ZyxwvutMethodDisambiguation;
|
|
|
|
|
|
|
|
|
|
impl ZyxwvutMethodDisambiguation {
|
|
|
|
|
pub fn method_impl_disambiguation(&self) -> bool {
|
|
|
|
|
true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub trait ZyxwvutTrait {
|
|
|
|
|
fn method_impl_disambiguation(&self, x: usize) -> usize;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl ZyxwvutTrait for ZyxwvutMethodDisambiguation {
|
|
|
|
|
fn method_impl_disambiguation(&self, x: usize) -> usize {
|
|
|
|
|
x
|
|
|
|
|
}
|
|
|
|
|
}
|