Skip to content

Commit e612ce9

Browse files
committed
Auto merge of rust-lang#96824 - matthiaskrgr:rollup-silw3ki, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#96336 (Link to correct `as_mut` in docs for `pointer::as_ref`) - rust-lang#96586 (Add aliases for std::fs::canonicalize) - rust-lang#96667 (Add regression test) - rust-lang#96671 (Remove hard links from `env::current_exe` security example) - rust-lang#96726 (Add regression and bug tests) - rust-lang#96756 (Enable compiler-docs by default for `compiler`, `codegen`, and `tools` profiles) - rust-lang#96757 (Don't constantly rebuild clippy on `x test src/tools/clippy`.) - rust-lang#96769 (Remove `adx_target_feature` feature from active features list) - rust-lang#96777 (Make the test `check-pass` not to produce a JSON file) - rust-lang#96822 (Enforce quote rule for JS source code) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents ea92b08 + 20ade86 commit e612ce9

24 files changed

+237
-87
lines changed

compiler/rustc_feature/src/active.rs

-1
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,6 @@ declare_features! (
244244

245245
// Unstable `#[target_feature]` directives.
246246
(active, aarch64_ver_target_feature, "1.27.0", Some(44839), None),
247-
(active, adx_target_feature, "1.32.0", Some(44839), None),
248247
(active, arm_target_feature, "1.27.0", Some(44839), None),
249248
(active, avx512_target_feature, "1.27.0", Some(44839), None),
250249
(active, bpf_target_feature, "1.54.0", Some(44839), None),

library/core/src/ptr/mut_ptr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ impl<T: ?Sized> *mut T {
287287
/// For the mutable counterpart see [`as_mut`].
288288
///
289289
/// [`as_uninit_ref`]: #method.as_uninit_ref-1
290-
/// [`as_mut`]: #method.as_mut
290+
/// [`as_mut`]: #method.as_mut-1
291291
///
292292
/// # Safety
293293
///

library/std/src/env.rs

+17-30
Original file line numberDiff line numberDiff line change
@@ -644,36 +644,23 @@ pub fn temp_dir() -> PathBuf {
644644
///
645645
/// # Security
646646
///
647-
/// The output of this function should not be used in anything that might have
648-
/// security implications. For example:
649-
///
650-
/// ```
651-
/// fn main() {
652-
/// println!("{:?}", std::env::current_exe());
653-
/// }
654-
/// ```
655-
///
656-
/// On Linux systems, if this is compiled as `foo`:
657-
///
658-
/// ```bash
659-
/// $ rustc foo.rs
660-
/// $ ./foo
661-
/// Ok("/home/alex/foo")
662-
/// ```
663-
///
664-
/// And you make a hard link of the program:
665-
///
666-
/// ```bash
667-
/// $ ln foo bar
668-
/// ```
669-
///
670-
/// When you run it, you won’t get the path of the original executable, you’ll
671-
/// get the path of the hard link:
672-
///
673-
/// ```bash
674-
/// $ ./bar
675-
/// Ok("/home/alex/bar")
676-
/// ```
647+
/// The output of this function should not be trusted for anything
648+
/// that might have security implications. Basically, if users can run
649+
/// the executable, they can change the output arbitrarily.
650+
///
651+
/// As an example, you can easily introduce a race condition. It goes
652+
/// like this:
653+
///
654+
/// 1. You get the path to the current executable using `current_exe()`, and
655+
/// store it in a variable.
656+
/// 2. Time passes. A malicious actor removes the current executable, and
657+
/// replaces it with a malicious one.
658+
/// 3. You then use the stored path to re-execute the current
659+
/// executable.
660+
///
661+
/// You expected to safely execute the current executable, but you're
662+
/// instead executing something completely different. The code you
663+
/// just executed run with your privileges.
677664
///
678665
/// This sort of behavior has been known to [lead to privilege escalation] when
679666
/// used incorrectly.

library/std/src/fs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1930,6 +1930,8 @@ pub fn read_link<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
19301930
/// Ok(())
19311931
/// }
19321932
/// ```
1933+
#[doc(alias = "realpath")]
1934+
#[doc(alias = "GetFinalPathNameByHandle")]
19331935
#[stable(feature = "fs_canonicalize", since = "1.5.0")]
19341936
pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
19351937
fs_imp::canonicalize(path.as_ref())

src/bootstrap/defaults/config.codegen.toml

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# These defaults are meant for contributors to the compiler who modify codegen or LLVM
2+
[build]
3+
# Contributors working on the compiler will probably expect compiler docs to be generated.
4+
compiler-docs = true
5+
26
[llvm]
37
# This enables debug-assertions in LLVM,
48
# catching logic errors in codegen much earlier in the process.

src/bootstrap/defaults/config.compiler.toml

+4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# These defaults are meant for contributors to the compiler who do not modify codegen or LLVM
2+
[build]
3+
# Contributors working on the compiler will probably expect compiler docs to be generated.
4+
compiler-docs = true
5+
26
[rust]
37
# This enables `RUSTC_LOG=debug`, avoiding confusing situations
48
# where adding `debug!()` appears to do nothing.

src/bootstrap/defaults/config.tools.toml

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ download-rustc = "if-unchanged"
1414
[build]
1515
# Document with the in-tree rustdoc by default, since `download-rustc` makes it quick to compile.
1616
doc-stage = 2
17+
# Contributors working on tools will probably expect compiler docs to be generated, so they can figure out how to use the API.
18+
compiler-docs = true
1719

1820
[llvm]
1921
# Will download LLVM from CI if available on your platform.

src/bootstrap/test.rs

-2
Original file line numberDiff line numberDiff line change
@@ -664,8 +664,6 @@ impl Step for Clippy {
664664
&[],
665665
);
666666

667-
// clippy tests need to know about the stage sysroot
668-
cargo.env("SYSROOT", builder.sysroot(compiler));
669667
cargo.env("RUSTC_TEST_SUITE", builder.rustc(compiler));
670668
cargo.env("RUSTC_LIB_PATH", builder.rustc_libdir(compiler));
671669
let host_libs = builder.stage_out(compiler, Mode::ToolRustc).join(builder.cargo_dir());

src/bootstrap/tool.rs

+4
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,10 @@ pub fn prepare_tool_cargo(
250250
}
251251
}
252252

253+
// clippy tests need to know about the stage sysroot. Set them consistently while building to
254+
// avoid rebuilding when running tests.
255+
cargo.env("SYSROOT", builder.sysroot(compiler));
256+
253257
// if tools are using lzma we want to force the build script to build its
254258
// own copy
255259
cargo.env("LZMA_API_STATIC", "1");

src/librustdoc/html/static/.eslintrc.js

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ module.exports = {
1717
"error",
1818
"always"
1919
],
20+
"quotes": [
21+
"error",
22+
"double"
23+
],
2024
"no-var": ["error"],
2125
"prefer-const": ["error"],
2226
"prefer-arrow-callback": ["error"],

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

+15-15
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ function loadCss(cssFileName) {
291291

292292
(function() {
293293
function loadScript(url) {
294-
const script = document.createElement('script');
294+
const script = document.createElement("script");
295295
script.src = url;
296296
document.head.append(script);
297297
}
@@ -344,7 +344,7 @@ function loadCss(cssFileName) {
344344
searchState.input.blur();
345345
},
346346
showResults: search => {
347-
if (search === null || typeof search === 'undefined') {
347+
if (search === null || typeof search === "undefined") {
348348
search = searchState.outputElement();
349349
}
350350
switchDisplayedElement(search);
@@ -390,7 +390,7 @@ function loadCss(cssFileName) {
390390
loadSearch();
391391
});
392392

393-
if (search_input.value !== '') {
393+
if (search_input.value !== "") {
394394
loadSearch();
395395
}
396396

@@ -968,7 +968,7 @@ function loadCss(cssFileName) {
968968

969969
onEachLazy(document.getElementsByClassName("notable-traits"), e => {
970970
e.onclick = function() {
971-
this.getElementsByClassName('notable-traits-tooltiptext')[0]
971+
this.getElementsByClassName("notable-traits-tooltiptext")[0]
972972
.classList.toggle("force-tooltip");
973973
};
974974
});
@@ -1070,29 +1070,29 @@ function loadCss(cssFileName) {
10701070
const path = [];
10711071

10721072
onEach(parent.childNodes, child => {
1073-
if (child.tagName === 'A') {
1073+
if (child.tagName === "A") {
10741074
path.push(child.textContent);
10751075
}
10761076
});
10771077

1078-
const el = document.createElement('textarea');
1079-
el.value = path.join('::');
1080-
el.setAttribute('readonly', '');
1078+
const el = document.createElement("textarea");
1079+
el.value = path.join("::");
1080+
el.setAttribute("readonly", "");
10811081
// To not make it appear on the screen.
1082-
el.style.position = 'absolute';
1083-
el.style.left = '-9999px';
1082+
el.style.position = "absolute";
1083+
el.style.left = "-9999px";
10841084

10851085
document.body.appendChild(el);
10861086
el.select();
1087-
document.execCommand('copy');
1087+
document.execCommand("copy");
10881088
document.body.removeChild(el);
10891089

10901090
// There is always one children, but multiple childNodes.
1091-
but.children[0].style.display = 'none';
1091+
but.children[0].style.display = "none";
10921092

10931093
let tmp;
10941094
if (but.childNodes.length < 2) {
1095-
tmp = document.createTextNode('✓');
1095+
tmp = document.createTextNode("✓");
10961096
but.appendChild(tmp);
10971097
} else {
10981098
onEachLazy(but.childNodes, e => {
@@ -1101,15 +1101,15 @@ function loadCss(cssFileName) {
11011101
return true;
11021102
}
11031103
});
1104-
tmp.textContent = '✓';
1104+
tmp.textContent = "✓";
11051105
}
11061106

11071107
if (reset_button_timeout !== null) {
11081108
window.clearTimeout(reset_button_timeout);
11091109
}
11101110

11111111
function reset_button() {
1112-
tmp.textContent = '';
1112+
tmp.textContent = "";
11131113
reset_button_timeout = null;
11141114
but.children[0].style.display = "";
11151115
}

src/librustdoc/html/static/js/scrape-examples.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
// Scroll code block to the given code location
1010
function scrollToLoc(elt, loc) {
11-
const lines = elt.querySelector('.line-numbers');
11+
const lines = elt.querySelector(".line-numbers");
1212
let scrollOffset;
1313

1414
// If the block is greater than the size of the viewer,
@@ -32,16 +32,16 @@
3232
function updateScrapedExample(example) {
3333
const locs = JSON.parse(example.attributes.getNamedItem("data-locs").textContent);
3434
let locIndex = 0;
35-
const highlights = Array.prototype.slice.call(example.querySelectorAll('.highlight'));
36-
const link = example.querySelector('.scraped-example-title a');
35+
const highlights = Array.prototype.slice.call(example.querySelectorAll(".highlight"));
36+
const link = example.querySelector(".scraped-example-title a");
3737

3838
if (locs.length > 1) {
3939
// Toggle through list of examples in a given file
4040
const onChangeLoc = changeIndex => {
41-
removeClass(highlights[locIndex], 'focus');
41+
removeClass(highlights[locIndex], "focus");
4242
changeIndex();
4343
scrollToLoc(example, locs[locIndex][0]);
44-
addClass(highlights[locIndex], 'focus');
44+
addClass(highlights[locIndex], "focus");
4545

4646
const url = locs[locIndex][1];
4747
const title = locs[locIndex][2];
@@ -50,24 +50,24 @@
5050
link.innerHTML = title;
5151
};
5252

53-
example.querySelector('.prev')
54-
.addEventListener('click', () => {
53+
example.querySelector(".prev")
54+
.addEventListener("click", () => {
5555
onChangeLoc(() => {
5656
locIndex = (locIndex - 1 + locs.length) % locs.length;
5757
});
5858
});
5959

60-
example.querySelector('.next')
61-
.addEventListener('click', () => {
60+
example.querySelector("next")
61+
.addEventListener("click", () => {
6262
onChangeLoc(() => {
6363
locIndex = (locIndex + 1) % locs.length;
6464
});
6565
});
6666
}
6767

68-
const expandButton = example.querySelector('.expand');
68+
const expandButton = example.querySelector(".expand");
6969
if (expandButton) {
70-
expandButton.addEventListener('click', () => {
70+
expandButton.addEventListener("click", () => {
7171
if (hasClass(example, "expanded")) {
7272
removeClass(example, "expanded");
7373
scrollToLoc(example, locs[0][0]);
@@ -81,19 +81,19 @@
8181
scrollToLoc(example, locs[0][0]);
8282
}
8383

84-
const firstExamples = document.querySelectorAll('.scraped-example-list > .scraped-example');
84+
const firstExamples = document.querySelectorAll(".scraped-example-list > .scraped-example");
8585
onEachLazy(firstExamples, updateScrapedExample);
86-
onEachLazy(document.querySelectorAll('.more-examples-toggle'), toggle => {
86+
onEachLazy(document.querySelectorAll(".more-examples-toggle"), toggle => {
8787
// Allow users to click the left border of the <details> section to close it,
8888
// since the section can be large and finding the [+] button is annoying.
89-
onEachLazy(toggle.querySelectorAll('.toggle-line, .hide-more'), button => {
90-
button.addEventListener('click', () => {
89+
onEachLazy(toggle.querySelectorAll(".toggle-line, .hide-more"), button => {
90+
button.addEventListener("click", () => {
9191
toggle.open = false;
9292
});
9393
});
9494

95-
const moreExamples = toggle.querySelectorAll('.scraped-example');
96-
toggle.querySelector('summary').addEventListener('click', () => {
95+
const moreExamples = toggle.querySelectorAll(".scraped-example");
96+
toggle.querySelector("summary").addEventListener("click", () => {
9797
// Wrapping in setTimeout ensures the update happens after the elements are actually
9898
// visible. This is necessary since updateScrapedExample calls scrollToLoc which
9999
// depends on offsetHeight, a property that requires an element to be visible to

0 commit comments

Comments
 (0)