Skip to content

Rollup of 8 pull requests #138841

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 19 commits into from
Mar 23, 2025
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
9e5c942
Mark some std tests as requiring `panic = "unwind"`
paulmenage Mar 10, 2025
409510c
rustdoc js: add nonnull helper and typecheck src-script.js
lolbinarycat Mar 13, 2025
1f64cb7
Add release notes for 1.85.1
cuviper Mar 18, 2025
e5fc7d6
Fix Thread::set_name on cygwin
Berrysoft Mar 21, 2025
7d3965e
Move make_input call
bjorn3 Feb 6, 2025
41f1ed1
Move some calls to before calling codegen_crate
bjorn3 Feb 6, 2025
cd929bf
Fix lint name in unused linker_messages warning
bjorn3 Feb 27, 2025
b2d7271
target spec check: better error when llvm-floatabi is missing
RalfJung Mar 21, 2025
110f1fe
Revert "Stabilize file_lock"
moxian Mar 22, 2025
f39478f
Clarify "Windows 1607"
cuviper Mar 22, 2025
bafdbca
rustdoc: Use own logic to print `#[repr(..)]` attributes in JSON output.
obi1kenobi Mar 4, 2025
c5a5f8a
Rollup merge of #138018 - obi1kenobi:pg/librustdoc_repr_attr, r=aDotI…
matthiaskrgr Mar 22, 2025
53076de
Rollup merge of #138294 - paulmenage:test-panic-unwind, r=bjorn3
matthiaskrgr Mar 22, 2025
26ecbc6
Rollup merge of #138468 - lolbinarycat:rustdoc-js-less-expect-error-p…
matthiaskrgr Mar 22, 2025
8986c53
Rollup merge of #138675 - cuviper:release-1.85.1, r=Urgau
matthiaskrgr Mar 22, 2025
9a98596
Rollup merge of #138765 - Berrysoft:cygwin-thread-name, r=joboet
matthiaskrgr Mar 22, 2025
4457da3
Rollup merge of #138786 - bjorn3:driver_code_move, r=compiler-errors
matthiaskrgr Mar 22, 2025
7372f28
Rollup merge of #138793 - RalfJung:arm-floatabi, r=Noratrieb
matthiaskrgr Mar 22, 2025
3f59916
Rollup merge of #138822 - moxian:unlock, r=joshtriplett
matthiaskrgr Mar 22, 2025
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
29 changes: 29 additions & 0 deletions src/librustdoc/html/static/js/rustdoc.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@

/* eslint-disable */
declare global {
/** Map from crate name to directory structure, for source view */
declare var srcIndex: Map<string, rustdoc.Dir>;
/** Defined and documented in `main.js` */
declare function nonnull(x: T|null, msg: string|undefined);
interface Window {
/** Make the current theme easy to find */
currentTheme: HTMLLinkElement|null;
Expand Down Expand Up @@ -40,6 +44,23 @@ declare global {
* or if this is a docs page, this function does nothing.
*/
rustdocShowSourceSidebar: function(),
/**
* Close the sidebar in source code view
*/
rustdocCloseSourceSidebar?: function(),
/**
* Shows the sidebar in source code view
*/
rustdocShowSourceSidebar?: function(),
/**
* Toggles the sidebar in source code view
*/
rustdocToggleSrcSidebar?: function(),
/**
* create's the sidebar in source code view.
* called in generated `src-files.js`.
*/
createSrcSidebar?: function(),
/**
* Set up event listeners for a scraped source example.
*/
Expand Down Expand Up @@ -438,4 +459,12 @@ declare namespace rustdoc {
type TypeImpls = {
[cratename: string]: Array<Array<string|0>>
}

/**
* Directory structure for source code view,
* defined in generated `src-files.js`.
*
* is a tuple of (filename, subdirs, filenames).
*/
type Dir = [string, rustdoc.Dir[], string[]]
}
28 changes: 19 additions & 9 deletions src/librustdoc/html/static/js/src-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

// Local js definitions:
/* global addClass, onEachLazy, removeClass, browserSupportsHistoryApi */
/* global updateLocalStorage, getVar */
/* global updateLocalStorage, getVar, nonnull */

// Eventually fix this.
// @ts-nocheck

"use strict";

Expand All @@ -29,6 +27,14 @@ function closeSidebarIfMobile() {
}
}

/**
* @param {rustdoc.Dir} elem
* @param {HTMLElement} parent
* @param {string} fullPath
* @param {boolean} hasFoundFile
*
* @returns {boolean} - new value for hasFoundFile
*/
function createDirEntry(elem, parent, fullPath, hasFoundFile) {
const dirEntry = document.createElement("details");
const summary = document.createElement("summary");
Expand Down Expand Up @@ -95,7 +101,7 @@ window.rustdocToggleSrcSidebar = () => {
// This function is called from "src-files.js", generated in `html/render/write_shared.rs`.
// eslint-disable-next-line no-unused-vars
function createSrcSidebar() {
const container = document.querySelector("nav.sidebar");
const container = nonnull(document.querySelector("nav.sidebar"));

const sidebar = document.createElement("div");
sidebar.id = "src-sidebar";
Expand All @@ -111,6 +117,7 @@ function createSrcSidebar() {
// Focus on the current file in the source files sidebar.
const selected_elem = sidebar.getElementsByClassName("selected")[0];
if (typeof selected_elem !== "undefined") {
// @ts-expect-error
selected_elem.focus();
}
}
Expand All @@ -130,19 +137,20 @@ function highlightSrcLines() {
to = from;
from = tmp;
}
let elem = document.getElementById(from);
const from_s = "" + from;
let elem = document.getElementById(from_s);
if (!elem) {
return;
}
const x = document.getElementById(from);
const x = document.getElementById(from_s);
if (x) {
x.scrollIntoView();
}
onEachLazy(document.querySelectorAll("a[data-nosnippet]"), e => {
removeClass(e, "line-highlighted");
});
for (let i = from; i <= to; ++i) {
elem = document.getElementById(i);
elem = document.getElementById("" + i);
if (!elem) {
break;
}
Expand All @@ -153,11 +161,12 @@ function highlightSrcLines() {
const handleSrcHighlight = (function() {
let prev_line_id = 0;

/** @type {function(string): void} */
const set_fragment = name => {
const x = window.scrollX,
y = window.scrollY;
if (browserSupportsHistoryApi()) {
history.replaceState(null, null, "#" + name);
history.replaceState(null, "", "#" + name);
highlightSrcLines();
} else {
location.replace("#" + name);
Expand All @@ -166,6 +175,7 @@ const handleSrcHighlight = (function() {
window.scrollTo(x, y);
};

// @ts-expect-error
return ev => {
let cur_line_id = parseInt(ev.target.id, 10);
// This event handler is attached to the entire line number column, but it should only
Expand All @@ -191,7 +201,7 @@ const handleSrcHighlight = (function() {
} else {
prev_line_id = cur_line_id;

set_fragment(cur_line_id);
set_fragment("" + cur_line_id);
}
};
}());
Expand Down
22 changes: 22 additions & 0 deletions src/librustdoc/html/static/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,28 @@ const settingsDataset = (function() {
return settingsElement && settingsElement.dataset ? settingsElement.dataset : null;
})();

/**
* Assert that the passed value is nonnull, then return it.
*
* Takes an optional error message argument.
*
* Must be defined in this file, as it is loaded before all others.
*
* @template T
* @param {T|null} x
* @param {string=} msg
* @returns T
*/
// used in other files, not yet used in this one.
// eslint-disable-next-line no-unused-vars
function nonnull(x, msg) {
if (x === null) {
throw (msg || "unexpected null value!");
} else {
return x;
}
}

/**
* Get a configuration value. If it's not set, get the default.
*
Expand Down