Skip to content

Rollup of 5 pull requests #46574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 12 commits into from
Dec 8, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -7,3 +7,4 @@
src/etc/installer/gfx/* binary
*.woff binary
src/vendor/** -text
Cargo.lock -merge
2 changes: 1 addition & 1 deletion src/libcore/macros.rs
Original file line number Diff line number Diff line change
@@ -736,7 +736,7 @@ mod builtin {
#[cfg(dox)]
macro_rules! module_path { () => ({ /* compiler built-in */ }) }

/// Boolean evaluation of configuration flags.
/// Boolean evaluation of configuration flags, at compile-time.
///
/// For more information, see the documentation for [`std::cfg!`].
///
17 changes: 17 additions & 0 deletions src/libcore/option.rs
Original file line number Diff line number Diff line change
@@ -338,6 +338,12 @@ impl<T> Option<T> {

/// Returns the contained value or a default.
///
/// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
/// the result of a function call, it is recommended to use [`unwrap_or_else`],
/// which is lazily evaluated.
///
/// [`unwrap_or_else`]: #method.unwrap_or_else
///
/// # Examples
///
/// ```
@@ -451,11 +457,16 @@ impl<T> Option<T> {
/// Transforms the `Option<T>` into a [`Result<T, E>`], mapping [`Some(v)`] to
/// [`Ok(v)`] and [`None`] to [`Err(err)`].
///
/// Arguments passed to `ok_or` are eagerly evaluated; if you are passing the
/// result of a function call, it is recommended to use [`ok_or_else`], which is
/// lazily evaluated.
///
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
/// [`Ok(v)`]: ../../std/result/enum.Result.html#variant.Ok
/// [`Err(err)`]: ../../std/result/enum.Result.html#variant.Err
/// [`None`]: #variant.None
/// [`Some(v)`]: #variant.Some
/// [`ok_or_else`]: #method.ok_or_else
///
/// # Examples
///
@@ -644,6 +655,12 @@ impl<T> Option<T> {

/// Returns the option if it contains a value, otherwise returns `optb`.
///
/// Arguments passed to `or` are eagerly evaluated; if you are passing the
/// result of a function call, it is recommended to use [`or_else`], which is
/// lazily evaluated.
///
/// [`or_else`]: #method.or_else
///
/// # Examples
///
/// ```
10 changes: 10 additions & 0 deletions src/libcore/result.rs
Original file line number Diff line number Diff line change
@@ -625,8 +625,13 @@ impl<T, E> Result<T, E> {

/// Returns `res` if the result is [`Err`], otherwise returns the [`Ok`] value of `self`.
///
/// Arguments passed to `or` are eagerly evaluated; if you are passing the
/// result of a function call, it is recommended to use [`or_else`], which is
/// lazily evaluated.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// [`or_else`]: #method.or_else
///
/// # Examples
///
@@ -690,8 +695,13 @@ impl<T, E> Result<T, E> {
/// Unwraps a result, yielding the content of an [`Ok`].
/// Else, it returns `optb`.
///
/// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
/// the result of a function call, it is recommended to use [`unwrap_or_else`],
/// which is lazily evaluated.
///
/// [`Ok`]: enum.Result.html#variant.Ok
/// [`Err`]: enum.Result.html#variant.Err
/// [`unwrap_or_else`]: #method.unwrap_or_else
///
/// # Examples
///
1 change: 1 addition & 0 deletions src/librustdoc/html/layout.rs
Original file line number Diff line number Diff line change
@@ -65,6 +65,7 @@ r##"<!DOCTYPE html>
{before_content}
<nav class="sidebar">
<div class="sidebar-menu">&#9776;</div>
{logo}
{sidebar}
</nav>
7 changes: 7 additions & 0 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
@@ -3542,6 +3542,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
let cx = self.cx;
let it = self.item;
let parentlen = cx.current.len() - if it.is_mod() {1} else {0};
let mut should_close = false;

if it.is_struct() || it.is_trait() || it.is_primitive() || it.is_union()
|| it.is_enum() || it.is_mod() || it.is_typedef()
@@ -3575,6 +3576,8 @@ impl<'a> fmt::Display for Sidebar<'a> {
}
}

write!(fmt, "<div class=\"sidebar-elems\">")?;
should_close = true;
match it.inner {
clean::StructItem(ref s) => sidebar_struct(fmt, it, s)?,
clean::TraitItem(ref t) => sidebar_trait(fmt, it, t)?,
@@ -3625,6 +3628,10 @@ impl<'a> fmt::Display for Sidebar<'a> {
write!(fmt, "<script defer src=\"{path}sidebar-items.js\"></script>",
path = relpath)?;
}
if should_close {
// Closes sidebar-elems div.
write!(fmt, "</div>")?;
}

Ok(())
}
44 changes: 43 additions & 1 deletion src/librustdoc/html/static/main.js
Original file line number Diff line number Diff line change
@@ -106,6 +106,30 @@
return (elem.offsetParent === null)
}

function showSidebar() {
var elems = document.getElementsByClassName("sidebar-elems")[0];
if (elems) {
elems.style.display = "block";
}
var sidebar = document.getElementsByClassName('sidebar')[0];
sidebar.style.position = 'fixed';
sidebar.style.width = '100%';
sidebar.style.marginLeft = '0';
document.getElementsByTagName("body")[0].style.marginTop = '45px';
}

function hideSidebar() {
var elems = document.getElementsByClassName("sidebar-elems")[0];
if (elems) {
elems.style.display = "";
}
var sidebar = document.getElementsByClassName('sidebar')[0];
sidebar.style.position = '';
sidebar.style.width = '';
sidebar.style.marginLeft = '';
document.getElementsByTagName("body")[0].style.marginTop = '';
}

// used for special search precedence
var TY_PRIMITIVE = itemTypes.indexOf("primitive");

@@ -130,6 +154,8 @@
}

function highlightSourceLines(ev) {
// If we're in mobile mode, we should add the sidebar in any case.
hideSidebar();
var search = document.getElementById("search");
var i, from, to, match = window.location.hash.match(/^#?(\d+)(?:-(\d+))?$/);
if (match) {
@@ -1459,7 +1485,7 @@

// delayed sidebar rendering.
function initSidebarItems(items) {
var sidebar = document.getElementsByClassName('sidebar')[0];
var sidebar = document.getElementsByClassName('sidebar-elems')[0];
var current = window.sidebarCurrent;

function block(shortty, longty) {
@@ -1829,6 +1855,22 @@
removeClass(search, "hidden");
search.innerHTML = '<h3 style="text-align: center;">Loading search results...</h3>';
}

var sidebar_menu = document.getElementsByClassName("sidebar-menu")[0];
if (sidebar_menu) {
sidebar_menu.onclick = function() {
var sidebar = document.getElementsByClassName('sidebar')[0];
if (sidebar.style.position === "fixed") {
hideSidebar();
} else {
showSidebar();
}
};
}

window.onresize = function() {
hideSidebar();
};
}());

// Sets the focus on the search bar at the top of the page
73 changes: 36 additions & 37 deletions src/librustdoc/html/static/rustdoc.css
Original file line number Diff line number Diff line change
@@ -208,7 +208,7 @@ nav.sub {
.sidebar .version {
font-size: 15px;
text-align: center;
border-bottom: #DDDDDD 1px solid;
border-bottom: 1px solid;
overflow-wrap: break-word;
word-wrap: break-word; /* deprecated */
word-break: break-word; /* Chrome, non-standard */
@@ -247,8 +247,8 @@ nav.sub {
}

.sidebar-title {
border-top: 1px solid #777;
border-bottom: 1px solid #777;
border-top: 1px solid;
border-bottom: 1px solid;
text-align: center;
font-size: 17px;
margin-bottom: 5px;
@@ -263,6 +263,10 @@ nav.sub {
width: 100%;
}

.sidebar-menu {
display: none;
}

.content {
padding: 15px 0;
}
@@ -364,7 +368,6 @@ h4 > code, h3 > code, .invisible > code {
}

.invisible {
background: rgba(0, 0, 0, 0);
width: 100%;
display: inline-block;
}
@@ -444,7 +447,6 @@ h4 > code, h3 > code, .invisible > code {
.content .fn .where,
.content .where.fmt-newline {
display: block;
color: #4E4C4C;
font-size: 0.8em;
}

@@ -538,7 +540,6 @@ a {
}

.search-input:focus {
border-color: #66afe9;
border-radius: 2px;
border: 0;
outline: 0;
@@ -560,7 +561,8 @@ a {
.content .search-results td:first-child a { padding-right: 10px; }

tr.result span.primitive::after {
content: ' (primitive type)'; font-style: italic; color: black;
content: ' (primitive type)';
font-style: italic;
}

body.blur > :not(#help) {
@@ -697,7 +699,6 @@ a.test-arrow:hover{
font-weight: 300;
position: absolute;
left: -23px;
color: #999;
top: 0;
}

@@ -823,7 +824,7 @@ span.since {
position: static;
}

.sidebar .location {
.sidebar > .location {
float: right;
margin: 0px;
margin-top: 2px;
@@ -843,16 +844,33 @@ span.since {
margin-top: 5px;
margin-bottom: 5px;
float: left;
margin-left: 50px;
}

nav.sub {
margin: 0 auto;
.sidebar-menu {
position: absolute;
font-size: 2rem;
cursor: pointer;
margin-top: 2px;
display: block;
}

.sidebar .block {
.sidebar-elems {
background-color: #F1F1F1;
position: fixed;
z-index: 1;
left: 0;
top: 45px;
bottom: 0;
overflow-y: auto;
border-right: 1px solid #000;
display: none;
}

nav.sub {
margin: 0 auto;
}

.content {
margin-left: 0px;
}
@@ -904,8 +922,6 @@ span.since {
.tooltip .tooltiptext {
width: 120px;
display: none;
background-color: black;
color: #fff;
text-align: center;
padding: 5px 3px;
border-radius: 6px;
@@ -927,13 +943,10 @@ span.since {
margin-top: -5px;
border-width: 5px;
border-style: solid;
border-color: transparent black transparent transparent;
}

.important-traits .tooltip .tooltiptext {
background-color: white;
color: black;
border: 1px solid #000;
border: 1px solid;
}

pre.rust {
@@ -953,22 +966,21 @@ pre.rust {
float: left;
width: 33.3%;
text-align: center;
border-bottom: 1px solid #ccc;
border-bottom: 1px solid;
font-size: 18px;
cursor: pointer;
}

#titles > div.selected {
border-bottom: 3px solid #0078ee;
border-bottom: 3px solid;
}

#titles > div:hover {
border-bottom: 3px solid #0089ff;
border-bottom: 3px solid;
}

#titles > div > div.count {
display: inline-block;
color: #888;
font-size: 16px;
}

@@ -987,7 +999,6 @@ h4 > .important-traits {
position: fixed;
width: 100vw;
height: 100vh;
background-color: rgba(0,0,0,0.3);
z-index: 10000;
top: 0;
left: 0;
@@ -997,13 +1008,12 @@ h4 > .important-traits {
display: block;
max-width: 60%;
min-width: 200px;
background-color: #eee;
padding: 8px;
top: 40%;
position: absolute;
left: 50%;
transform: translate(-50%, -40%);
border: 1px solid #999;
border: 1px solid;
border-radius: 4px;
border-top-right-radius: 0;
}
@@ -1030,35 +1040,24 @@ h3.important {
right: -25px;
top: -1px;
font-size: 18px;
background-color: #eee;
width: 25px;
padding-right: 2px;
border-top-right-radius: 5px;
border-bottom-right-radius: 5px;
text-align: center;
border: 1px solid #999;
border: 1px solid;
border-right: 0;
cursor: pointer;
}

.modal-content > .close:hover {
background-color: #ff1f1f;
color: white;
}

.modal-content > .whiter {
height: 25px;
position: absolute;
width: 3px;
background-color: #eee;
right: -2px;
top: 0px;
}

.modal-content > .close:hover + .whiter {
background-color: #ff1f1f;
}

#main > div.important-traits {
position: absolute;
left: -24px;
89 changes: 89 additions & 0 deletions src/librustdoc/html/static/styles/main.css
Original file line number Diff line number Diff line change
@@ -31,6 +31,10 @@ h2, h3:not(.impl):not(.method):not(.type):not(.tymethod), h4:not(.method):not(.t
background-color: white;
}

.invisible {
background: rgba(0, 0, 0, 0);
}

.docblock code, .docblock-short code {
background-color: #F5F5F5;
}
@@ -56,6 +60,15 @@ pre {
color: #333;
}

.sidebar .version {
border-bottom-color: #DDD;
}

.sidebar-title {
border-top-color: #777;
border-bottom-color: #777;
}

.block a:hover {
background: #F5F5F5;
}
@@ -89,6 +102,12 @@ pre {
background: #FDFFD3;
}

.content .method .where,
.content .fn .where,
.content .where.fmt-newline {
color: #4E4C4C;
}

.content .highlighted {
color: #000 !important;
background-color: #ccc;
@@ -152,12 +171,20 @@ a.test-arrow {
color: #f5f5f5;
}

.collapse-toggle {
color: #999;
}

.search-input {
color: #555;
box-shadow: 0 0 0 1px #e0e0e0, 0 0 0 2px transparent;
background-color: white;
}

.search-input:focus {
border-color: #66afe9;
}

.stab.unstable { background: #FFF5D6; border-color: #FFC600; }
.stab.deprecated { background: #F3DFFF; border-color: #7F0087; }
.stab.portability { background: #C4ECFF; border-color: #7BA5DB; }
@@ -176,6 +203,10 @@ a.test-arrow {
color: grey;
}

tr.result span.primitive::after {
color: black;
}

.line-numbers :target { background-color: transparent; }

/* Code highlighting */
@@ -241,3 +272,61 @@ pre.ignore:hover, .information:hover + pre.ignore {
.search-failed > a {
color: #0089ff;
}

.tooltip .tooltiptext {
background-color: black;
color: #fff;
}

.tooltip .tooltiptext::after {
border-color: transparent black transparent transparent;
}

.important-traits .tooltip .tooltiptext {
background-color: white;
color: black;
border-color: black;
}

#titles > div {
border-bottom-color: #ccc;
}

#titles > div.selected {
border-bottom-color: #0078ee;
}

#titles > div:hover {
border-bottom-color: #0089ff;
}

#titles > div > div.count {
color: #888;
}

.modal {
background-color: rgba(0,0,0,0.3);
}

.modal-content {
background-color: #eee;
border-color: #999;
}

.modal-content > .close {
background-color: #eee;
border-color: #999;
}

.modal-content > .close:hover {
background-color: #ff1f1f;
color: white;
}

.modal-content > .whiter {
background-color: #eee;
}

.modal-content > .close:hover + .whiter {
background-color: #ff1f1f;
}
2 changes: 1 addition & 1 deletion src/libstd/macros.rs
Original file line number Diff line number Diff line change
@@ -631,7 +631,7 @@ pub mod builtin {
#[macro_export]
macro_rules! module_path { () => ({ /* compiler built-in */ }) }

/// Boolean evaluation of configuration flags.
/// Boolean evaluation of configuration flags, at compile-time.
///
/// In addition to the `#[cfg]` attribute, this macro is provided to allow
/// boolean expression evaluation of configuration flags. This frequently