Skip to content

Rollup of 5 pull requests #98925

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 65 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
b96d1e4
change ptr::swap methods to do untyped copies
RalfJung Jun 3, 2022
cb7cd97
promise that ptr::copy and ptr::swap are doing untyped copies
RalfJung Jun 3, 2022
7d2eba6
middle: translation in `LintDiagnosticBuilder`
davidtwco Jun 27, 2022
0f4c4c5
lint: port array-into-iter diagnostics
davidtwco Jun 27, 2022
2a69640
lint: port enum intrinsics diagnostics
davidtwco Jun 27, 2022
a0624eb
lint: port expectation diagnostics
davidtwco Jun 27, 2022
fd57269
lint: port hidden unicode codepoints diagnostics
davidtwco Jun 27, 2022
e88916c
lint: port default hash types diagnostics
davidtwco Jun 27, 2022
8139542
lint: port query instability diagnostics
davidtwco Jun 27, 2022
0996a7a
lint: port ty diagnostics
davidtwco Jun 27, 2022
1c3a3e0
lint: port impl `LintPass` by hand diagnostics
davidtwco Jun 27, 2022
674ac60
lint: port non-existant doc keyword diagnostics
davidtwco Jun 27, 2022
4f35c79
lint: port translation migration diagnostics
davidtwco Jun 27, 2022
c29e05e
lint: port `CString` ptr diagnostics
davidtwco Jun 27, 2022
48e4bf1
lint: port non-ascii-idents diagnostics
davidtwco Jun 27, 2022
7ee4aa7
lint: port non-fmt-panic diagnostics
davidtwco Jun 27, 2022
096a69d
lint: port non-standard style diagnostics
davidtwco Jun 27, 2022
855f237
lint: port no-op method call diagnostics
davidtwco Jun 27, 2022
37588d6
lint: port pass-by-value diagnostics
davidtwco Jun 27, 2022
8e83656
lint: port redundant semicolons diagnostics
davidtwco Jun 27, 2022
7ef610c
lint: port drop trait/glue diagnostics
davidtwco Jun 27, 2022
7a9bef4
lint: port overflowing literals diagnostics
davidtwco Jun 27, 2022
e5f2e0e
lint: port improper ctypes diagnostics
davidtwco Jun 28, 2022
14c3016
lint: port variant size difference diagnostics
davidtwco Jun 28, 2022
0602729
lint: port atomic ordering diagnostics
davidtwco Jun 28, 2022
1999a4c
lint: port unused diagnostics
davidtwco Jun 28, 2022
2829f51
lint: port path statement diagnostics
davidtwco Jun 28, 2022
fc4f8d9
lint: port unused delimiter diagnostics
davidtwco Jun 28, 2022
e248338
lint: port unused import braces diagnostics
davidtwco Jun 28, 2022
4f7b10f
lint: port unused allocation diagnostics
davidtwco Jun 28, 2022
588977b
lint: port while true diagnostics
davidtwco Jun 28, 2022
d433c9a
lint: port box pointers diagnostics
davidtwco Jun 28, 2022
4c63a21
lint: port non-shorthand pattern diagnostics
davidtwco Jun 28, 2022
7dffd14
lint: port unsafe diagnostics
davidtwco Jun 28, 2022
82bd2c2
lint: port missing documentation diagnostics
davidtwco Jun 28, 2022
28655bc
lint: port missing copy impl diagnostics
davidtwco Jun 28, 2022
284ec37
lint: port missing debug impl diagnostics
davidtwco Jun 28, 2022
18a48c1
lint: port anonymous parameter diagnostics
davidtwco Jun 28, 2022
e151d66
lint: port deprecated attr diagnostics
davidtwco Jun 28, 2022
a13b70e
lint: port unused doc comment diagnostics
davidtwco Jun 28, 2022
dbdbdb6
lint: port no-mangle diagnostics
davidtwco Jun 28, 2022
d071f50
lint: port mutable transmutes diagnostic
davidtwco Jun 28, 2022
23ee3e0
lint: port unstable feature diagnostics
davidtwco Jun 28, 2022
dbced10
lint: port unreachable `pub` diagnostic
davidtwco Jun 28, 2022
01a64af
lint: port type alias bounds diagnostics
davidtwco Jun 28, 2022
3c9bda5
lint: port trivial bounds diagnostics
davidtwco Jun 28, 2022
3a498a7
lint: port `...` range pattern diagnostics
davidtwco Jun 28, 2022
10f2d3f
lint: port test items diagnostics
davidtwco Jun 28, 2022
1067641
lint: port keyword idents diagnostics
davidtwco Jun 28, 2022
acea23e
lint: port explicit outlives diagnostics
davidtwco Jun 28, 2022
bd8fe82
lint: port incomplete features diagnostics
davidtwco Jun 28, 2022
157cbbc
lint: add todo for invalid value diagnostics
davidtwco Jun 28, 2022
2e563a4
lint: port clashing extern diagnostics
davidtwco Jun 28, 2022
5524ca1
lint: port deref nullptr diagnostics
davidtwco Jun 28, 2022
fedd4c6
lint: port asm labels diagnostics
davidtwco Jun 28, 2022
9ff6c77
tests: avoid inadvertent diffs in diag derive test
davidtwco Jun 29, 2022
83f2288
Improve click behavior of the source code mobile full-screen "sidebar"
notriddle Jul 1, 2022
6e2c49f
rustdoc: add gui test case ensuring source sidebar doesn't spontaneou…
notriddle Jul 2, 2022
ce9e834
Remove FIXME from rustdoc intra-doc test
GuillaumeGomez Jul 3, 2022
170b173
:arrow_up: rust-analyzer
lnicola Jul 5, 2022
8fa1ed8
Rollup merge of #97712 - RalfJung:untyped, r=scottmcm
Dylan-DPC Jul 5, 2022
291df97
Rollup merge of #98624 - davidtwco:translation-on-lints, r=compiler-e…
Dylan-DPC Jul 5, 2022
c2613a5
Rollup merge of #98776 - notriddle:notriddle/mobile-sidebar-auto-clos…
Dylan-DPC Jul 5, 2022
6a61e18
Rollup merge of #98856 - GuillaumeGomez:rustdoc-test-rm-fixme, r=Dyla…
Dylan-DPC Jul 5, 2022
1036a38
Rollup merge of #98913 - lnicola:rust-analyzer-2022-07-05, r=lnicola
Dylan-DPC Jul 5, 2022
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
Prev Previous commit
Next Next commit
Improve click behavior of the source code mobile full-screen "sidebar"
On desktop, if you open the source code sidebar, it stays open even when you
move from page to page. It used to do the same thing on mobile, but I think
that's stupid. Since the file list fills the entire screen on mobile, and you
can't really do anything with the currently selected file other than dismiss
the "sidebar" to look at it, it's safe to assume that anybody who clicks a
file in that list probably wants the list to go away so they can see it.
  • Loading branch information
notriddle committed Jul 1, 2022
commit 83f22885ae9fe7116f97efd7f7df9b6a719d7e6f
10 changes: 10 additions & 0 deletions src/librustdoc/html/static/css/rustdoc.css
Original file line number Diff line number Diff line change
Expand Up @@ -1683,6 +1683,11 @@ details.rustdoc-toggle[open] > summary.hideme::after {

/* Media Queries */

/*
WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY;
If you update this line, then you also need to update the line with the same warning
in storage.js plus the media query with (max-width: 700px)
*/
@media (min-width: 701px) {
/* In case there is no documentation before a code block, we need to add some margin at the top
to prevent an overlay between the "collapse toggle" and the information tooltip.
Expand All @@ -1703,6 +1708,11 @@ details.rustdoc-toggle[open] > summary.hideme::after {
}
}

/*
WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY
If you update this line, then you also need to update the line with the same warning
in storage.js plus the media query with (min-width: 701px)
*/
@media (max-width: 700px) {
/* When linking to an item with an `id` (for instance, by clicking a link in the sidebar,
or visiting a URL with a fragment like `#method.new`, we don't want the item to be obscured
Expand Down
11 changes: 9 additions & 2 deletions src/librustdoc/html/static/js/source-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@
const rootPath = document.getElementById("rustdoc-vars").attributes["data-root-path"].value;
let oldScrollPosition = 0;

function closeSidebarIfMobile() {
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) {
updateLocalStorage("source-sidebar-show", "false");
}
}

function createDirEntry(elem, parent, fullPath, hasFoundFile) {
const name = document.createElement("div");
name.className = "name";
Expand Down Expand Up @@ -48,6 +54,7 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
const file = document.createElement("a");
file.innerText = file_text;
file.href = rootPath + "src/" + fullPath + file_text + ".html";
file.addEventListener("click", closeSidebarIfMobile);
const w = window.location.href.split("#")[0];
if (!hasFoundFile && w === file.href) {
file.className = "selected";
Expand All @@ -66,7 +73,7 @@ function createDirEntry(elem, parent, fullPath, hasFoundFile) {
function toggleSidebar() {
const child = this.children[0];
if (child.innerText === ">") {
if (window.innerWidth < 701) {
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) {
// This is to keep the scroll position on mobile.
oldScrollPosition = window.scrollY;
document.body.style.position = "fixed";
Expand All @@ -76,7 +83,7 @@ function toggleSidebar() {
child.innerText = "<";
updateLocalStorage("source-sidebar-show", "true");
} else {
if (window.innerWidth < 701) {
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) {
// This is to keep the scroll position on mobile.
document.body.style.position = "";
document.body.style.top = "";
Expand Down
5 changes: 5 additions & 0 deletions src/librustdoc/html/static/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ const darkThemes = ["dark", "ayu"];
window.currentTheme = document.getElementById("themeStyle");
window.mainTheme = document.getElementById("mainThemeStyle");

// WARNING: RUSTDOC_MOBILE_BREAKPOINT MEDIA QUERY
// If you update this line, then you also need to update the two media queries with the same
// warning in rustdoc.css
window.RUSTDOC_MOBILE_BREAKPOINT = 701;

const settingsDataset = (function() {
const settingsElement = document.getElementById("default-settings");
if (settingsElement === null) {
Expand Down
22 changes: 22 additions & 0 deletions src/test/rustdoc-gui/sidebar-source-code-display.goml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ click: "#sidebar-toggle"
// Because of the transition CSS, we check by using `wait-for-css` instead of `assert-css`.
wait-for-css: ("#sidebar-toggle", {"visibility": "visible", "opacity": 1})

// We now check that opening the sidebar and clicking a link will leave it open.
// The behavior here on desktop is different than the behavior on mobile,
// but since the sidebar doesn't fill the entire screen here, it makes sense to have the
// sidebar stay resident.
wait-for-css: (".sidebar", {"width": "300px"})
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
click: ".sidebar a.selected"
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}

// Now we check the display of the sidebar items.
show-text: true

Expand Down Expand Up @@ -152,3 +162,15 @@ click: "#sidebar-toggle"
wait-for-css: (".sidebar", {"width": "0px"})
// The "scrollTop" property should be the same.
assert-window-property: {"pageYOffset": "2519"}

// We now check that opening the sidebar and clicking a link will close it.
// The behavior here on mobile is different than the behavior on desktop,
// but common sense dictates that if you have a list of files that fills the entire screen, and
// you click one of them, you probably want to actually see the file's contents, and not just
// make it the current selection.
click: "#sidebar-toggle"
wait-for-css: (".sidebar", {"width": "500px"})
assert-local-storage: {"rustdoc-source-sidebar-show": "true"}
click: ".sidebar a.selected"
goto: file://|DOC_PATH|/src/test_docs/lib.rs.html
assert-local-storage: {"rustdoc-source-sidebar-show": "false"}