From 51fdc2bf1431d6ac1f32531f820a937ddbb70048 Mon Sep 17 00:00:00 2001 From: Florian Hartwig Date: Tue, 30 Oct 2018 23:27:05 +0100 Subject: [PATCH 01/31] Add example of using the indexing operator to HashMap docs --- src/libstd/collections/hash/map.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libstd/collections/hash/map.rs b/src/libstd/collections/hash/map.rs index ef5dae724b247..2bc440a19fb08 100644 --- a/src/libstd/collections/hash/map.rs +++ b/src/libstd/collections/hash/map.rs @@ -318,6 +318,9 @@ const DISPLACEMENT_THRESHOLD: usize = 128; /// } /// } /// +/// // Look up the value for a key (will panic if the key is not found). +/// println!("Review for Jane: {}", book_reviews["Pride and Prejudice"]); +/// /// // Iterate over everything. /// for (book, review) in &book_reviews { /// println!("{}: \"{}\"", book, review); From 700c83bc05ebeddbe3d3a10c2e309826d563b12b Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Sun, 24 Jun 2018 09:38:56 +0200 Subject: [PATCH 02/31] Document `From` implementations --- src/libstd/path.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index a153456370c6f..ab37bb7520972 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1397,6 +1397,8 @@ impl<'a> From<&'a Path> for Box { #[stable(feature = "path_buf_from_box", since = "1.18.0")] impl From> for PathBuf { + /// Converts a `Box` into a `PathBuf`. + /// This conversion does not allocate memory fn from(boxed: Box) -> PathBuf { boxed.into_path_buf() } @@ -1404,6 +1406,8 @@ impl From> for PathBuf { #[stable(feature = "box_from_path_buf", since = "1.20.0")] impl From for Box { + /// Converts a `PathBuf` into a `Box`. + /// This conversion does not allocate memory fn from(p: PathBuf) -> Box { p.into_boxed_path() } @@ -1426,6 +1430,9 @@ impl<'a, T: ?Sized + AsRef> From<&'a T> for PathBuf { #[stable(feature = "rust1", since = "1.0.0")] impl From for PathBuf { + /// Converts a `OsString` into a `PathBuf`. + /// This conversion copies the data. + /// This conversion does allocate memory. fn from(s: OsString) -> PathBuf { PathBuf { inner: s } } @@ -1433,6 +1440,9 @@ impl From for PathBuf { #[stable(feature = "from_path_buf_for_os_string", since = "1.14.0")] impl From for OsString { + /// Converts a `PathBuf` into a `OsString`. + /// This conversion copies the data. + /// This conversion does allocate memory. fn from(path_buf : PathBuf) -> OsString { path_buf.inner } @@ -1440,6 +1450,8 @@ impl From for OsString { #[stable(feature = "rust1", since = "1.0.0")] impl From for PathBuf { + /// Converts a `String` into a `PathBuf`. + /// This conversion does not allocate memory fn from(s: String) -> PathBuf { PathBuf::from(OsString::from(s)) } @@ -1536,6 +1548,10 @@ impl<'a> From> for PathBuf { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From for Arc { + /// Converts a `PathBuf` into a `Arc`. + /// This conversion happens in place. + /// This conversion does not allocate memory. + /// This function is unsafe. Data can't be moved from this reference. #[inline] fn from(s: PathBuf) -> Arc { let arc: Arc = Arc::from(s.into_os_string()); @@ -1545,6 +1561,10 @@ impl From for Arc { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl<'a> From<&'a Path> for Arc { + /// Converts a `PathBuf` into a `Arc`. + /// This conversion happens in place. + /// This conversion does not allocate memory. + /// This function is unsafe. Data can't be moved from this reference. #[inline] fn from(s: &Path) -> Arc { let arc: Arc = Arc::from(s.as_os_str()); @@ -1554,6 +1574,10 @@ impl<'a> From<&'a Path> for Arc { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From for Rc { + /// Converts a `PathBuf` into a `Rc`. + /// This conversion happens in place. + /// This conversion does not allocate memory. + /// This function is unsafe. Data can't be moved from this reference. #[inline] fn from(s: PathBuf) -> Rc { let rc: Rc = Rc::from(s.into_os_string()); From 072bca3ff5a3907a71c22fba041825cfa3eb321e Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Mon, 25 Jun 2018 14:24:39 +0200 Subject: [PATCH 03/31] Remove 'unsafe' comments --- src/libstd/path.rs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index ab37bb7520972..9145eeb6063f6 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1551,7 +1551,6 @@ impl From for Arc { /// Converts a `PathBuf` into a `Arc`. /// This conversion happens in place. /// This conversion does not allocate memory. - /// This function is unsafe. Data can't be moved from this reference. #[inline] fn from(s: PathBuf) -> Arc { let arc: Arc = Arc::from(s.into_os_string()); @@ -1564,7 +1563,6 @@ impl<'a> From<&'a Path> for Arc { /// Converts a `PathBuf` into a `Arc`. /// This conversion happens in place. /// This conversion does not allocate memory. - /// This function is unsafe. Data can't be moved from this reference. #[inline] fn from(s: &Path) -> Arc { let arc: Arc = Arc::from(s.as_os_str()); @@ -1577,7 +1575,6 @@ impl From for Rc { /// Converts a `PathBuf` into a `Rc`. /// This conversion happens in place. /// This conversion does not allocate memory. - /// This function is unsafe. Data can't be moved from this reference. #[inline] fn from(s: PathBuf) -> Rc { let rc: Rc = Rc::from(s.into_os_string()); From 88a708dd6a5bb14f3a19ae98238ddf2d03cb93d3 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Mon, 25 Jun 2018 21:29:22 +0200 Subject: [PATCH 04/31] Update comments --- src/libstd/path.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 9145eeb6063f6..e631bb90f5741 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1431,8 +1431,7 @@ impl<'a, T: ?Sized + AsRef> From<&'a T> for PathBuf { #[stable(feature = "rust1", since = "1.0.0")] impl From for PathBuf { /// Converts a `OsString` into a `PathBuf`. - /// This conversion copies the data. - /// This conversion does allocate memory. + /// This conversion does not allocate memory fn from(s: OsString) -> PathBuf { PathBuf { inner: s } } @@ -1441,8 +1440,7 @@ impl From for PathBuf { #[stable(feature = "from_path_buf_for_os_string", since = "1.14.0")] impl From for OsString { /// Converts a `PathBuf` into a `OsString`. - /// This conversion copies the data. - /// This conversion does allocate memory. + /// This conversion does not allocate memory fn from(path_buf : PathBuf) -> OsString { path_buf.inner } From 5c747eb32654401b9b6fe053c3f51399a6454f8c Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Thu, 26 Jul 2018 10:59:46 +0200 Subject: [PATCH 05/31] Update style of comments --- src/libstd/path.rs | 40 ++++++++++++++++++++++++++-------------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index e631bb90f5741..9f6fcad242292 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1397,7 +1397,8 @@ impl<'a> From<&'a Path> for Box { #[stable(feature = "path_buf_from_box", since = "1.18.0")] impl From> for PathBuf { - /// Converts a `Box` into a `PathBuf`. + /// Converts a `Box` into a `PathBuf` + /// /// This conversion does not allocate memory fn from(boxed: Box) -> PathBuf { boxed.into_path_buf() @@ -1406,7 +1407,8 @@ impl From> for PathBuf { #[stable(feature = "box_from_path_buf", since = "1.20.0")] impl From for Box { - /// Converts a `PathBuf` into a `Box`. + /// Converts a `PathBuf` into a `Box` + /// /// This conversion does not allocate memory fn from(p: PathBuf) -> Box { p.into_boxed_path() @@ -1430,7 +1432,8 @@ impl<'a, T: ?Sized + AsRef> From<&'a T> for PathBuf { #[stable(feature = "rust1", since = "1.0.0")] impl From for PathBuf { - /// Converts a `OsString` into a `PathBuf`. + /// Converts a `OsString` into a `PathBuf` + /// /// This conversion does not allocate memory fn from(s: OsString) -> PathBuf { PathBuf { inner: s } @@ -1439,7 +1442,8 @@ impl From for PathBuf { #[stable(feature = "from_path_buf_for_os_string", since = "1.14.0")] impl From for OsString { - /// Converts a `PathBuf` into a `OsString`. + /// Converts a `PathBuf` into a `OsString` + /// /// This conversion does not allocate memory fn from(path_buf : PathBuf) -> OsString { path_buf.inner @@ -1448,7 +1452,8 @@ impl From for OsString { #[stable(feature = "rust1", since = "1.0.0")] impl From for PathBuf { - /// Converts a `String` into a `PathBuf`. + /// Converts a `String` into a `PathBuf` + /// /// This conversion does not allocate memory fn from(s: String) -> PathBuf { PathBuf::from(OsString::from(s)) @@ -1546,9 +1551,11 @@ impl<'a> From> for PathBuf { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From for Arc { - /// Converts a `PathBuf` into a `Arc`. - /// This conversion happens in place. - /// This conversion does not allocate memory. + /// Converts a `PathBuf` into a `Arc` + /// + /// This conversion happens in place + /// + /// This conversion does not allocate memory #[inline] fn from(s: PathBuf) -> Arc { let arc: Arc = Arc::from(s.into_os_string()); @@ -1558,9 +1565,12 @@ impl From for Arc { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl<'a> From<&'a Path> for Arc { - /// Converts a `PathBuf` into a `Arc`. - /// This conversion happens in place. - /// This conversion does not allocate memory. + /// Converts a `PathBuf` into a `Arc` + /// + /// This conversion happens in place + /// + /// This conversion does not allocate memory + /// #[inline] fn from(s: &Path) -> Arc { let arc: Arc = Arc::from(s.as_os_str()); @@ -1570,9 +1580,11 @@ impl<'a> From<&'a Path> for Arc { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From for Rc { - /// Converts a `PathBuf` into a `Rc`. - /// This conversion happens in place. - /// This conversion does not allocate memory. + /// Converts a `PathBuf` into a `Rc` + /// + /// This conversion happens in place + /// + /// This conversion does not allocate memory #[inline] fn from(s: PathBuf) -> Rc { let rc: Rc = Rc::from(s.into_os_string()); From e8dafbaf10bf9e54854382f0aa830d219aec85bb Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 21 Nov 2018 13:06:22 +0100 Subject: [PATCH 06/31] Adjust doc comments --- src/libstd/path.rs | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 9f6fcad242292..2d0a2501f7e99 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1399,7 +1399,7 @@ impl<'a> From<&'a Path> for Box { impl From> for PathBuf { /// Converts a `Box` into a `PathBuf` /// - /// This conversion does not allocate memory + /// This conversion does not allocate or copy memory. fn from(boxed: Box) -> PathBuf { boxed.into_path_buf() } @@ -1409,7 +1409,8 @@ impl From> for PathBuf { impl From for Box { /// Converts a `PathBuf` into a `Box` /// - /// This conversion does not allocate memory + /// This conversion currently should not allocate memory, + // but this behavior is not guaranteed on all platforms or in all future versions. fn from(p: PathBuf) -> Box { p.into_boxed_path() } @@ -1434,7 +1435,7 @@ impl<'a, T: ?Sized + AsRef> From<&'a T> for PathBuf { impl From for PathBuf { /// Converts a `OsString` into a `PathBuf` /// - /// This conversion does not allocate memory + /// This conversion does not allocate or copy memory. fn from(s: OsString) -> PathBuf { PathBuf { inner: s } } @@ -1444,7 +1445,7 @@ impl From for PathBuf { impl From for OsString { /// Converts a `PathBuf` into a `OsString` /// - /// This conversion does not allocate memory + /// This conversion does not allocate or copy memory. fn from(path_buf : PathBuf) -> OsString { path_buf.inner } @@ -1454,7 +1455,7 @@ impl From for OsString { impl From for PathBuf { /// Converts a `String` into a `PathBuf` /// - /// This conversion does not allocate memory + /// This conversion does not allocate or copy memory. fn from(s: String) -> PathBuf { PathBuf::from(OsString::from(s)) } @@ -1551,11 +1552,7 @@ impl<'a> From> for PathBuf { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From for Arc { - /// Converts a `PathBuf` into a `Arc` - /// - /// This conversion happens in place - /// - /// This conversion does not allocate memory + /// Converts a Path into a Rc by copying the Path data into a new Rc buffer. #[inline] fn from(s: PathBuf) -> Arc { let arc: Arc = Arc::from(s.into_os_string()); @@ -1565,12 +1562,7 @@ impl From for Arc { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl<'a> From<&'a Path> for Arc { - /// Converts a `PathBuf` into a `Arc` - /// - /// This conversion happens in place - /// - /// This conversion does not allocate memory - /// + /// Converts a Path into a Rc by copying the Path data into a new Rc buffer. #[inline] fn from(s: &Path) -> Arc { let arc: Arc = Arc::from(s.as_os_str()); @@ -1580,11 +1572,7 @@ impl<'a> From<&'a Path> for Arc { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl From for Rc { - /// Converts a `PathBuf` into a `Rc` - /// - /// This conversion happens in place - /// - /// This conversion does not allocate memory + /// Converts a Path into a Rc by copying the Path data into a new Rc buffer. #[inline] fn from(s: PathBuf) -> Rc { let rc: Rc = Rc::from(s.into_os_string()); @@ -1594,6 +1582,7 @@ impl From for Rc { #[stable(feature = "shared_from_slice2", since = "1.24.0")] impl<'a> From<&'a Path> for Rc { + /// Converts a Path into a Rc by copying the Path data into a new Rc buffer. #[inline] fn from(s: &Path) -> Rc { let rc: Rc = Rc::from(s.as_os_str()); From 7933628de58851281544fe2a7b4e0d0673652e47 Mon Sep 17 00:00:00 2001 From: Bastian Gruber Date: Wed, 21 Nov 2018 13:57:56 +0100 Subject: [PATCH 07/31] Remove trailing whitespace --- src/libstd/path.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libstd/path.rs b/src/libstd/path.rs index 2d0a2501f7e99..dcd02ac59b6c8 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1409,7 +1409,7 @@ impl From> for PathBuf { impl From for Box { /// Converts a `PathBuf` into a `Box` /// - /// This conversion currently should not allocate memory, + /// This conversion currently should not allocate memory, // but this behavior is not guaranteed on all platforms or in all future versions. fn from(p: PathBuf) -> Box { p.into_boxed_path() From c209ed84359804d200454f117946d41e5ac84159 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Thu, 1 Nov 2018 02:20:49 +0100 Subject: [PATCH 08/31] Improve no result found sentence in doc search --- src/librustdoc/html/static/main.js | 11 ++++++++++- src/librustdoc/html/static/rustdoc.css | 13 ++++++++++--- src/librustdoc/html/static/themes/dark.css | 2 +- src/librustdoc/html/static/themes/light.css | 2 +- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index 3174c1be3adc8..27b1dfc9ce39a 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -1340,7 +1340,16 @@ output = '
No results :(
' + 'Try on DuckDuckGo?
'; + '">DuckDuckGo?

' + + 'Or try looking in one of these:'; } return [output, length]; } diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 8bcb828a5ade1..aa43a0bb58ad9 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -658,9 +658,9 @@ a { padding-right: 10px; } .content .search-results td:first-child a:after { - clear: both; - content: ""; - display: block; + clear: both; + content: ""; + display: block; } .content .search-results td:first-child a span { float: left; @@ -1116,6 +1116,13 @@ pre.rust { margin-top: 20px; } +.search-failed > ul { + text-align: left; + max-width: 570px; + margin-left: auto; + margin-right: auto; +} + #titles { height: 35px; } diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 4a8950b236c62..9c90c94858116 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -285,7 +285,7 @@ pre.ignore:hover, .information:hover + pre.ignore { color: rgba(255,142,0,1); } -.search-failed > a { +.search-failed a { color: #0089ff; } diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index b3b0b6b2ea9e8..e839fc3f2783f 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -279,7 +279,7 @@ pre.ignore:hover, .information:hover + pre.ignore { color: rgba(255,142,0,1); } -.search-failed > a { +.search-failed a { color: #0089ff; } From dd717deccb3a4698beac8edb0a75e2efb6f08ebb Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 1 Oct 2018 00:47:54 +0200 Subject: [PATCH 09/31] Add crate filtering --- src/librustdoc/html/layout.rs | 15 ++-- src/librustdoc/html/render.rs | 2 +- src/librustdoc/html/static/main.js | 99 +++++++++++++++++---- src/librustdoc/html/static/rustdoc.css | 24 ++++- src/librustdoc/html/static/themes/dark.css | 8 +- src/librustdoc/html/static/themes/light.css | 9 +- 6 files changed, 131 insertions(+), 26 deletions(-) diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 6868c7707adc8..d585b737517b3 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -81,11 +81,16 @@ pub fn render(