Skip to content

Commit 5f4b09e

Browse files
committed
Auto merge of #46574 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 5 pull requests - Successful merges: #46416, #46444, #46526, #46539, #46548 - Failed merges:
2 parents c8ddf28 + 0b47f02 commit 5f4b09e

File tree

10 files changed

+206
-40
lines changed

10 files changed

+206
-40
lines changed

.gitattributes

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@
77
src/etc/installer/gfx/* binary
88
*.woff binary
99
src/vendor/** -text
10+
Cargo.lock -merge

src/libcore/macros.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ mod builtin {
736736
#[cfg(dox)]
737737
macro_rules! module_path { () => ({ /* compiler built-in */ }) }
738738

739-
/// Boolean evaluation of configuration flags.
739+
/// Boolean evaluation of configuration flags, at compile-time.
740740
///
741741
/// For more information, see the documentation for [`std::cfg!`].
742742
///

src/libcore/option.rs

+17
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,12 @@ impl<T> Option<T> {
338338

339339
/// Returns the contained value or a default.
340340
///
341+
/// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
342+
/// the result of a function call, it is recommended to use [`unwrap_or_else`],
343+
/// which is lazily evaluated.
344+
///
345+
/// [`unwrap_or_else`]: #method.unwrap_or_else
346+
///
341347
/// # Examples
342348
///
343349
/// ```
@@ -451,11 +457,16 @@ impl<T> Option<T> {
451457
/// Transforms the `Option<T>` into a [`Result<T, E>`], mapping [`Some(v)`] to
452458
/// [`Ok(v)`] and [`None`] to [`Err(err)`].
453459
///
460+
/// Arguments passed to `ok_or` are eagerly evaluated; if you are passing the
461+
/// result of a function call, it is recommended to use [`ok_or_else`], which is
462+
/// lazily evaluated.
463+
///
454464
/// [`Result<T, E>`]: ../../std/result/enum.Result.html
455465
/// [`Ok(v)`]: ../../std/result/enum.Result.html#variant.Ok
456466
/// [`Err(err)`]: ../../std/result/enum.Result.html#variant.Err
457467
/// [`None`]: #variant.None
458468
/// [`Some(v)`]: #variant.Some
469+
/// [`ok_or_else`]: #method.ok_or_else
459470
///
460471
/// # Examples
461472
///
@@ -644,6 +655,12 @@ impl<T> Option<T> {
644655

645656
/// Returns the option if it contains a value, otherwise returns `optb`.
646657
///
658+
/// Arguments passed to `or` are eagerly evaluated; if you are passing the
659+
/// result of a function call, it is recommended to use [`or_else`], which is
660+
/// lazily evaluated.
661+
///
662+
/// [`or_else`]: #method.or_else
663+
///
647664
/// # Examples
648665
///
649666
/// ```

src/libcore/result.rs

+10
Original file line numberDiff line numberDiff line change
@@ -625,8 +625,13 @@ impl<T, E> Result<T, E> {
625625

626626
/// Returns `res` if the result is [`Err`], otherwise returns the [`Ok`] value of `self`.
627627
///
628+
/// Arguments passed to `or` are eagerly evaluated; if you are passing the
629+
/// result of a function call, it is recommended to use [`or_else`], which is
630+
/// lazily evaluated.
631+
///
628632
/// [`Ok`]: enum.Result.html#variant.Ok
629633
/// [`Err`]: enum.Result.html#variant.Err
634+
/// [`or_else`]: #method.or_else
630635
///
631636
/// # Examples
632637
///
@@ -690,8 +695,13 @@ impl<T, E> Result<T, E> {
690695
/// Unwraps a result, yielding the content of an [`Ok`].
691696
/// Else, it returns `optb`.
692697
///
698+
/// Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing
699+
/// the result of a function call, it is recommended to use [`unwrap_or_else`],
700+
/// which is lazily evaluated.
701+
///
693702
/// [`Ok`]: enum.Result.html#variant.Ok
694703
/// [`Err`]: enum.Result.html#variant.Err
704+
/// [`unwrap_or_else`]: #method.unwrap_or_else
695705
///
696706
/// # Examples
697707
///

src/librustdoc/html/layout.rs

+1
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ r##"<!DOCTYPE html>
6565
{before_content}
6666
6767
<nav class="sidebar">
68+
<div class="sidebar-menu">&#9776;</div>
6869
{logo}
6970
{sidebar}
7071
</nav>

src/librustdoc/html/render.rs

+7
Original file line numberDiff line numberDiff line change
@@ -3542,6 +3542,7 @@ impl<'a> fmt::Display for Sidebar<'a> {
35423542
let cx = self.cx;
35433543
let it = self.item;
35443544
let parentlen = cx.current.len() - if it.is_mod() {1} else {0};
3545+
let mut should_close = false;
35453546

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

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

36293636
Ok(())
36303637
}

src/librustdoc/html/static/main.js

+43-1
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,30 @@
106106
return (elem.offsetParent === null)
107107
}
108108

109+
function showSidebar() {
110+
var elems = document.getElementsByClassName("sidebar-elems")[0];
111+
if (elems) {
112+
elems.style.display = "block";
113+
}
114+
var sidebar = document.getElementsByClassName('sidebar')[0];
115+
sidebar.style.position = 'fixed';
116+
sidebar.style.width = '100%';
117+
sidebar.style.marginLeft = '0';
118+
document.getElementsByTagName("body")[0].style.marginTop = '45px';
119+
}
120+
121+
function hideSidebar() {
122+
var elems = document.getElementsByClassName("sidebar-elems")[0];
123+
if (elems) {
124+
elems.style.display = "";
125+
}
126+
var sidebar = document.getElementsByClassName('sidebar')[0];
127+
sidebar.style.position = '';
128+
sidebar.style.width = '';
129+
sidebar.style.marginLeft = '';
130+
document.getElementsByTagName("body")[0].style.marginTop = '';
131+
}
132+
109133
// used for special search precedence
110134
var TY_PRIMITIVE = itemTypes.indexOf("primitive");
111135

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

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

14601486
// delayed sidebar rendering.
14611487
function initSidebarItems(items) {
1462-
var sidebar = document.getElementsByClassName('sidebar')[0];
1488+
var sidebar = document.getElementsByClassName('sidebar-elems')[0];
14631489
var current = window.sidebarCurrent;
14641490

14651491
function block(shortty, longty) {
@@ -1829,6 +1855,22 @@
18291855
removeClass(search, "hidden");
18301856
search.innerHTML = '<h3 style="text-align: center;">Loading search results...</h3>';
18311857
}
1858+
1859+
var sidebar_menu = document.getElementsByClassName("sidebar-menu")[0];
1860+
if (sidebar_menu) {
1861+
sidebar_menu.onclick = function() {
1862+
var sidebar = document.getElementsByClassName('sidebar')[0];
1863+
if (sidebar.style.position === "fixed") {
1864+
hideSidebar();
1865+
} else {
1866+
showSidebar();
1867+
}
1868+
};
1869+
}
1870+
1871+
window.onresize = function() {
1872+
hideSidebar();
1873+
};
18321874
}());
18331875

18341876
// Sets the focus on the search bar at the top of the page

0 commit comments

Comments
 (0)