From 1f143bc46fe04aa564736b4741a8f179c46eccc5 Mon Sep 17 00:00:00 2001 From: Corey Farwell Date: Wed, 28 Mar 2018 11:25:52 +0200 Subject: [PATCH 01/10] Explicitly mention `Option` in `?` error message. Save users the time/effort of having to lookup what types implement the `Try` trait. --- src/libcore/ops/try.rs | 2 +- src/test/ui/suggestions/try-on-option.stderr | 2 +- src/test/ui/suggestions/try-operator-on-main.stderr | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libcore/ops/try.rs b/src/libcore/ops/try.rs index 81e5cb5c3504..ef6a8fb6a61c 100644 --- a/src/libcore/ops/try.rs +++ b/src/libcore/ops/try.rs @@ -20,7 +20,7 @@ any(from_method="from_error", from_method="from_ok"), from_desugaring="?"), message="the `?` operator can only be used in a \ - function that returns `Result` \ + function that returns `Result` or `Option` \ (or another type that implements `{Try}`)", label="cannot use the `?` operator in a function that returns `{Self}`"), on(all(from_method="into_result", from_desugaring="?"), diff --git a/src/test/ui/suggestions/try-on-option.stderr b/src/test/ui/suggestions/try-on-option.stderr index aee52808f1e2..265ee593bb70 100644 --- a/src/test/ui/suggestions/try-on-option.stderr +++ b/src/test/ui/suggestions/try-on-option.stderr @@ -6,7 +6,7 @@ LL | x?; //~ the trait bound | = note: required by `std::convert::From::from` -error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`) +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`) --> $DIR/try-on-option.rs:23:5 | LL | x?; //~ the `?` operator diff --git a/src/test/ui/suggestions/try-operator-on-main.stderr b/src/test/ui/suggestions/try-operator-on-main.stderr index 7536bbcd2db3..121ae14f999c 100644 --- a/src/test/ui/suggestions/try-operator-on-main.stderr +++ b/src/test/ui/suggestions/try-operator-on-main.stderr @@ -1,4 +1,4 @@ -error[E0277]: the `?` operator can only be used in a function that returns `Result` (or another type that implements `std::ops::Try`) +error[E0277]: the `?` operator can only be used in a function that returns `Result` or `Option` (or another type that implements `std::ops::Try`) --> $DIR/try-operator-on-main.rs:19:5 | LL | std::fs::File::open("foo")?; //~ ERROR the `?` operator can only From 93f96be7d974de1b98e37b03a2ae5464b7a9564a Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 28 Mar 2018 10:48:00 +0200 Subject: [PATCH 02/10] Fix tooltip position --- src/librustdoc/html/static/rustdoc.css | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 9b899dd4517e..591645b73505 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -109,7 +109,6 @@ h3.impl, h3.method, h4.method, h3.type, h4.type, h4.associatedconstant { position: relative; } h3.impl, h3.method, h3.type { - margin-top: 15px; padding-left: 15px; } @@ -467,7 +466,10 @@ h4 > code, h3 > code, .invisible > code { font-size: 0.8em; } -.content .methods > div:not(.important-traits) { margin-left: 40px; } +.content .methods > div:not(.important-traits) { + margin-left: 40px; + margin-bottom: 15px; +} .content .impl-items .docblock, .content .impl-items .stability { margin-left: 40px; From 082e50d9869a3c159bb0ce1570b71ad0d86ea23d Mon Sep 17 00:00:00 2001 From: tinaun Date: Wed, 28 Mar 2018 17:39:27 -0400 Subject: [PATCH 03/10] Don't mention unstable constructors in release notes --- RELEASES.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/RELEASES.md b/RELEASES.md index 100de005990c..c44c501305f5 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -47,8 +47,6 @@ eg. `static MINUTE: Duration = Duration::from_secs(60);` - [`Duration::new`][47300] - [`Duration::from_secs`][47300] - [`Duration::from_millis`][47300] -- [`Duration::from_micros`][47300] -- [`Duration::from_nanos`][47300] Cargo ----- From 77c70a8c47f569481a364df42b2eae72733e7d4c Mon Sep 17 00:00:00 2001 From: Oliver Middleton Date: Wed, 28 Mar 2018 22:43:23 +0100 Subject: [PATCH 04/10] rustbuild: Don't leak file handles when creating junctions on Windows This fixes building the compiler docs because stage1-rustc\x86_64-pc-windows-msvc\doc is used twice which doesn't work if we still have a handle from the first time. --- src/bootstrap/util.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/util.rs b/src/bootstrap/util.rs index 07941e588387..492eceef05c7 100644 --- a/src/bootstrap/util.rs +++ b/src/bootstrap/util.rs @@ -288,6 +288,7 @@ pub fn symlink_dir(src: &Path, dest: &Path) -> io::Result<()> { nOutBufferSize: DWORD, lpBytesReturned: LPDWORD, lpOverlapped: LPOVERLAPPED) -> BOOL; + fn CloseHandle(hObject: HANDLE) -> BOOL; } fn to_u16s>(s: S) -> io::Result> { @@ -341,11 +342,13 @@ pub fn symlink_dir(src: &Path, dest: &Path) -> io::Result<()> { &mut ret, ptr::null_mut()); - if res == 0 { + let out = if res == 0 { Err(io::Error::last_os_error()) } else { Ok(()) - } + }; + CloseHandle(h); + out } } } From 262be13643cf5e3ff4f4e880b2dee601d4740fd8 Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 29 Mar 2018 09:34:39 +0900 Subject: [PATCH 05/10] Use f{32,64}::to_bits for is_zero test in vec::SpecFromElem vec::SpecFromElem provides an optimization to use calloc to fill a Vec when the element given to fill the Vec is represented by 0. For floats, the test for that currently used is `x == 0. && x.is_sign_positive()`. When compiled in a standalone function, rustc generates the following assembly: ``` xorps xmm1, xmm1 ucomisd xmm0, xmm1 setnp al sete cl and cl, al movq rax, xmm0 test rax, rax setns al and al, cl ret ``` A simpler test telling us whether the value is represented by 0, is `x.to_bits() == 0`, which rustc compiles to: ``` movq rax, xmm0 test rax, rax sete al ret ``` Not that the test is hot in any way, but it also makes it clearer what the intent in the rust code is. --- src/liballoc/vec.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 953f95876be1..3c2f91d08e35 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1574,8 +1574,8 @@ impl_spec_from_elem!(u64, |x| x == 0); impl_spec_from_elem!(u128, |x| x == 0); impl_spec_from_elem!(usize, |x| x == 0); -impl_spec_from_elem!(f32, |x: f32| x == 0. && x.is_sign_positive()); -impl_spec_from_elem!(f64, |x: f64| x == 0. && x.is_sign_positive()); +impl_spec_from_elem!(f32, |x: f32| x.to_bits() == 0); +impl_spec_from_elem!(f64, |x: f64| x.to_bits() == 0); //////////////////////////////////////////////////////////////////////////////// // Common trait implementations for Vec From 6462c0bd7f03c9f1310ea9e4d259462e753e967e Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Thu, 29 Mar 2018 11:51:52 +0900 Subject: [PATCH 06/10] Remove unnecessary use core::hash in liballoc/boxed.rs It' only used for hash::Hasher, but Hasher is also imported. --- src/liballoc/boxed.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/liballoc/boxed.rs b/src/liballoc/boxed.rs index bfd806f99e78..fdc3ef4efb86 100644 --- a/src/liballoc/boxed.rs +++ b/src/liballoc/boxed.rs @@ -62,7 +62,7 @@ use core::any::Any; use core::borrow; use core::cmp::Ordering; use core::fmt; -use core::hash::{self, Hash, Hasher}; +use core::hash::{Hash, Hasher}; use core::iter::FusedIterator; use core::marker::{self, Unpin, Unsize}; use core::mem::{self, Pin}; @@ -508,7 +508,7 @@ impl Eq for Box {} #[stable(feature = "rust1", since = "1.0.0")] impl Hash for Box { - fn hash(&self, state: &mut H) { + fn hash(&self, state: &mut H) { (**self).hash(state); } } From 39fe29bf0ca4d105a6118b4a1ca5ce17a59b71b1 Mon Sep 17 00:00:00 2001 From: Josh Triplett Date: Thu, 29 Mar 2018 09:43:26 +0200 Subject: [PATCH 07/10] src/libcore/ptr.rs: Fix documentation for size of `Option>` Seems more useful to say that it has the same size as `*mut T`. --- src/libcore/ptr.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index aebd50d9c6b3..5a54de06b5ef 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -2653,7 +2653,7 @@ impl<'a, T: ?Sized> From> for Unique { /// /// Unlike `*mut T`, the pointer must always be non-null, even if the pointer /// is never dereferenced. This is so that enums may use this forbidden value -/// as a discriminant -- `Option>` has the same size as `NonNull`. +/// as a discriminant -- `Option>` has the same size as `*mut T`. /// However the pointer may still dangle if it isn't dereferenced. /// /// Unlike `*mut T`, `NonNull` is covariant over `T`. If this is incorrect From 772a8028ffbb3386d8da8cf5a17517b453eed767 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Wed, 28 Mar 2018 11:18:45 +0200 Subject: [PATCH 08/10] Rename main theme into light theme --- src/doc/rustdoc/src/unstable-features.md | 6 +++--- src/librustdoc/html/layout.rs | 2 +- src/librustdoc/html/render.rs | 12 ++++++------ src/librustdoc/html/static/storage.js | 2 +- .../html/static/themes/{main.css => light.css} | 0 src/librustdoc/lib.rs | 8 ++++---- src/tools/error_index_generator/main.rs | 4 ++-- src/tools/rustdoc-themes/main.rs | 2 +- 8 files changed, 18 insertions(+), 18 deletions(-) rename src/librustdoc/html/static/themes/{main.css => light.css} (100%) diff --git a/src/doc/rustdoc/src/unstable-features.md b/src/doc/rustdoc/src/unstable-features.md index 16356c20c706..44b9145a8c2e 100644 --- a/src/doc/rustdoc/src/unstable-features.md +++ b/src/doc/rustdoc/src/unstable-features.md @@ -305,7 +305,7 @@ $ rustdoc src/lib.rs -Z unstable-options --themes theme.css Giving this flag to `rustdoc` will make it copy your theme into the generated crate docs and enable it in the theme selector. Note that `rustdoc` will reject your theme file if it doesn't style -everything the "main" theme does. See `--theme-checker` below for details. +everything the "light" theme does. See `--theme-checker` below for details. ### `--theme-checker`: verify theme CSS for validity @@ -316,7 +316,7 @@ $ rustdoc -Z unstable-options --theme-checker theme.css ``` Before including your theme in crate docs, `rustdoc` will compare all the CSS rules it contains -against the "main" theme included by default. Using this flag will allow you to see which rules are +against the "light" theme included by default. Using this flag will allow you to see which rules are missing if `rustdoc` rejects your theme. ### `--resource-suffix`: modifying the name of CSS/JavaScript in crate docs @@ -330,7 +330,7 @@ $ rustdoc src/lib.rs -Z unstable-options --resource-suffix suf When rendering docs, `rustdoc` creates several CSS and JavaScript files as part of the output. Since all these files are linked from every page, changing where they are can be cumbersome if you need to specially cache them. This flag will rename all these files in the output to include the suffix in -the filename. For example, `main.css` would become `main-suf.css` with the above command. +the filename. For example, `light.css` would become `light-suf.css` with the above command. ### `--display-warnings`: display warnings when documenting or running documentation tests diff --git a/src/librustdoc/html/layout.rs b/src/librustdoc/html/layout.rs index 0151a8c3ab71..aac5d0d2601d 100644 --- a/src/librustdoc/html/layout.rs +++ b/src/librustdoc/html/layout.rs @@ -53,7 +53,7 @@ r##" id="mainThemeStyle"> {themes} - + {css_extension} diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 678e1762a551..6d71b0ec8ec7 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -129,8 +129,8 @@ pub struct SharedContext { pub sort_modules_alphabetically: bool, /// Additional themes to be added to the generated docs. pub themes: Vec, - /// Suffix to be added on resource files (if suffix is "-v2" then "main.css" becomes - /// "main-v2.css"). + /// Suffix to be added on resource files (if suffix is "-v2" then "light.css" becomes + /// "light-v2.css"). pub resource_suffix: String, } @@ -743,7 +743,7 @@ fn write_shared(cx: &Context, write(cx.dst.join(&format!("rustdoc{}.css", cx.shared.resource_suffix)), include_bytes!("static/rustdoc.css"))?; - // To avoid "main.css" to be overwritten, we'll first run over the received themes and only + // To avoid "light.css" to be overwritten, we'll first run over the received themes and only // then we'll run over the "official" styles. let mut themes: HashSet = HashSet::new(); @@ -761,9 +761,9 @@ fn write_shared(cx: &Context, write(cx.dst.join(&format!("brush{}.svg", cx.shared.resource_suffix)), include_bytes!("static/brush.svg"))?; - write(cx.dst.join(&format!("main{}.css", cx.shared.resource_suffix)), - include_bytes!("static/themes/main.css"))?; - themes.insert("main".to_owned()); + write(cx.dst.join(&format!("light{}.css", cx.shared.resource_suffix)), + include_bytes!("static/themes/light.css"))?; + themes.insert("light".to_owned()); write(cx.dst.join(&format!("dark{}.css", cx.shared.resource_suffix)), include_bytes!("static/themes/dark.css"))?; themes.insert("dark".to_owned()); diff --git a/src/librustdoc/html/static/storage.js b/src/librustdoc/html/static/storage.js index c8571e4cf918..2f4e203ebc5c 100644 --- a/src/librustdoc/html/static/storage.js +++ b/src/librustdoc/html/static/storage.js @@ -67,4 +67,4 @@ function switchTheme(styleElem, mainStyleElem, newTheme) { } } -switchTheme(currentTheme, mainTheme, getCurrentValue('rustdoc-theme') || 'main'); +switchTheme(currentTheme, mainTheme, getCurrentValue('rustdoc-theme') || 'light'); diff --git a/src/librustdoc/html/static/themes/main.css b/src/librustdoc/html/static/themes/light.css similarity index 100% rename from src/librustdoc/html/static/themes/main.css rename to src/librustdoc/html/static/themes/light.css diff --git a/src/librustdoc/lib.rs b/src/librustdoc/lib.rs index bec25a98227a..9f6e0c2944e3 100644 --- a/src/librustdoc/lib.rs +++ b/src/librustdoc/lib.rs @@ -266,8 +266,8 @@ pub fn opts() -> Vec { unstable("resource-suffix", |o| { o.optopt("", "resource-suffix", - "suffix to add to CSS and JavaScript files, e.g. \"main.css\" will become \ - \"main-suffix.css\"", + "suffix to add to CSS and JavaScript files, e.g. \"light.css\" will become \ + \"light-suffix.css\"", "PATH") }), ] @@ -321,7 +321,7 @@ pub fn main_args(args: &[String]) -> isize { let to_check = matches.opt_strs("theme-checker"); if !to_check.is_empty() { - let paths = theme::load_css_paths(include_bytes!("html/static/themes/main.css")); + let paths = theme::load_css_paths(include_bytes!("html/static/themes/light.css")); let mut errors = 0; println!("rustdoc: [theme-checker] Starting tests!"); @@ -392,7 +392,7 @@ pub fn main_args(args: &[String]) -> isize { let mut themes = Vec::new(); if matches.opt_present("themes") { - let paths = theme::load_css_paths(include_bytes!("html/static/themes/main.css")); + let paths = theme::load_css_paths(include_bytes!("html/static/themes/light.css")); for (theme_file, theme_s) in matches.opt_strs("themes") .iter() diff --git a/src/tools/error_index_generator/main.rs b/src/tools/error_index_generator/main.rs index cdeb60156725..ade7ae0a4aee 100644 --- a/src/tools/error_index_generator/main.rs +++ b/src/tools/error_index_generator/main.rs @@ -61,8 +61,8 @@ impl Formatter for HTMLFormatter { Rust Compiler Error Index - - + +