Add primitive documentation to libcore
This works by doing two things: - Adding links that are specific to the crate. Since not all primitive items are defined in `core` (due to lang_items), these need to use relative links and not intra-doc links. - Duplicating `primitive_docs` in both core and std. This allows not needing CARGO_PKG_NAME to build the standard library. It also adds a tidy check to make sure they stay the same.
This commit is contained in:
parent
8c2b6ea37d
commit
69fe39e8a8
29 changed files with 1394 additions and 31 deletions
1
library/core/primitive_docs/box_into_raw.md
Normal file
1
library/core/primitive_docs/box_into_raw.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
../std/boxed/struct.Box.html#method.into_raw
|
1
library/core/primitive_docs/fs_file.md
Normal file
1
library/core/primitive_docs/fs_file.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
../std/fs/struct.File.html
|
1
library/core/primitive_docs/io_bufread.md
Normal file
1
library/core/primitive_docs/io_bufread.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
../std/io/trait.BufRead.html
|
1
library/core/primitive_docs/io_read.md
Normal file
1
library/core/primitive_docs/io_read.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
../std/io/trait.Read.html
|
1
library/core/primitive_docs/io_seek.md
Normal file
1
library/core/primitive_docs/io_seek.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
../std/io/trait.Seek.html
|
1
library/core/primitive_docs/io_write.md
Normal file
1
library/core/primitive_docs/io_write.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
../std/io/trait.Write.html
|
1
library/core/primitive_docs/net_tosocketaddrs.md
Normal file
1
library/core/primitive_docs/net_tosocketaddrs.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
../std/net/trait.ToSocketAddrs.html
|
1
library/core/primitive_docs/process_exit.md
Normal file
1
library/core/primitive_docs/process_exit.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
../std/process/fn.exit.html
|
1
library/core/primitive_docs/string_string.md
Normal file
1
library/core/primitive_docs/string_string.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
../std/string/struct.String.html
|
|
@ -2,7 +2,8 @@
|
||||||
|
|
||||||
#[lang = "bool"]
|
#[lang = "bool"]
|
||||||
impl bool {
|
impl bool {
|
||||||
/// Returns `Some(t)` if the `bool` is [`true`](keyword.true.html), or `None` otherwise.
|
/// Returns `Some(t)` if the `bool` is [`true`](../std/keyword.true.html),
|
||||||
|
/// or `None` otherwise.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -18,7 +19,8 @@ impl bool {
|
||||||
if self { Some(t) } else { None }
|
if self { Some(t) } else { None }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns `Some(f())` if the `bool` is [`true`](keyword.true.html), or `None` otherwise.
|
/// Returns `Some(f())` if the `bool` is [`true`](../std/keyword.true.html),
|
||||||
|
/// or `None` otherwise.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
|
|
@ -96,7 +96,7 @@ impl char {
|
||||||
/// Converts a `u32` to a `char`.
|
/// Converts a `u32` to a `char`.
|
||||||
///
|
///
|
||||||
/// Note that all `char`s are valid [`u32`]s, and can be cast to one with
|
/// Note that all `char`s are valid [`u32`]s, and can be cast to one with
|
||||||
/// [`as`](keyword.as.html):
|
/// [`as`](../std/keyword.as.html):
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// let c = '💯';
|
/// let c = '💯';
|
||||||
|
@ -372,7 +372,7 @@ impl char {
|
||||||
/// println!("\\u{{2764}}");
|
/// println!("\\u{{2764}}");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
|
/// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string):
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}");
|
/// assert_eq!('❤'.escape_unicode().to_string(), "\\u{2764}");
|
||||||
|
@ -448,7 +448,7 @@ impl char {
|
||||||
/// println!("\\n");
|
/// println!("\\n");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
|
/// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string):
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// assert_eq!('\n'.escape_debug().to_string(), "\\n");
|
/// assert_eq!('\n'.escape_debug().to_string(), "\\n");
|
||||||
|
@ -502,7 +502,7 @@ impl char {
|
||||||
/// println!("\\\"");
|
/// println!("\\\"");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
|
/// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string):
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// assert_eq!('"'.escape_default().to_string(), "\\\"");
|
/// assert_eq!('"'.escape_default().to_string(), "\\\"");
|
||||||
|
@ -937,7 +937,7 @@ impl char {
|
||||||
/// println!("i\u{307}");
|
/// println!("i\u{307}");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
|
/// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string):
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// assert_eq!('C'.to_lowercase().to_string(), "c");
|
/// assert_eq!('C'.to_lowercase().to_string(), "c");
|
||||||
|
@ -1002,7 +1002,7 @@ impl char {
|
||||||
/// println!("SS");
|
/// println!("SS");
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// Using [`to_string`](string/trait.ToString.html#tymethod.to_string):
|
/// Using [`to_string`](../std/string/trait.ToString.html#tymethod.to_string):
|
||||||
///
|
///
|
||||||
/// ```
|
/// ```
|
||||||
/// assert_eq!('c'.to_uppercase().to_string(), "C");
|
/// assert_eq!('c'.to_uppercase().to_string(), "C");
|
||||||
|
|
|
@ -130,6 +130,7 @@
|
||||||
#![feature(decl_macro)]
|
#![feature(decl_macro)]
|
||||||
#![feature(doc_cfg)]
|
#![feature(doc_cfg)]
|
||||||
#![feature(doc_notable_trait)]
|
#![feature(doc_notable_trait)]
|
||||||
|
#![feature(doc_primitive)]
|
||||||
#![feature(exhaustive_patterns)]
|
#![feature(exhaustive_patterns)]
|
||||||
#![feature(extern_types)]
|
#![feature(extern_types)]
|
||||||
#![feature(fundamental)]
|
#![feature(fundamental)]
|
||||||
|
@ -355,3 +356,5 @@ pub mod arch {
|
||||||
/* compiler built-in */
|
/* compiler built-in */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
include!("primitive_docs.rs");
|
||||||
|
|
1307
library/core/src/primitive_docs.rs
Normal file
1307
library/core/src/primitive_docs.rs
Normal file
File diff suppressed because it is too large
Load diff
1
library/std/primitive_docs/box_into_raw.md
Normal file
1
library/std/primitive_docs/box_into_raw.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Box::into_raw
|
1
library/std/primitive_docs/fs_file.md
Normal file
1
library/std/primitive_docs/fs_file.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
fs::File
|
1
library/std/primitive_docs/io_bufread.md
Normal file
1
library/std/primitive_docs/io_bufread.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
io::BufRead
|
1
library/std/primitive_docs/io_read.md
Normal file
1
library/std/primitive_docs/io_read.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
io::Read
|
1
library/std/primitive_docs/io_seek.md
Normal file
1
library/std/primitive_docs/io_seek.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
io::Seek
|
1
library/std/primitive_docs/io_write.md
Normal file
1
library/std/primitive_docs/io_write.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
io::Write
|
1
library/std/primitive_docs/net_tosocketaddrs.md
Normal file
1
library/std/primitive_docs/net_tosocketaddrs.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
net::ToSocketAddrs
|
1
library/std/primitive_docs/process_exit.md
Normal file
1
library/std/primitive_docs/process_exit.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
process::exit
|
1
library/std/primitive_docs/string_string.md
Normal file
1
library/std/primitive_docs/string_string.md
Normal file
|
@ -0,0 +1 @@
|
||||||
|
string::String
|
|
@ -1,3 +1,6 @@
|
||||||
|
// `library/{std,core}/src/primitive_docs.rs` should have the same contents.
|
||||||
|
// These are different files so that relative links work properly without
|
||||||
|
// having to have `CARGO_PKG_NAME` set, but conceptually they should always be the same.
|
||||||
#[doc(primitive = "bool")]
|
#[doc(primitive = "bool")]
|
||||||
#[doc(alias = "true")]
|
#[doc(alias = "true")]
|
||||||
#[doc(alias = "false")]
|
#[doc(alias = "false")]
|
||||||
|
@ -20,12 +23,12 @@
|
||||||
/// assert!(!bool_val);
|
/// assert!(!bool_val);
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`true`]: keyword.true.html
|
/// [`true`]: ../std/keyword.true.html
|
||||||
/// [`false`]: keyword.false.html
|
/// [`false`]: ../std/keyword.false.html
|
||||||
/// [`BitAnd`]: ops::BitAnd
|
/// [`BitAnd`]: ops::BitAnd
|
||||||
/// [`BitOr`]: ops::BitOr
|
/// [`BitOr`]: ops::BitOr
|
||||||
/// [`Not`]: ops::Not
|
/// [`Not`]: ops::Not
|
||||||
/// [`if`]: keyword.if.html
|
/// [`if`]: ../std/keyword.if.html
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
|
@ -103,7 +106,7 @@ mod prim_bool {}
|
||||||
/// behaviour of the `!` type - expressions with type `!` will coerce into any other type.
|
/// behaviour of the `!` type - expressions with type `!` will coerce into any other type.
|
||||||
///
|
///
|
||||||
/// [`u32`]: prim@u32
|
/// [`u32`]: prim@u32
|
||||||
/// [`exit`]: process::exit
|
#[doc = concat!("[`exit`]: ", include_str!("../primitive_docs/process_exit.md"))]
|
||||||
///
|
///
|
||||||
/// # `!` and generics
|
/// # `!` and generics
|
||||||
///
|
///
|
||||||
|
@ -188,7 +191,7 @@ mod prim_bool {}
|
||||||
/// because `!` coerces to `Result<!, ConnectionError>` automatically.
|
/// because `!` coerces to `Result<!, ConnectionError>` automatically.
|
||||||
///
|
///
|
||||||
/// [`String::from_str`]: str::FromStr::from_str
|
/// [`String::from_str`]: str::FromStr::from_str
|
||||||
/// [`String`]: string::String
|
#[doc = concat!("[`String`]: ", include_str!("../primitive_docs/string_string.md"))]
|
||||||
/// [`FromStr`]: str::FromStr
|
/// [`FromStr`]: str::FromStr
|
||||||
///
|
///
|
||||||
/// # `!` and traits
|
/// # `!` and traits
|
||||||
|
@ -264,7 +267,7 @@ mod prim_bool {}
|
||||||
/// `impl` for this which simply panics, but the same is true for any type (we could `impl
|
/// `impl` for this which simply panics, but the same is true for any type (we could `impl
|
||||||
/// Default` for (eg.) [`File`] by just making [`default()`] panic.)
|
/// Default` for (eg.) [`File`] by just making [`default()`] panic.)
|
||||||
///
|
///
|
||||||
/// [`File`]: fs::File
|
#[doc = concat!("[`File`]: ", include_str!("../primitive_docs/fs_file.md"))]
|
||||||
/// [`Debug`]: fmt::Debug
|
/// [`Debug`]: fmt::Debug
|
||||||
/// [`default()`]: Default::default
|
/// [`default()`]: Default::default
|
||||||
///
|
///
|
||||||
|
@ -272,7 +275,6 @@ mod prim_bool {}
|
||||||
mod prim_never {}
|
mod prim_never {}
|
||||||
|
|
||||||
#[doc(primitive = "char")]
|
#[doc(primitive = "char")]
|
||||||
//
|
|
||||||
/// A character type.
|
/// A character type.
|
||||||
///
|
///
|
||||||
/// The `char` type represents a single character. More specifically, since
|
/// The `char` type represents a single character. More specifically, since
|
||||||
|
@ -304,7 +306,7 @@ mod prim_never {}
|
||||||
/// assert_eq!(5, s.len() * std::mem::size_of::<u8>());
|
/// assert_eq!(5, s.len() * std::mem::size_of::<u8>());
|
||||||
/// ```
|
/// ```
|
||||||
///
|
///
|
||||||
/// [`String`]: string/struct.String.html
|
#[doc = concat!("[`String`]: ", include_str!("../primitive_docs/string_string.md"))]
|
||||||
///
|
///
|
||||||
/// As always, remember that a human intuition for 'character' might not map to
|
/// As always, remember that a human intuition for 'character' might not map to
|
||||||
/// Unicode's definitions. For example, despite looking similar, the 'é'
|
/// Unicode's definitions. For example, despite looking similar, the 'é'
|
||||||
|
@ -499,7 +501,7 @@ mod prim_unit {}
|
||||||
/// [`null_mut`]: ptr::null_mut
|
/// [`null_mut`]: ptr::null_mut
|
||||||
/// [`is_null`]: pointer::is_null
|
/// [`is_null`]: pointer::is_null
|
||||||
/// [`offset`]: pointer::offset
|
/// [`offset`]: pointer::offset
|
||||||
/// [`into_raw`]: Box::into_raw
|
#[doc = concat!("[`into_raw`]: ", include_str!("../primitive_docs/box_into_raw.md"))]
|
||||||
/// [`drop`]: mem::drop
|
/// [`drop`]: mem::drop
|
||||||
/// [`write`]: ptr::write
|
/// [`write`]: ptr::write
|
||||||
#[stable(feature = "rust1", since = "1.0.0")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
|
@ -581,9 +583,9 @@ mod prim_pointer {}
|
||||||
/// # Editions
|
/// # Editions
|
||||||
///
|
///
|
||||||
/// Prior to Rust 1.53, arrays did not implement [`IntoIterator`] by value, so the method call
|
/// Prior to Rust 1.53, arrays did not implement [`IntoIterator`] by value, so the method call
|
||||||
/// `array.into_iter()` auto-referenced into a [slice iterator](slice::iter). Right now, the old behavior
|
/// `array.into_iter()` auto-referenced into a [slice iterator](slice::iter). Right now, the old
|
||||||
/// is preserved in the 2015 and 2018 editions of Rust for compatibility, ignoring
|
/// behavior is preserved in the 2015 and 2018 editions of Rust for compatibility, ignoring
|
||||||
/// `IntoIterator` by value. In the future, the behavior on the 2015 and 2018 edition
|
/// [`IntoIterator`] by value. In the future, the behavior on the 2015 and 2018 edition
|
||||||
/// might be made consistent to the behavior of later editions.
|
/// might be made consistent to the behavior of later editions.
|
||||||
///
|
///
|
||||||
/// ```rust,edition2018
|
/// ```rust,edition2018
|
||||||
|
@ -1042,15 +1044,15 @@ mod prim_usize {}
|
||||||
/// References, both shared and mutable.
|
/// References, both shared and mutable.
|
||||||
///
|
///
|
||||||
/// A reference represents a borrow of some owned value. You can get one by using the `&` or `&mut`
|
/// A reference represents a borrow of some owned value. You can get one by using the `&` or `&mut`
|
||||||
/// operators on a value, or by using a [`ref`](keyword.ref.html) or
|
/// operators on a value, or by using a [`ref`](../std/keyword.ref.html) or
|
||||||
/// <code>[ref](keyword.ref.html) [mut](keyword.mut.html)</code> pattern.
|
/// <code>[ref](../std/keyword.ref.html) [mut](../std/keyword.mut.html)</code> pattern.
|
||||||
///
|
///
|
||||||
/// For those familiar with pointers, a reference is just a pointer that is assumed to be
|
/// For those familiar with pointers, a reference is just a pointer that is assumed to be
|
||||||
/// aligned, not null, and pointing to memory containing a valid value of `T` - for example,
|
/// aligned, not null, and pointing to memory containing a valid value of `T` - for example,
|
||||||
/// <code>&[bool]</code> can only point to an allocation containing the integer values `1`
|
/// <code>&[bool]</code> can only point to an allocation containing the integer values `1`
|
||||||
/// ([`true`](keyword.true.html)) or `0` ([`false`](keyword.false.html)), but creating a
|
/// ([`true`](../std/keyword.true.html)) or `0` ([`false`](../std/keyword.false.html)), but
|
||||||
/// <code>&[bool]</code> that points to an allocation containing the value `3` causes
|
/// creating a <code>&[bool]</code> that points to an allocation containing
|
||||||
/// undefined behaviour.
|
/// the value `3` causes undefined behaviour.
|
||||||
/// In fact, <code>[Option]\<&T></code> has the same memory representation as a
|
/// In fact, <code>[Option]\<&T></code> has the same memory representation as a
|
||||||
/// nullable but aligned pointer, and can be passed across FFI boundaries as such.
|
/// nullable but aligned pointer, and can be passed across FFI boundaries as such.
|
||||||
///
|
///
|
||||||
|
@ -1117,6 +1119,7 @@ mod prim_usize {}
|
||||||
///
|
///
|
||||||
/// [`DerefMut`]: ops::DerefMut
|
/// [`DerefMut`]: ops::DerefMut
|
||||||
/// [`BorrowMut`]: borrow::BorrowMut
|
/// [`BorrowMut`]: borrow::BorrowMut
|
||||||
|
/// [bool]: prim@bool
|
||||||
///
|
///
|
||||||
/// The following traits are implemented on `&T` references if the underlying `T` also implements
|
/// The following traits are implemented on `&T` references if the underlying `T` also implements
|
||||||
/// that trait:
|
/// that trait:
|
||||||
|
@ -1134,7 +1137,7 @@ mod prim_usize {}
|
||||||
/// [`std::fmt`]: fmt
|
/// [`std::fmt`]: fmt
|
||||||
/// ['Pointer`]: fmt::Pointer
|
/// ['Pointer`]: fmt::Pointer
|
||||||
/// [`Hash`]: hash::Hash
|
/// [`Hash`]: hash::Hash
|
||||||
/// [`ToSocketAddrs`]: net::ToSocketAddrs
|
#[doc = concat!("[`ToSocketAddrs`]: ", include_str!("../primitive_docs/net_tosocketaddrs.md"))]
|
||||||
///
|
///
|
||||||
/// `&mut T` references get all of the above except `ToSocketAddrs`, plus the following, if `T`
|
/// `&mut T` references get all of the above except `ToSocketAddrs`, plus the following, if `T`
|
||||||
/// implements that trait:
|
/// implements that trait:
|
||||||
|
@ -1155,9 +1158,10 @@ mod prim_usize {}
|
||||||
///
|
///
|
||||||
/// [`FusedIterator`]: iter::FusedIterator
|
/// [`FusedIterator`]: iter::FusedIterator
|
||||||
/// [`TrustedLen`]: iter::TrustedLen
|
/// [`TrustedLen`]: iter::TrustedLen
|
||||||
/// [`Seek`]: io::Seek
|
#[doc = concat!("[`Seek`]: ", include_str!("../primitive_docs/io_seek.md"))]
|
||||||
/// [`BufRead`]: io::BufRead
|
#[doc = concat!("[`BufRead`]: ", include_str!("../primitive_docs/io_bufread.md"))]
|
||||||
/// [`Read`]: io::Read
|
#[doc = concat!("[`Read`]: ", include_str!("../primitive_docs/io_read.md"))]
|
||||||
|
#[doc = concat!("[`io::Write`]: ", include_str!("../primitive_docs/io_write.md"))]
|
||||||
///
|
///
|
||||||
/// Note that due to method call deref coercion, simply calling a trait method will act like they
|
/// Note that due to method call deref coercion, simply calling a trait method will act like they
|
||||||
/// work on references as well as they do on owned values! The implementations described here are
|
/// work on references as well as they do on owned values! The implementations described here are
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
// compile-flags: --crate-type lib --edition 2018
|
// compile-flags: --crate-type lib --edition 2018
|
||||||
|
|
||||||
|
#![feature(no_core)]
|
||||||
|
#![no_core]
|
||||||
|
|
||||||
#[doc(primitive = "usize")]
|
#[doc(primitive = "usize")]
|
||||||
/// This is the built-in type `usize`.
|
/// This is the built-in type `usize`.
|
||||||
mod usize {
|
mod usize {
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
// aux-build:primitive-doc.rs
|
// aux-build:primitive-doc.rs
|
||||||
// compile-flags: --extern-html-root-url=primitive_doc=../ -Z unstable-options
|
// compile-flags: --extern-html-root-url=primitive_doc=../ -Z unstable-options
|
||||||
|
#![feature(no_core)]
|
||||||
#![no_std]
|
#![no_core]
|
||||||
|
|
||||||
extern crate primitive_doc;
|
extern crate primitive_doc;
|
||||||
|
|
||||||
// @has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'usize'
|
// @has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'usize'
|
||||||
|
// @has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'link'
|
||||||
|
/// [link](usize)
|
||||||
pub fn foo() -> usize { 0 }
|
pub fn foo() -> usize { 0 }
|
||||||
|
|
5
src/test/rustdoc/primitive/no_std.rs
Normal file
5
src/test/rustdoc/primitive/no_std.rs
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
#![no_std]
|
||||||
|
|
||||||
|
// @has no_std/fn.foo.html '//a/[@href="{{channel}}/core/primitive.u8.html"]' 'u8'
|
||||||
|
// Link to [u8]
|
||||||
|
pub fn foo() -> u8 {}
|
|
@ -46,6 +46,7 @@ pub mod errors;
|
||||||
pub mod extdeps;
|
pub mod extdeps;
|
||||||
pub mod features;
|
pub mod features;
|
||||||
pub mod pal;
|
pub mod pal;
|
||||||
|
pub mod primitive_docs;
|
||||||
pub mod style;
|
pub mod style;
|
||||||
pub mod target_specific_tests;
|
pub mod target_specific_tests;
|
||||||
pub mod ui_tests;
|
pub mod ui_tests;
|
||||||
|
|
|
@ -71,6 +71,7 @@ fn main() {
|
||||||
|
|
||||||
// Checks that only make sense for the std libs.
|
// Checks that only make sense for the std libs.
|
||||||
check!(pal, &library_path);
|
check!(pal, &library_path);
|
||||||
|
check!(primitive_docs, &library_path);
|
||||||
|
|
||||||
// Checks that need to be done for both the compiler and std libraries.
|
// Checks that need to be done for both the compiler and std libraries.
|
||||||
check!(unit_tests, &src_path);
|
check!(unit_tests, &src_path);
|
||||||
|
|
17
src/tools/tidy/src/primitive_docs.rs
Normal file
17
src/tools/tidy/src/primitive_docs.rs
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
//! Tidy check to make sure `library/{std,core}/src/primitive_docs.rs` are the same file. These are
|
||||||
|
//! different files so that relative links work properly without having to have `CARGO_PKG_NAME`
|
||||||
|
//! set, but conceptually they should always be the same.
|
||||||
|
|
||||||
|
use std::path::Path;
|
||||||
|
|
||||||
|
pub fn check(library_path: &Path, bad: &mut bool) {
|
||||||
|
let std_name = "std/src/primitive_docs.rs";
|
||||||
|
let core_name = "core/src/primitive_docs.rs";
|
||||||
|
let std_contents = std::fs::read_to_string(library_path.join(std_name))
|
||||||
|
.unwrap_or_else(|e| panic!("failed to read library/{}: {}", std_name, e));
|
||||||
|
let core_contents = std::fs::read_to_string(library_path.join(core_name))
|
||||||
|
.unwrap_or_else(|e| panic!("failed to read library/{}: {}", core_name, e));
|
||||||
|
if std_contents != core_contents {
|
||||||
|
tidy_error!(bad, "library/{} and library/{} have different contents", core_name, std_name);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue