Skip to content

Commit f382c27

Browse files
committed
Auto merge of rust-lang#102819 - matthiaskrgr:rollup-xwnvofc, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - rust-lang#99194 (Fix gdb-cmd for rust-gdbgui) - rust-lang#99880 (`EscapeAscii` is not an `ExactSizeIterator`) - rust-lang#102524 (rustdoc: remove weird `<a href="#">` wrapper around unsafe triangle) - rust-lang#102581 (Make the `config.src` handling for downloadable bootstrap more conservative) - rust-lang#102604 (Improve readability of bootstrap's README) - rust-lang#102723 (test: run-make: skip when cross-compiling) - rust-lang#102815 (rustdoc: remove mobile topbar from source pages instead of hiding it) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 8796e7a + 9262863 commit f382c27

File tree

12 files changed

+97
-54
lines changed

12 files changed

+97
-54
lines changed

library/core/src/slice/ascii.rs

-2
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,6 @@ impl<'a> iter::DoubleEndedIterator for EscapeAscii<'a> {
215215
}
216216
}
217217
#[stable(feature = "inherent_ascii_escape", since = "1.60.0")]
218-
impl<'a> iter::ExactSizeIterator for EscapeAscii<'a> {}
219-
#[stable(feature = "inherent_ascii_escape", since = "1.60.0")]
220218
impl<'a> iter::FusedIterator for EscapeAscii<'a> {}
221219
#[stable(feature = "inherent_ascii_escape", since = "1.60.0")]
222220
impl<'a> fmt::Display for EscapeAscii<'a> {

src/bootstrap/README.md

+32-32
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# rustbuild - Bootstrapping Rust
22

33
This is an in-progress README which is targeted at helping to explain how Rust
4-
is bootstrapped and in general some of the technical details of the build
4+
is bootstrapped and in general, some of the technical details of the build
55
system.
66

77
## Using rustbuild
@@ -12,16 +12,16 @@ The rustbuild build system has a primary entry point, a top level `x.py` script:
1212
$ python ./x.py build
1313
```
1414

15-
Note that if you're on Unix you should be able to execute the script directly:
15+
Note that if you're on Unix, you should be able to execute the script directly:
1616

1717
```sh
1818
$ ./x.py build
1919
```
2020

2121
The script accepts commands, flags, and arguments to determine what to do:
2222

23-
* `build` - a general purpose command for compiling code. Alone `build` will
24-
bootstrap the entire compiler, and otherwise arguments passed indicate what to
23+
* `build` - a general purpose command for compiling code. Alone, `build` will
24+
bootstrap the entire compiler, and otherwise, arguments passed indicate what to
2525
build. For example:
2626

2727
```
@@ -38,7 +38,7 @@ The script accepts commands, flags, and arguments to determine what to do:
3838
./x.py build --stage 0 library/test
3939
```
4040

41-
If files are dirty that would normally be rebuilt from stage 0, that can be
41+
If files that would normally be rebuilt from stage 0 are dirty, the rebuild can be
4242
overridden using `--keep-stage 0`. Using `--keep-stage n` will skip all steps
4343
that belong to stage n or earlier:
4444

@@ -47,8 +47,8 @@ The script accepts commands, flags, and arguments to determine what to do:
4747
./x.py build --keep-stage 0
4848
```
4949

50-
* `test` - a command for executing unit tests. Like the `build` command this
51-
will execute the entire test suite by default, and otherwise it can be used to
50+
* `test` - a command for executing unit tests. Like the `build` command, this
51+
will execute the entire test suite by default, and otherwise, it can be used to
5252
select which test suite is run:
5353

5454
```
@@ -75,7 +75,7 @@ The script accepts commands, flags, and arguments to determine what to do:
7575
./x.py test src/doc
7676
```
7777

78-
* `doc` - a command for building documentation. Like above can take arguments
78+
* `doc` - a command for building documentation. Like above, can take arguments
7979
for what to document.
8080

8181
## Configuring rustbuild
@@ -110,12 +110,12 @@ compiler. What actually happens when you invoke rustbuild is:
110110
compiles the build system itself (this folder). Finally, it then invokes the
111111
actual `bootstrap` binary build system.
112112
2. In Rust, `bootstrap` will slurp up all configuration, perform a number of
113-
sanity checks (compilers exist for example), and then start building the
113+
sanity checks (whether compilers exist, for example), and then start building the
114114
stage0 artifacts.
115-
3. The stage0 `cargo` downloaded earlier is used to build the standard library
115+
3. The stage0 `cargo`, downloaded earlier, is used to build the standard library
116116
and the compiler, and then these binaries are then copied to the `stage1`
117117
directory. That compiler is then used to generate the stage1 artifacts which
118-
are then copied to the stage2 directory, and then finally the stage2
118+
are then copied to the stage2 directory, and then finally, the stage2
119119
artifacts are generated using that compiler.
120120

121121
The goal of each stage is to (a) leverage Cargo as much as possible and failing
@@ -149,7 +149,7 @@ like this:
149149
build/
150150

151151
# Location where the stage0 compiler downloads are all cached. This directory
152-
# only contains the tarballs themselves as they're extracted elsewhere.
152+
# only contains the tarballs themselves, as they're extracted elsewhere.
153153
cache/
154154
2015-12-19/
155155
2016-01-15/
@@ -172,22 +172,22 @@ build/
172172
# hand.
173173
x86_64-unknown-linux-gnu/
174174

175-
# The build artifacts for the `compiler-rt` library for the target this
176-
# folder is under. The exact layout here will likely depend on the platform,
177-
# and this is also built with CMake so the build system is also likely
178-
# different.
175+
# The build artifacts for the `compiler-rt` library for the target that
176+
# this folder is under. The exact layout here will likely depend on the
177+
# platform, and this is also built with CMake, so the build system is
178+
# also likely different.
179179
compiler-rt/
180180
build/
181181

182182
# Output folder for LLVM if it is compiled for this target
183183
llvm/
184184

185185
# build folder (e.g. the platform-specific build system). Like with
186-
# compiler-rt this is compiled with CMake
186+
# compiler-rt, this is compiled with CMake
187187
build/
188188

189189
# Installation of LLVM. Note that we run the equivalent of 'make install'
190-
# for LLVM to setup these folders.
190+
# for LLVM, to setup these folders.
191191
bin/
192192
lib/
193193
include/
@@ -206,18 +206,18 @@ build/
206206

207207
# Location where the stage0 Cargo and Rust compiler are unpacked. This
208208
# directory is purely an extracted and overlaid tarball of these two (done
209-
# by the bootstrapy python script). In theory the build system does not
209+
# by the bootstrap python script). In theory, the build system does not
210210
# modify anything under this directory afterwards.
211211
stage0/
212212

213-
# These to build directories are the cargo output directories for builds of
214-
# the standard library and compiler, respectively. Internally these may also
213+
# These to-build directories are the cargo output directories for builds of
214+
# the standard library and compiler, respectively. Internally, these may also
215215
# have other target directories, which represent artifacts being compiled
216216
# from the host to the specified target.
217217
#
218218
# Essentially, each of these directories is filled in by one `cargo`
219219
# invocation. The build system instruments calling Cargo in the right order
220-
# with the right variables to ensure these are filled in correctly.
220+
# with the right variables to ensure that these are filled in correctly.
221221
stageN-std/
222222
stageN-test/
223223
stageN-rustc/
@@ -232,8 +232,8 @@ build/
232232
# being compiled (e.g. after libstd has been built), *this* is used as the
233233
# sysroot for the stage0 compiler being run.
234234
#
235-
# Basically this directory is just a temporary artifact use to configure the
236-
# stage0 compiler to ensure that the libstd we just built is used to
235+
# Basically, this directory is just a temporary artifact used to configure the
236+
# stage0 compiler to ensure that the libstd that we just built is used to
237237
# compile the stage1 compiler.
238238
stage0-sysroot/lib/
239239

@@ -242,7 +242,7 @@ build/
242242
# system will link (using hard links) output from stageN-{std,rustc} into
243243
# each of these directories.
244244
#
245-
# In theory there is no extra build output in these directories.
245+
# In theory, there is no extra build output in these directories.
246246
stage1/
247247
stage2/
248248
stage3/
@@ -265,14 +265,14 @@ structure here serves two goals:
265265
depend on `std`, so libstd is a separate project compiled ahead of time
266266
before the actual compiler builds.
267267
2. Splitting "host artifacts" from "target artifacts". That is, when building
268-
code for an arbitrary target you don't need the entire compiler, but you'll
268+
code for an arbitrary target, you don't need the entire compiler, but you'll
269269
end up needing libraries like libtest that depend on std but also want to use
270270
crates.io dependencies. Hence, libtest is split out as its own project that
271271
is sequenced after `std` but before `rustc`. This project is built for all
272272
targets.
273273

274274
There is some loss in build parallelism here because libtest can be compiled in
275-
parallel with a number of rustc artifacts, but in theory the loss isn't too bad!
275+
parallel with a number of rustc artifacts, but in theory, the loss isn't too bad!
276276

277277
## Build tools
278278

@@ -285,13 +285,13 @@ appropriate libstd/libtest/librustc compile above.
285285

286286
## Extending rustbuild
287287

288-
So you'd like to add a feature to the rustbuild build system or just fix a bug.
288+
So, you'd like to add a feature to the rustbuild build system or just fix a bug.
289289
Great! One of the major motivational factors for moving away from `make` is that
290290
Rust is in theory much easier to read, modify, and write. If you find anything
291-
excessively confusing, please open an issue on this and we'll try to get it
292-
documented or simplified pronto.
291+
excessively confusing, please open an issue on this, and we'll try to get it
292+
documented or simplified, pronto.
293293

294-
First up, you'll probably want to read over the documentation above as that'll
294+
First up, you'll probably want to read over the documentation above, as that'll
295295
give you a high level overview of what rustbuild is doing. You also probably
296296
want to play around a bit yourself by just getting it up and running before you
297297
dive too much into the actual build system itself.
@@ -326,7 +326,7 @@ A 'major change' includes
326326
Changes that do not affect contributors to the compiler or users
327327
building rustc from source don't need an update to `VERSION`.
328328

329-
If you have any questions feel free to reach out on the `#t-infra` channel in
329+
If you have any questions, feel free to reach out on the `#t-infra` channel in
330330
the [Rust Zulip server][rust-zulip] or ask on internals.rust-lang.org. When
331331
you encounter bugs, please file issues on the rust-lang/rust issue tracker.
332332

src/bootstrap/config.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -829,10 +829,19 @@ impl Config {
829829
let s = git_root.to_str().unwrap();
830830

831831
// Bootstrap is quite bad at handling /? in front of paths
832-
config.src = match s.strip_prefix("\\\\?\\") {
832+
let src = match s.strip_prefix("\\\\?\\") {
833833
Some(p) => PathBuf::from(p),
834834
None => PathBuf::from(git_root),
835835
};
836+
// If this doesn't have at least `stage0.json`, we guessed wrong. This can happen when,
837+
// for example, the build directory is inside of another unrelated git directory.
838+
// In that case keep the original `CARGO_MANIFEST_DIR` handling.
839+
//
840+
// NOTE: this implies that downloadable bootstrap isn't supported when the build directory is outside
841+
// the source directory. We could fix that by setting a variable from all three of python, ./x, and x.ps1.
842+
if src.join("src").join("stage0.json").exists() {
843+
config.src = src;
844+
}
836845
} else {
837846
// We're building from a tarball, not git sources.
838847
// We don't support pre-downloaded bootstrap in this case.

src/etc/rust-gdbgui

+1-2
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ GDB_ARGS="--directory=\"$GDB_PYTHON_MODULE_DIRECTORY\" -iex \"add-auto-load-safe
5858
# Finally we execute gdbgui.
5959
PYTHONPATH="$PYTHONPATH:$GDB_PYTHON_MODULE_DIRECTORY" \
6060
exec ${RUST_GDBGUI} \
61-
--gdb ${RUST_GDB} \
62-
--gdb-args "${GDB_ARGS}" \
61+
--gdb-cmd "${RUST_GDB} ${GDB_ARGS}" \
6362
"${@}"
6463

src/librustdoc/html/render/print_item.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ fn item_module(w: &mut Buffer, cx: &mut Context<'_>, item: &clean::Item, items:
400400
if myitem.fn_header(cx.tcx()).unwrap().unsafety
401401
== hir::Unsafety::Unsafe =>
402402
{
403-
"<a title=\"unsafe function\" href=\"#\"><sup>⚠</sup></a>"
403+
"<sup title=\"unsafe function\">⚠</sup>"
404404
}
405405
_ => "",
406406
};

src/librustdoc/html/static/css/rustdoc.css

-4
Original file line numberDiff line numberDiff line change
@@ -1801,10 +1801,6 @@ in storage.js plus the media query with (min-width: 701px)
18011801
top: 0;
18021802
}
18031803

1804-
.source .mobile-topbar {
1805-
display: none;
1806-
}
1807-
18081804
.sidebar-menu-toggle {
18091805
width: 45px;
18101806
/* Rare exception to specifying font sizes in rem. Since this is acting

src/librustdoc/html/static/js/main.js

+8-6
Original file line numberDiff line numberDiff line change
@@ -735,14 +735,15 @@ function loadCss(cssFileName) {
735735
let oldSidebarScrollPosition = null;
736736

737737
function showSidebar() {
738-
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT) {
738+
const mobile_topbar = document.querySelector(".mobile-topbar");
739+
if (window.innerWidth < window.RUSTDOC_MOBILE_BREAKPOINT && mobile_topbar) {
739740
// This is to keep the scroll position on mobile.
740741
oldSidebarScrollPosition = window.scrollY;
741742
document.body.style.width = `${document.body.offsetWidth}px`;
742743
document.body.style.position = "fixed";
743744
document.body.style.top = `-${oldSidebarScrollPosition}px`;
744-
document.querySelector(".mobile-topbar").style.top = `${oldSidebarScrollPosition}px`;
745-
document.querySelector(".mobile-topbar").style.position = "relative";
745+
mobile_topbar.style.top = `${oldSidebarScrollPosition}px`;
746+
mobile_topbar.style.position = "relative";
746747
} else {
747748
oldSidebarScrollPosition = null;
748749
}
@@ -751,13 +752,14 @@ function loadCss(cssFileName) {
751752
}
752753

753754
function hideSidebar() {
754-
if (oldSidebarScrollPosition !== null) {
755+
const mobile_topbar = document.querySelector(".mobile-topbar");
756+
if (oldSidebarScrollPosition !== null && mobile_topbar) {
755757
// This is to keep the scroll position on mobile.
756758
document.body.style.width = "";
757759
document.body.style.position = "";
758760
document.body.style.top = "";
759-
document.querySelector(".mobile-topbar").style.top = "";
760-
document.querySelector(".mobile-topbar").style.position = "";
761+
mobile_topbar.style.top = "";
762+
mobile_topbar.style.position = "";
761763
// The scroll position is lost when resetting the style, hence why we store it in
762764
// `oldSidebarScrollPosition`.
763765
window.scrollTo(0, oldSidebarScrollPosition);

src/librustdoc/html/templates/page.html

+2
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
</div> {#- -#}
7474
<![endif]--> {#- -#}
7575
{{- layout.external_html.before_content|safe -}}
76+
{%- if page.css_class != "source" -%}
7677
<nav class="mobile-topbar"> {#- -#}
7778
<button class="sidebar-menu-toggle">&#9776;</button> {#- -#}
7879
<a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
@@ -86,6 +87,7 @@
8687
</a> {#- -#}
8788
<h2 class="location"></h2> {#- -#}
8889
</nav> {#- -#}
90+
{%- endif -%}
8991
<nav class="sidebar"> {#- -#}
9092
<a class="sidebar-logo" href="{{page.root_path|safe}}{{krate_with_trailing_slash|safe}}index.html"> {#- -#}
9193
<div class="logo-container"> {#- -#}

src/test/run-make/issue-36710/Makefile

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
1-
# ignore-riscv64 $(call RUN,foo) expects to run the target executable natively
1+
# ignore-cross-compile $(call RUN,foo) expects to run the target executable natively
22
# so it won't work with remote-test-server
3-
# ignore-arm Another build using remote-test-server
43
# ignore-none no-std is not supported
5-
# ignore-wasm32 FIXME: don't attempt to compile C++ to WASM
6-
# ignore-wasm64 FIXME: don't attempt to compile C++ to WASM
7-
# ignore-nvptx64-nvidia-cuda FIXME: can't find crate for `std`
84
# ignore-musl FIXME: this makefile needs teaching how to use a musl toolchain
95
# (see dist-i586-gnu-i586-i686-musl Dockerfile)
106

src/test/rustdoc-gui/sidebar-source-code.goml

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,4 @@ assert-false: ".source-sidebar-expanded"
4242
assert: "nav.sidebar"
4343

4444
// Check that the topbar is not visible
45-
assert-property: (".mobile-topbar", {"offsetParent": "null"})
45+
assert-false: ".mobile-topbar"

src/test/rustdoc-gui/src/test_docs/lib.rs

+4
Original file line numberDiff line numberDiff line change
@@ -367,3 +367,7 @@ impl TypeWithNoDocblocks {
367367
pub fn first_fn(&self) {}
368368
pub fn second_fn(&self) {}
369369
}
370+
371+
pub unsafe fn unsafe_fn() {}
372+
373+
pub fn safe_fn() {}

src/test/rustdoc-gui/unsafe-fn.goml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
goto: "file://" + |DOC_PATH| + "/test_docs/index.html"
2+
3+
compare-elements-property: (
4+
"//a[@title='test_docs::safe_fn fn']/..",
5+
"//a[@title='test_docs::unsafe_fn fn']/..",
6+
["clientHeight"]
7+
)
8+
9+
// If the text isn't displayed, the browser doesn't compute color style correctly...
10+
show-text: true
11+
12+
// Set the theme to dark.
13+
local-storage: {"rustdoc-theme": "dark", "rustdoc-preferred-dark-theme": "dark", "rustdoc-use-system-theme": "false"}
14+
// We reload the page so the local storage settings are being used.
15+
reload:
16+
17+
assert-css: (".item-left sup", {
18+
"color": "rgb(221, 221, 221)"
19+
})
20+
21+
// Set the theme to ayu.
22+
local-storage: {"rustdoc-theme": "ayu", "rustdoc-preferred-dark-theme": "ayu", "rustdoc-use-system-theme": "false"}
23+
// We reload the page so the local storage settings are being used.
24+
reload:
25+
26+
assert-css: (".item-left sup", {
27+
"color": "rgb(197, 197, 197)"
28+
})
29+
30+
// Set the theme to light.
31+
local-storage: {"rustdoc-theme": "light", "rustdoc-preferred-dark-theme": "light", "rustdoc-use-system-theme": "false"}
32+
// We reload the page so the local storage settings are being used.
33+
reload:
34+
35+
assert-css: (".item-left sup", {
36+
"color": "rgb(0, 0, 0)"
37+
})

0 commit comments

Comments
 (0)