From 7e952ec039528bcc11263d87b66216a7567af5f2 Mon Sep 17 00:00:00 2001 From: Ellen Date: Thu, 13 May 2021 11:37:25 +0100 Subject: [PATCH 1/8] completion uwu --- compiler/rustc_feature/src/active.rs | 1 - .../ui/const-generics/defaults/const-param-as-default-value.rs | 1 - .../ui/const-generics/defaults/const-param-in-ty-defaults.rs | 1 - src/test/ui/const-generics/defaults/default-param-wf-concrete.rs | 1 - src/test/ui/const-generics/defaults/pretty-printing-ast.rs | 1 - src/test/ui/const-generics/defaults/pretty-printing-ast.stdout | 1 - src/test/ui/const-generics/defaults/repr-c-issue-82792.rs | 1 - .../const-generics/min_const_generics/default_function_param.rs | 1 - src/test/ui/derives/derive-macro-const-default.rs | 1 - 9 files changed, 9 deletions(-) diff --git a/compiler/rustc_feature/src/active.rs b/compiler/rustc_feature/src/active.rs index 535cb1327664..418270c62159 100644 --- a/compiler/rustc_feature/src/active.rs +++ b/compiler/rustc_feature/src/active.rs @@ -692,7 +692,6 @@ pub fn set(&self, features: &mut Features, span: Span) { sym::repr128, sym::unsized_locals, sym::capture_disjoint_fields, - sym::const_generics_defaults, sym::inherent_associated_types, sym::type_alias_impl_trait, sym::native_link_modifiers, diff --git a/src/test/ui/const-generics/defaults/const-param-as-default-value.rs b/src/test/ui/const-generics/defaults/const-param-as-default-value.rs index 59ac261f44fd..9779835d3150 100644 --- a/src/test/ui/const-generics/defaults/const-param-as-default-value.rs +++ b/src/test/ui/const-generics/defaults/const-param-as-default-value.rs @@ -1,6 +1,5 @@ // run-pass #![feature(const_generics_defaults)] -#![allow(incomplete_features)] struct Foo([u8; N], [u8; M]); fn foo() -> Foo { diff --git a/src/test/ui/const-generics/defaults/const-param-in-ty-defaults.rs b/src/test/ui/const-generics/defaults/const-param-in-ty-defaults.rs index 3f534ca0308b..dbcab77dcd2e 100644 --- a/src/test/ui/const-generics/defaults/const-param-in-ty-defaults.rs +++ b/src/test/ui/const-generics/defaults/const-param-in-ty-defaults.rs @@ -1,6 +1,5 @@ // run-pass #![feature(const_generics_defaults)] -#![allow(incomplete_features)] struct Foo(T); impl Foo { diff --git a/src/test/ui/const-generics/defaults/default-param-wf-concrete.rs b/src/test/ui/const-generics/defaults/default-param-wf-concrete.rs index 4bb56c6a1c08..d4271adefd12 100644 --- a/src/test/ui/const-generics/defaults/default-param-wf-concrete.rs +++ b/src/test/ui/const-generics/defaults/default-param-wf-concrete.rs @@ -1,5 +1,4 @@ #![feature(const_generics_defaults)] -#![allow(incomplete_features)] struct Foo; //~^ ERROR evaluation of constant value failed fn main() {} diff --git a/src/test/ui/const-generics/defaults/pretty-printing-ast.rs b/src/test/ui/const-generics/defaults/pretty-printing-ast.rs index 7a57950dfc92..0487668cd2a7 100644 --- a/src/test/ui/const-generics/defaults/pretty-printing-ast.rs +++ b/src/test/ui/const-generics/defaults/pretty-printing-ast.rs @@ -4,7 +4,6 @@ #![crate_type = "lib"] #![feature(const_generics_defaults)] -#![allow(incomplete_features)] trait Foo {} diff --git a/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout b/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout index f549993c413d..1bceb8cbb94d 100644 --- a/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout +++ b/src/test/ui/const-generics/defaults/pretty-printing-ast.stdout @@ -6,7 +6,6 @@ #![crate_type = "lib"] #![feature(const_generics_defaults)] -#![allow(incomplete_features)] #[prelude_import] use ::std::prelude::rust_2015::*; #[macro_use] diff --git a/src/test/ui/const-generics/defaults/repr-c-issue-82792.rs b/src/test/ui/const-generics/defaults/repr-c-issue-82792.rs index c64c2974c8f8..ca29ee942064 100644 --- a/src/test/ui/const-generics/defaults/repr-c-issue-82792.rs +++ b/src/test/ui/const-generics/defaults/repr-c-issue-82792.rs @@ -3,7 +3,6 @@ // run-pass #![feature(const_generics_defaults)] -#![allow(incomplete_features)] #[repr(C)] pub struct Loaf { diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.rs b/src/test/ui/const-generics/min_const_generics/default_function_param.rs index ebdb5a65bc35..b47dd2f618cd 100644 --- a/src/test/ui/const-generics/min_const_generics/default_function_param.rs +++ b/src/test/ui/const-generics/min_const_generics/default_function_param.rs @@ -1,6 +1,5 @@ #![crate_type = "lib"] #![feature(const_generics_defaults)] -#![allow(incomplete_features)] fn foo() {} //~^ ERROR defaults for const parameters are diff --git a/src/test/ui/derives/derive-macro-const-default.rs b/src/test/ui/derives/derive-macro-const-default.rs index a844f2d20237..7c4ebca87467 100644 --- a/src/test/ui/derives/derive-macro-const-default.rs +++ b/src/test/ui/derives/derive-macro-const-default.rs @@ -1,5 +1,4 @@ // check-pass -#![allow(incomplete_features)] #![feature(const_generics_defaults)] #[derive(Clone, PartialEq, Debug)] From aec611c08d4b0d51a0d294b8ac39cc0a6c345ca6 Mon Sep 17 00:00:00 2001 From: Ellen Date: Thu, 13 May 2021 14:00:04 +0100 Subject: [PATCH 2/8] wow --- .../ui/const-generics/defaults/default-param-wf-concrete.stderr | 2 +- .../min_const_generics/default_function_param.stderr | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/ui/const-generics/defaults/default-param-wf-concrete.stderr b/src/test/ui/const-generics/defaults/default-param-wf-concrete.stderr index 8464ea98bf69..6fca9d31c0a9 100644 --- a/src/test/ui/const-generics/defaults/default-param-wf-concrete.stderr +++ b/src/test/ui/const-generics/defaults/default-param-wf-concrete.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/default-param-wf-concrete.rs:3:28 + --> $DIR/default-param-wf-concrete.rs:2:28 | LL | struct Foo; | ^^^^^^^ attempt to compute `u8::MAX + 1_u8`, which would overflow diff --git a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr index 243ac0db5f55..11df8621faa2 100644 --- a/src/test/ui/const-generics/min_const_generics/default_function_param.stderr +++ b/src/test/ui/const-generics/min_const_generics/default_function_param.stderr @@ -1,5 +1,5 @@ error: defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/default_function_param.rs:5:14 + --> $DIR/default_function_param.rs:4:14 | LL | fn foo() {} | ^^^^ From b615c0c85469c94041a5e68b9d8b68dcf799f9f1 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Sun, 9 May 2021 12:56:21 -0700 Subject: [PATCH 3/8] rustdoc: use focus for search navigation Rather than keeping track of highlighted element inside the JS, take advantage of `.focus()` and the :focus CSS pseudo-class. This required wrapping each row of results in one big tag (because anchors can be focused, but table rows cannot). That in turn required moving from a table layout to a div layout with float. This makes it so Ctrl+Enter opens links in new tabs, and using the arrow keys to navigate off the bottom of the page scrolls the rest of the page into view. It also simplifies the keyboard event handling. It eliminates the need for click handlers on the search results, and for tracking mouse movements. This changes the UI treatment of mouse hovering. A hovered element now gets a light grey background, but does not change the focused element. It's possible to have two highlighted search results: one that is focused (via keyboard) and one that is hovered (via mouse). Pressing enter will activate the focused link; clicking will activate the hovered link. This matches up with how Firefox and Chrome handle suggestions in their URL bar, and avoids stray mouse movements changing the focus. Selecting tabs is now done with left/right arrows while any search result is focused. The visibility of results on each search tab is controlled with the "active" class, rather than by setting display: none directly. Note that the old code kept track of highlighted search element when tabbing back and forth. The new code doesn't. --- src/librustdoc/html/static/main.js | 9 +- src/librustdoc/html/static/rustdoc.css | 32 ++-- src/librustdoc/html/static/search.js | 186 ++++++++------------ src/librustdoc/html/static/themes/ayu.css | 50 ++++-- src/librustdoc/html/static/themes/dark.css | 50 +++--- src/librustdoc/html/static/themes/light.css | 46 ++--- 6 files changed, 178 insertions(+), 195 deletions(-) diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js index ebc9ada4451e..fcb06bc796ee 100644 --- a/src/librustdoc/html/static/main.js +++ b/src/librustdoc/html/static/main.js @@ -170,7 +170,8 @@ function hideThemeButtonState() { // 1 for "In Parameters" // 2 for "In Return Types" currentTab: 0, - mouseMovedAfterSearch: true, + // tab and back preserves the element that was focused. + focusedByTab: [null, null, null], clearInputTimeout: function() { if (searchState.timeout !== null) { clearTimeout(searchState.timeout); @@ -262,10 +263,6 @@ function hideThemeButtonState() { search_input.placeholder = searchState.input.origPlaceholder; }); - document.addEventListener("mousemove", function() { - searchState.mouseMovedAfterSearch = true; - }); - search_input.removeAttribute('disabled'); // `crates{version}.js` should always be loaded before this script, so we can use it @@ -1070,7 +1067,7 @@ function hideThemeButtonState() { ["T", "Focus the theme picker menu"], ["↑", "Move up in search results"], ["↓", "Move down in search results"], - ["ctrl + ↑ / ↓", "Switch result tab"], + ["← / →", "Switch result tab (when results focused)"], ["⏎", "Go to active search result"], ["+", "Expand all sections"], ["-", "Collapse all sections"], diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index 1b7eff4604f5..b03e657dce0f 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -144,7 +144,7 @@ h4.type.trait-impl, h4.associatedconstant.trait-impl, h4.associatedtype.trait-im } h1, h2, h3, h4, -.sidebar, a.source, .search-input, .content table td:first-child > a, +.sidebar, a.source, .search-input, .search-results .result-name, div.item-list .out-of-band, #source-sidebar, #sidebar-toggle, details.rustdoc-toggle > summary::before, @@ -748,6 +748,15 @@ a { outline: 0; } +.search-results { + display: none; + padding-bottom: 2em; +} + +.search-results.active { + display: block; +} + .search-results .desc { white-space: nowrap; text-overflow: ellipsis; @@ -756,22 +765,14 @@ a { } .search-results a { + /* A little margin ensures the browser's outlining of focused links has room to display. */ + margin-left: 2px; + margin-right: 2px; display: block; } -.content .search-results td:first-child { - padding-right: 0; +.result-name { width: 50%; -} -.content .search-results td:first-child a { - padding-right: 10px; -} -.content .search-results td:first-child a:after { - clear: both; - content: ""; - display: block; -} -.content .search-results td:first-child a span { float: left; } @@ -1134,6 +1135,11 @@ pre.rust { .search-failed { text-align: center; margin-top: 20px; + display: none; +} + +.search-failed.active { + display: block; } .search-failed > ul { diff --git a/src/librustdoc/html/static/search.js b/src/librustdoc/html/static/search.js index a09d3eb1796b..4de24d732837 100644 --- a/src/librustdoc/html/static/search.js +++ b/src/librustdoc/html/static/search.js @@ -48,9 +48,9 @@ function printTab(nb) { }); onEachLazy(document.getElementById("results").childNodes, function(elem) { if (nb === 0) { - elem.style.display = ""; + addClass(elem, "active"); } else { - elem.style.display = "none"; + removeClass(elem, "active"); } nb -= 1; }); @@ -875,106 +875,22 @@ window.initSearch = function(rawSearchIndex) { }; } - function initSearchNav() { - var hoverTimeout; + function nextTab(direction) { + var next = (searchState.currentTab + direction + 3) % searchState.focusedByTab.length; + searchState.focusedByTab[searchState.currentTab] = document.activeElement; + printTab(next); + focusSearchResult(); + } - var click_func = function(e) { - var el = e.target; - // to retrieve the real "owner" of the event. - while (el.tagName !== "TR") { - el = el.parentNode; - } - var dst = e.target.getElementsByTagName("a"); - if (dst.length < 1) { - return; - } - dst = dst[0]; - if (window.location.pathname === dst.pathname) { - searchState.hideResults(); - document.location.href = dst.href; - } - }; - var mouseover_func = function(e) { - if (searchState.mouseMovedAfterSearch) { - var el = e.target; - // to retrieve the real "owner" of the event. - while (el.tagName !== "TR") { - el = el.parentNode; - } - clearTimeout(hoverTimeout); - hoverTimeout = setTimeout(function() { - onEachLazy(document.getElementsByClassName("search-results"), function(e) { - onEachLazy(e.getElementsByClassName("result"), function(i_e) { - removeClass(i_e, "highlighted"); - }); - }); - addClass(el, "highlighted"); - }, 20); - } - }; - onEachLazy(document.getElementsByClassName("search-results"), function(e) { - onEachLazy(e.getElementsByClassName("result"), function(i_e) { - i_e.onclick = click_func; - i_e.onmouseover = mouseover_func; - }); - }); - - searchState.input.onkeydown = function(e) { - // "actives" references the currently highlighted item in each search tab. - // Each array in "actives" represents a tab. - var actives = [[], [], []]; - // "current" is used to know which tab we're looking into. - var current = 0; - onEachLazy(document.getElementById("results").childNodes, function(e) { - onEachLazy(e.getElementsByClassName("highlighted"), function(h_e) { - actives[current].push(h_e); - }); - current += 1; - }); - var SHIFT = 16; - var CTRL = 17; - var ALT = 18; - - var currentTab = searchState.currentTab; - if (e.which === 38) { // up - if (e.ctrlKey) { // Going through result tabs. - printTab(currentTab > 0 ? currentTab - 1 : 2); - } else { - if (!actives[currentTab].length || - !actives[currentTab][0].previousElementSibling) { - return; - } - addClass(actives[currentTab][0].previousElementSibling, "highlighted"); - removeClass(actives[currentTab][0], "highlighted"); - } - e.preventDefault(); - } else if (e.which === 40) { // down - if (e.ctrlKey) { // Going through result tabs. - printTab(currentTab > 1 ? 0 : currentTab + 1); - } else if (!actives[currentTab].length) { - var results = document.getElementById("results").childNodes; - if (results.length > 0) { - var res = results[currentTab].getElementsByClassName("result"); - if (res.length > 0) { - addClass(res[0], "highlighted"); - } - } - } else if (actives[currentTab][0].nextElementSibling) { - addClass(actives[currentTab][0].nextElementSibling, "highlighted"); - removeClass(actives[currentTab][0], "highlighted"); - } - e.preventDefault(); - } else if (e.which === 13) { // return - if (actives[currentTab].length) { - var elem = actives[currentTab][0].getElementsByTagName("a")[0]; - document.location.href = elem.href; - } - } else if ([SHIFT, CTRL, ALT].indexOf(e.which) !== -1) { - // Does nothing, it's just to avoid losing "focus" on the highlighted element. - } else if (actives[currentTab].length > 0) { - removeClass(actives[currentTab][0], "highlighted"); - } - }; + // focus the first search result on the active tab, or the result that + // was focused last time this tab was active. + function focusSearchResult() { + var target = searchState.focusedByTab[searchState.currentTab] || + document.querySelectorAll(".search-results.active a").item(0) || + document.querySelectorAll("#titles > button").item(searchState.currentTab); + if (target) { + target.focus(); + } } function buildHrefAndPath(item) { @@ -1044,16 +960,16 @@ window.initSearch = function(rawSearchIndex) { } function addTab(array, query, display) { - var extraStyle = ""; - if (display === false) { - extraStyle = " style=\"display: none;\""; + var extraClass = ""; + if (display === true) { + extraClass = " active"; } var output = ""; var duplicates = {}; var length = 0; if (array.length > 0) { - output = ""; + output = "
"; array.forEach(function(item) { var name, type; @@ -1069,20 +985,19 @@ window.initSearch = function(rawSearchIndex) { } length += 1; - output += "
"; + " "; }); - output += "
" + - "" + + output += "" + + "" + - "" + + name + "
"; + output += ""; } else { - output = "
No results :(
" + + output = "
No results :(
" + "Try on
DuckDuckGo?

" + @@ -1118,7 +1033,7 @@ window.initSearch = function(rawSearchIndex) { { var elem = document.createElement("a"); elem.href = results.others[0].href; - elem.style.display = "none"; + removeClass(elem, "active"); // For firefox, we need the element to be in the DOM so it can be clicked. document.body.appendChild(elem); elem.click(); @@ -1159,7 +1074,6 @@ window.initSearch = function(rawSearchIndex) { search.innerHTML = output; searchState.showResults(search); - initSearchNav(); var elems = document.getElementById("titles").childNodes; elems[0].onclick = function() { printTab(0); }; elems[1].onclick = function() { printTab(1); }; @@ -1437,6 +1351,50 @@ window.initSearch = function(rawSearchIndex) { }; searchState.input.onpaste = searchState.input.onchange; + searchState.outputElement().addEventListener("keydown", function(e) { + // We only handle unmodified keystrokes here. We don't want to interfere with, + // for instance, alt-left and alt-right for history navigation. + if (e.altKey || e.ctrlKey || e.shiftKey || e.metaKey) { + return; + } + // up and down arrow select next/previous search result, or the + // search box if we're already at the top. + if (e.which === 38) { // up + var previous = document.activeElement.previousElementSibling; + if (previous) { + console.log("previousElementSibling", previous); + previous.focus(); + } else { + searchState.focus(); + } + e.preventDefault(); + } else if (e.which === 40) { // down + var next = document.activeElement.nextElementSibling; + if (next) { + next.focus(); + } + var rect = document.activeElement.getBoundingClientRect(); + if (window.innerHeight - rect.bottom < rect.height) { + window.scrollBy(0, rect.height); + } + e.preventDefault(); + } else if (e.which === 37) { // left + nextTab(-1); + e.preventDefault(); + } else if (e.which === 39) { // right + nextTab(1); + e.preventDefault(); + } + }); + + searchState.input.addEventListener("keydown", function(e) { + if (e.which === 40) { // down + focusSearchResult(); + e.preventDefault(); + } + }); + + var selectCrate = document.getElementById("crate-search"); if (selectCrate) { selectCrate.onchange = function() { diff --git a/src/librustdoc/html/static/themes/ayu.css b/src/librustdoc/html/static/themes/ayu.css index 13d1a475e4b2..cf3b4b4b9361 100644 --- a/src/librustdoc/html/static/themes/ayu.css +++ b/src/librustdoc/html/static/themes/ayu.css @@ -151,13 +151,16 @@ pre, .rustdoc.source .example-wrap { color: #c5c5c5; } -.content .highlighted { +.content a:hover { + background-color: #777; +} + +.content a:focus { color: #000 !important; background-color: #c6afb3; } -.content .highlighted a, .content .highlighted span { color: #000 !important; } -.content .highlighted { - background-color: #c6afb3; +.content a:focus { + color: #000 !important; } .search-results a { color: #0096cf; @@ -432,31 +435,21 @@ individually rather than as a group) */ /* FIXME: these rules should be at the bottom of the file but currently must be above the `@media (max-width: 700px)` rules due to a bug in the css checker */ /* see https://github.com/rust-lang/rust/pull/71237#issuecomment-618170143 */ -.content .highlighted.mod, .content .highlighted.externcrate {} .search-input:focus {} .content span.attr,.content a.attr,.block a.current.attr,.content span.derive,.content a.derive, .block a.current.derive,.content span.macro,.content a.macro,.block a.current.macro {} -.content .highlighted.trait {} .content span.struct,.content a.struct,.block a.current.struct {} #titles>button:hover,#titles>button.selected {} -.content .highlighted.traitalias {} .content span.type,.content a.type,.block a.current.type {} .content span.union,.content a.union,.block a.current.union {} -.content .highlighted.foreigntype {} pre.rust .lifetime {} -.content .highlighted.primitive {} -.content .highlighted.constant,.content .highlighted.static {} .stab.unstable {} -.content .highlighted.fn,.content .highlighted.method,.content .highlighted.tymethod {} h2,h3:not(.impl):not(.method):not(.type):not(.tymethod),h4:not(.method):not(.type):not(.tymethod) {} .content span.enum,.content a.enum,.block a.current.enum {} .content span.constant,.content a.constant,.block a.current.constant,.content span.static, -.content a.static,.block a.current.static {} +.content a.static, .block a.current.static {} .content span.keyword,.content a.keyword,.block a.current.keyword {} pre.rust .comment {} -.content .highlighted.enum {} -.content .highlighted.struct {} -.content .highlighted.keyword {} .content span.traitalias,.content a.traitalias,.block a.current.traitalias {} .content span.fn,.content a.fn,.block a.current.fn,.content span.method,.content a.method, .block a.current.method,.content span.tymethod,.content a.tymethod,.block a.current.tymethod, @@ -467,15 +460,36 @@ pre.rust .attribute .ident {} .content span.foreigntype,.content a.foreigntype,.block a.current.foreigntype {} pre.rust .doccomment {} .stab.deprecated {} -.content .highlighted.attr,.content .highlighted.derive,.content .highlighted.macro {} +.content a.attr,.content a.derive,.content a.macro {} .stab.portability {} -.content .highlighted.union {} .content span.primitive,.content a.primitive,.block a.current.primitive {} .content span.externcrate,.content span.mod,.content a.mod,.block a.current.mod {} -.content .highlighted.type {} pre.rust .kw-2,pre.rust .prelude-ty {} .content span.trait,.content a.trait,.block a.current.trait {} +.search-results a:focus span {} +a.result-trait:focus {} +a.result-traitalias:focus {} +a.result-mod:focus, +a.result-externcrate:focus {} +a.result-mod:focus {} +a.result-externcrate:focus {} +a.result-enum:focus {} +a.result-struct:focus {} +a.result-union:focus {} +a.result-fn:focus, +a.result-method:focus, +a.result-tymethod:focus {} +a.result-type:focus {} +a.result-foreigntype:focus {} +a.result-attr:focus, +a.result-derive:focus, +a.result-macro:focus {} +a.result-constant:focus, +a.result-static:focus {} +a.result-primitive:focus {} +a.result-keyword:focus {} + @media (max-width: 700px) { .sidebar-menu { background-color: #14191f; diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 945ca9b252e5..f66f9bbbc893 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -109,32 +109,36 @@ pre, .rustdoc.source .example-wrap { color: #ddd; } -.content .highlighted { +.content a:hover { + background-color: #777; +} + +.content a:focus { color: #eee !important; background-color: #616161; } -.content .highlighted a, .content .highlighted span { color: #eee !important; } -.content .highlighted.trait { background-color: #013191; } -.content .highlighted.traitalias { background-color: #013191; } -.content .highlighted.mod, -.content .highlighted.externcrate { background-color: #afc6e4; } -.content .highlighted.mod { background-color: #803a1b; } -.content .highlighted.externcrate { background-color: #396bac; } -.content .highlighted.enum { background-color: #5b4e68; } -.content .highlighted.struct { background-color: #194e9f; } -.content .highlighted.union { background-color: #b7bd49; } -.content .highlighted.fn, -.content .highlighted.method, -.content .highlighted.tymethod { background-color: #4950ed; } -.content .highlighted.type { background-color: #38902c; } -.content .highlighted.foreigntype { background-color: #b200d6; } -.content .highlighted.attr, -.content .highlighted.derive, -.content .highlighted.macro { background-color: #217d1c; } -.content .highlighted.constant, -.content .highlighted.static { background-color: #0063cc; } -.content .highlighted.primitive { background-color: #00708a; } -.content .highlighted.keyword { background-color: #884719; } +.search-results a:focus span { color: #eee !important; } +a.result-trait:focus { background-color: #013191; } +a.result-traitalias:focus { background-color: #013191; } +a.result-mod:focus, +a.result-externcrate:focus { background-color: #afc6e4; } +a.result-mod:focus { background-color: #803a1b; } +a.result-externcrate:focus { background-color: #396bac; } +a.result-enum:focus { background-color: #5b4e68; } +a.result-struct:focus { background-color: #194e9f; } +a.result-union:focus { background-color: #b7bd49; } +a.result-fn:focus, +a.result-method:focus, +a.result-tymethod:focus { background-color: #4950ed; } +a.result-type:focus { background-color: #38902c; } +a.result-foreigntype:focus { background-color: #b200d6; } +a.result-attr:focus, +a.result-derive:focus, +a.result-macro:focus { background-color: #217d1c; } +a.result-constant:focus, +a.result-static:focus { background-color: #0063cc; } +a.result-primitive:focus { background-color: #00708a; } +a.result-keyword:focus { background-color: #884719; } .content .item-info::before { color: #ccc; } diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index 2ed638bdd4fa..872160863b29 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -109,30 +109,34 @@ pre, .rustdoc.source .example-wrap { color: #4E4C4C; } -.content .highlighted { +.content a:hover { + background-color: #ddd; +} + +.content a:focus { color: #000 !important; background-color: #ccc; } -.content .highlighted a, .content .highlighted span { color: #000 !important; } -.content .highlighted.trait { background-color: #c7b6ff; } -.content .highlighted.traitalias { background-color: #c7b6ff; } -.content .highlighted.mod, -.content .highlighted.externcrate { background-color: #afc6e4; } -.content .highlighted.enum { background-color: #b4d1b9; } -.content .highlighted.struct { background-color: #e7b1a0; } -.content .highlighted.union { background-color: #b7bd49; } -.content .highlighted.fn, -.content .highlighted.method, -.content .highlighted.tymethod { background-color: #c6afb3; } -.content .highlighted.type { background-color: #ffc891; } -.content .highlighted.foreigntype { background-color: #f5c4ff; } -.content .highlighted.attr, -.content .highlighted.derive, -.content .highlighted.macro { background-color: #8ce488; } -.content .highlighted.constant, -.content .highlighted.static { background-color: #c3e0ff; } -.content .highlighted.primitive { background-color: #9aecff; } -.content .highlighted.keyword { background-color: #f99650; } +.search-results a:focus span { color: #000 !important; } +a.result-trait:focus { background-color: #c7b6ff; } +a.result-traitalias:focus { background-color: #c7b6ff; } +a.result-mod:focus, +a.result-externcrate:focus { background-color: #afc6e4; } +a.result-enum:focus { background-color: #b4d1b9; } +a.result-struct:focus { background-color: #e7b1a0; } +a.result-union:focus { background-color: #b7bd49; } +a.result-fn:focus, +a.result-method:focus, +a.result-tymethod:focus { background-color: #c6afb3; } +a.result-type:focus { background-color: #ffc891; } +a.result-foreigntype:focus { background-color: #f5c4ff; } +a.result-attr:focus, +a.result-derive:focus, +a.result-macro:focus { background-color: #8ce488; } +a.result-constant:focus, +a.result-static:focus { background-color: #c3e0ff; } +a.result-primitive:focus { background-color: #9aecff; } +a.result-keyword:focus { background-color: #f99650; } .content .item-info::before { color: #ccc; } From 6bcfdd99131988a899ad97602d3b618bd9fc1a33 Mon Sep 17 00:00:00 2001 From: Pietro Albini Date: Mon, 17 May 2021 12:03:49 +0200 Subject: [PATCH 4/8] backport 1.52.1 release notes --- RELEASES.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 92312d8d556e..60b3359c1b68 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,24 @@ +Version 1.52.1 (2021-05-10) +============================ + +This release disables incremental compilation, unless the user has explicitly +opted in via the newly added RUSTC_FORCE_INCREMENTAL=1 environment variable. + +This is due to the widespread, and frequently occuring, breakage encountered by +Rust users due to newly enabled incremental verification in 1.52.0. Notably, +Rust users **should** upgrade to 1.52.0 or 1.52.1: the bugs that are detected by +newly added incremental verification are still present in past stable versions, +and are not yet fixed on any channel. These bugs can lead to miscompilation of +Rust binaries. + +These problems only affect incremental builds, so release builds with Cargo +should not be affected unless the user has explicitly opted into incremental. +Debug and check builds are affected. + +See [84970] for more details. + +[84970]: https://github.com/rust-lang/rust/issues/84970 + Version 1.52.0 (2021-05-06) ============================ From 28c9c04325819662219340b21be55daf1d22ae4d Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 17 May 2021 22:07:30 -0400 Subject: [PATCH 5/8] Don't require cmake on Windows when LLVM isn't being built Previously, setting `download-ci-llvm = true` when cmake wasn't installed would give the following error: ``` failed to execute command: "cmake" "--help" error: The system cannot find the file specified. (os error 2) ``` --- src/bootstrap/sanity.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bootstrap/sanity.rs b/src/bootstrap/sanity.rs index ed0cbdf97b09..a28762ac485e 100644 --- a/src/bootstrap/sanity.rs +++ b/src/bootstrap/sanity.rs @@ -93,7 +93,8 @@ pub fn check(build: &mut Build) { .unwrap_or(true) }) .any(|build_llvm_ourselves| build_llvm_ourselves); - if building_llvm || build.config.any_sanitizers_enabled() { + let need_cmake = building_llvm || build.config.any_sanitizers_enabled(); + if need_cmake { cmd_finder.must_have("cmake"); } @@ -204,7 +205,7 @@ pub fn check(build: &mut Build) { } } - if target.contains("msvc") { + if need_cmake && target.contains("msvc") { // There are three builds of cmake on windows: MSVC, MinGW, and // Cygwin. The Cygwin build does not have generators for Visual // Studio, so detect that here and error. From 4c12a5dc6c99a234e2e9c0313f6b73c8fa162a11 Mon Sep 17 00:00:00 2001 From: Lee Bradley Date: Tue, 18 May 2021 00:33:17 -0500 Subject: [PATCH 6/8] Add x.py pre-setup instructions This change adds pre-setup instructions that outline how x.py requires python to be setup and how to work around the problem of x.py failing to locate python, especially now that Ubuntu 20.04's dropped default python command is causing people to encounter this issue regularly. See also: #71818 --- README.md | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5ec94e189f83..af6a4090a27c 100644 --- a/README.md +++ b/README.md @@ -19,8 +19,28 @@ Read ["Installation"] from [The Book]. ## Installing from Source The Rust build system uses a Python script called `x.py` to build the compiler, -which manages the bootstrapping process. More information about it can be found -by running `./x.py --help` or reading the [rustc dev guide][rustcguidebuild]. +which manages the bootstrapping process. It lives in the root of the project. + +The `x.py` command can be run directly on most systems in the following format: + +```sh +./x.py [flags] +``` + +This is how the documentation and examples assume you are running `x.py`. + +Systems such as Ubuntu 20.04 LTS do not create the necessary `python` command by default when Python is installed that allows `x.py` to be run directly. In that case you can either create a symlink for `python` (Ubuntu provides the `python-is-python3` package for this), or run `x.py` using Python itself: + +```sh +# Python 3 +python3 x.py [flags] + +# Python 2.7 +python2.7 x.py [flags] +``` + +More information about `x.py` can be found +by running it with the `--help` flag or reading the [rustc dev guide][rustcguidebuild]. [gettingstarted]: https://rustc-dev-guide.rust-lang.org/getting-started.html [rustcguidebuild]: https://rustc-dev-guide.rust-lang.org/building/how-to-build-and-run.html From 5d004c1e2020eaa9bc336f09b6b0475c0eef4d78 Mon Sep 17 00:00:00 2001 From: Guillaume Gomez Date: Mon, 17 May 2021 13:26:58 +0200 Subject: [PATCH 7/8] Improve display for "copy-path" button, making it more discrete --- src/librustdoc/html/static/rustdoc.css | 5 ++--- src/librustdoc/html/static/themes/ayu.css | 17 +++++++++++++---- src/librustdoc/html/static/themes/dark.css | 15 ++++++++++++--- src/librustdoc/html/static/themes/light.css | 15 ++++++++++++--- 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css index e2e1aefa4a84..f11ca52dab17 100644 --- a/src/librustdoc/html/static/rustdoc.css +++ b/src/librustdoc/html/static/rustdoc.css @@ -1262,12 +1262,11 @@ h4 > .notable-traits { } #copy-path { + background: initial; margin-left: 10px; padding: 0; padding-left: 2px; -} -#copy-path> img { - margin-bottom: 2px; + border: 0; } #theme-choices { diff --git a/src/librustdoc/html/static/themes/ayu.css b/src/librustdoc/html/static/themes/ayu.css index 13d1a475e4b2..6651260c28f5 100644 --- a/src/librustdoc/html/static/themes/ayu.css +++ b/src/librustdoc/html/static/themes/ayu.css @@ -502,20 +502,29 @@ kbd { box-shadow-color: #c6cbd1; } -#theme-picker, #settings-menu, #help-button, #copy-path { +#theme-picker, #settings-menu, #help-button { border-color: #5c6773; background-color: #0f1419; color: #fff; } -#theme-picker > img, #settings-menu > img, #copy-path > img { +#theme-picker > img, #settings-menu > img { filter: invert(100); } +#copy-path { + color: #fff; +} +#copy-path > img { + filter: invert(70%); +} +#copy-path:hover > img { + filter: invert(100%); +} + #theme-picker:hover, #theme-picker:focus, #settings-menu:hover, #settings-menu:focus, -#help-button:hover, #help-button:focus, -#copy-path:hover, #copy-path:focus { +#help-button:hover, #help-button:focus { border-color: #e0e0e0; } diff --git a/src/librustdoc/html/static/themes/dark.css b/src/librustdoc/html/static/themes/dark.css index 945ca9b252e5..548306d99eb0 100644 --- a/src/librustdoc/html/static/themes/dark.css +++ b/src/librustdoc/html/static/themes/dark.css @@ -392,7 +392,7 @@ kbd { box-shadow-color: #c6cbd1; } -#theme-picker, #settings-menu, #help-button, #copy-path { +#theme-picker, #settings-menu, #help-button { border-color: #e0e0e0; background: #f0f0f0; color: #000; @@ -400,11 +400,20 @@ kbd { #theme-picker:hover, #theme-picker:focus, #settings-menu:hover, #settings-menu:focus, -#help-button:hover, #help-button:focus, -#copy-path:hover, #copy-path:focus { +#help-button:hover, #help-button:focus { border-color: #ffb900; } +#copy-path { + color: #999; +} +#copy-path > img { + filter: invert(50%); +} +#copy-path:hover > img { + filter: invert(65%); +} + #theme-choices { border-color: #e0e0e0; background-color: #353535; diff --git a/src/librustdoc/html/static/themes/light.css b/src/librustdoc/html/static/themes/light.css index 2ed638bdd4fa..76e880256fd3 100644 --- a/src/librustdoc/html/static/themes/light.css +++ b/src/librustdoc/html/static/themes/light.css @@ -384,18 +384,27 @@ kbd { box-shadow-color: #c6cbd1; } -#theme-picker, #settings-menu, #help-button, #copy-path { +#theme-picker, #settings-menu, #help-button { border-color: #e0e0e0; background-color: #fff; } #theme-picker:hover, #theme-picker:focus, #settings-menu:hover, #settings-menu:focus, -#help-button:hover, #help-button:focus, -#copy-path:hover, #copy-path:focus { +#help-button:hover, #help-button:focus { border-color: #717171; } +#copy-path { + color: #999; +} +#copy-path > img { + filter: invert(50%); +} +#copy-path:hover > img { + filter: invert(35%); +} + #theme-choices { border-color: #ccc; background-color: #fff; From d13745d99b60633a667989d2868ddb18a5567284 Mon Sep 17 00:00:00 2001 From: Jorge Ferreira Date: Tue, 18 May 2021 17:05:40 +0100 Subject: [PATCH 8/8] fix typo --- library/std/src/io/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/std/src/io/mod.rs b/library/std/src/io/mod.rs index 9f43379aff78..e18402f8dec1 100644 --- a/library/std/src/io/mod.rs +++ b/library/std/src/io/mod.rs @@ -1663,7 +1663,7 @@ pub trait Seek { /// /// # Errors /// - /// Seeking can fail, for example becaue it might involve flushing a buffer. + /// Seeking can fail, for example because it might involve flushing a buffer. /// /// Seeking to a negative offset is considered an error. #[stable(feature = "rust1", since = "1.0.0")] @@ -1675,7 +1675,7 @@ pub trait Seek { /// /// # Errors /// - /// Rewinding can fail, for example becaue it might involve flushing a buffer. + /// Rewinding can fail, for example because it might involve flushing a buffer. /// /// # Example ///