Skip to content

Commit 1871252

Browse files
committed
Auto merge of rust-lang#125164 - fmease:rollup-s5vwzlg, r=fmease
Rollup of 5 pull requests Successful merges: - rust-lang#125003 (avoid using aligned_alloc; posix_memalign is better-behaved) - rust-lang#125142 (Migrate `run-make/rustdoc-themes` to new rmake.rs) - rust-lang#125146 (Migrate `run-make/panic-impl-transitive` to `rmake`) - rust-lang#125154 (Small improvements to the documentaion of FnAbi ) - rust-lang#125159 (Meta: Allow unauthenticated users to modify `L-*`, `PG-*` and `-Z*` labels) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b21b74b + 734a109 commit 1871252

File tree

10 files changed

+78
-43
lines changed

10 files changed

+78
-43
lines changed

compiler/rustc_target/src/abi/call/mod.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -779,26 +779,31 @@ impl RiscvInterruptKind {
779779
/// Metadata describing how the arguments to a native function
780780
/// should be passed in order to respect the native ABI.
781781
///
782+
/// The signature represented by this type may not match the MIR function signature.
783+
/// Certain attributes, like `#[track_caller]` can introduce additional arguments, which are present in [`FnAbi`], but not in `FnSig`.
784+
/// While this difference is rarely relevant, it should still be kept in mind.
785+
///
782786
/// I will do my best to describe this structure, but these
783787
/// comments are reverse-engineered and may be inaccurate. -NDM
784788
#[derive(Clone, PartialEq, Eq, Hash, HashStable_Generic)]
785789
pub struct FnAbi<'a, Ty> {
786-
/// The LLVM types of each argument.
790+
/// The type, layout, and information about how each argument is passed.
787791
pub args: Box<[ArgAbi<'a, Ty>]>,
788792

789-
/// LLVM return type.
793+
/// The layout, type, and the way a value is returned from this function.
790794
pub ret: ArgAbi<'a, Ty>,
791795

796+
/// Marks this function as variadic (accepting a variable number of arguments).
792797
pub c_variadic: bool,
793798

794799
/// The count of non-variadic arguments.
795800
///
796801
/// Should only be different from args.len() when c_variadic is true.
797802
/// This can be used to know whether an argument is variadic or not.
798803
pub fixed_count: u32,
799-
804+
/// The calling convention of this function.
800805
pub conv: Conv,
801-
806+
/// Indicates if an unwind may happen across a call to this function.
802807
pub can_unwind: bool,
803808
}
804809

library/std/src/sys/pal/unix/alloc.rs

+8-11
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,18 @@ cfg_if::cfg_if! {
8787
// /memory/aligned_memory.cc
8888
libc::memalign(layout.align(), layout.size()) as *mut u8
8989
}
90-
} else if #[cfg(target_os = "wasi")] {
91-
#[inline]
92-
unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
93-
// C11 aligned_alloc requires that the size be a multiple of the alignment.
94-
// Layout already checks that the size rounded up doesn't overflow isize::MAX.
95-
let align = layout.align();
96-
let size = layout.size().next_multiple_of(align);
97-
libc::aligned_alloc(align, size) as *mut u8
98-
}
9990
} else {
10091
#[inline]
10192
unsafe fn aligned_malloc(layout: &Layout) -> *mut u8 {
10293
let mut out = ptr::null_mut();
103-
// posix_memalign requires that the alignment be a multiple of `sizeof(void*)`.
104-
// Since these are all powers of 2, we can just use max.
94+
// We prefer posix_memalign over aligned_malloc since with aligned_malloc,
95+
// implementations are making almost arbitrary choices for which alignments are
96+
// "supported", making it hard to use. For instance, some implementations require the
97+
// size to be a multiple of the alignment (wasi emmalloc), while others require the
98+
// alignment to be at least the pointer size (Illumos, macOS) -- which may or may not be
99+
// standards-compliant, but that does not help us.
100+
// posix_memalign only has one, clear requirement: that the alignment be a multiple of
101+
// `sizeof(void*)`. Since these are all powers of 2, we can just use max.
105102
let align = layout.align().max(crate::mem::size_of::<usize>());
106103
let ret = libc::posix_memalign(&mut out, align, layout.size());
107104
if ret != 0 { ptr::null_mut() } else { out as *mut u8 }

src/tools/run-make-support/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ pub fn python_command() -> Command {
6464
Command::new(python_path)
6565
}
6666

67+
pub fn htmldocck() -> Command {
68+
let mut python = python_command();
69+
python.arg(source_path().join("/src/etc/htmldocck.py"));
70+
python
71+
}
72+
6773
pub fn source_path() -> PathBuf {
6874
std::env::var("S").expect("S variable does not exist").into()
6975
}

src/tools/tidy/src/allowed_run_make_makefiles.txt

-2
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,6 @@ run-make/output-with-hyphens/Makefile
190190
run-make/override-aliased-flags/Makefile
191191
run-make/overwrite-input/Makefile
192192
run-make/panic-abort-eh_frame/Makefile
193-
run-make/panic-impl-transitive/Makefile
194193
run-make/pass-linker-flags-flavor/Makefile
195194
run-make/pass-linker-flags-from-dep/Makefile
196195
run-make/pass-linker-flags/Makefile
@@ -243,7 +242,6 @@ run-make/rustdoc-scrape-examples-multiple/Makefile
243242
run-make/rustdoc-scrape-examples-remap/Makefile
244243
run-make/rustdoc-scrape-examples-test/Makefile
245244
run-make/rustdoc-scrape-examples-whitespace/Makefile
246-
run-make/rustdoc-themes/Makefile
247245
run-make/rustdoc-verify-output-files/Makefile
248246
run-make/rustdoc-with-out-dir-option/Makefile
249247
run-make/rustdoc-with-output-option/Makefile

tests/run-make/panic-impl-transitive/Makefile

-7
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// In Rust programs where the standard library is unavailable (#![no_std]), we may be interested
2+
// in customizing how panics are handled. Here, the provider specifies that panics should be handled
3+
// by entering an infinite loop. This test checks that this panic implementation can be transitively
4+
// provided by an external crate.
5+
// --emit=llvm-ir is used to avoid running the linker, as linking will fail due to the lack of main
6+
// function in the crate.
7+
// See https://github.com/rust-lang/rust/pull/50338
8+
9+
use run_make_support::{rustc, tmp_dir};
10+
11+
fn main() {
12+
rustc().input("panic-impl-provider.rs").run();
13+
rustc()
14+
.input("panic-impl-consumer.rs")
15+
.panic("abort")
16+
.emit("llvm-ir")
17+
.library_search_path(tmp_dir())
18+
.run();
19+
}

tests/run-make/rustdoc-scrape-examples-ordering/rmake.rs

+2-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use run_make_support::{python_command, rustc, rustdoc, source_path, tmp_dir};
1+
use run_make_support::{htmldocck, rustc, rustdoc, source_path, tmp_dir};
22
use std::fs::read_dir;
33
use std::path::Path;
44

@@ -45,11 +45,5 @@ fn main() {
4545
}
4646
rustdoc.run();
4747

48-
python_command()
49-
.arg(source_path().join("/src/etc/htmldocck.py"))
50-
.arg(out_dir)
51-
.arg("src/lib.rs")
52-
.status()
53-
.unwrap()
54-
.success();
48+
htmldocck().arg(out_dir).arg("src/lib.rs").status().unwrap().success();
5549
}

tests/run-make/rustdoc-themes/Makefile

-11
This file was deleted.
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Test that rustdoc will properly load in a theme file and display it in the theme selector.
2+
3+
use run_make_support::{htmldocck, rustdoc, source_path, tmp_dir};
4+
5+
fn main() {
6+
let out_dir = tmp_dir().join("rustdoc-themes");
7+
let test_css = out_dir.join("test.css");
8+
9+
let no_script =
10+
std::fs::read_to_string(source_path().join("src/librustdoc/html/static/css/noscript.css"))
11+
.unwrap();
12+
13+
let mut test_content = String::new();
14+
let mut found_begin_light = false;
15+
for line in no_script.split('\n') {
16+
if line == "/* Begin theme: light */" {
17+
found_begin_light = true;
18+
} else if line == "/* End theme: light */" {
19+
break;
20+
} else if found_begin_light {
21+
test_content.push_str(line);
22+
test_content.push('\n');
23+
}
24+
}
25+
assert!(!test_content.is_empty());
26+
std::fs::create_dir_all(&out_dir).unwrap();
27+
std::fs::write(&test_css, test_content).unwrap();
28+
29+
rustdoc().output(&out_dir).input("foo.rs").arg("--theme").arg(&test_css).run();
30+
htmldocck().arg(out_dir).arg("foo.rs").status().unwrap().success();
31+
}

triagebot.toml

+3
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@ allow-unauthenticated = [
99
"E-*",
1010
"F-*",
1111
"I-*",
12+
"L-*",
1213
"NLL-*",
1314
"O-*",
15+
"PG-*",
1416
"S-*",
1517
"T-*",
1618
"WG-*",
19+
"-Z*",
1720
"beta-nominated",
1821
"const-hack",
1922
"llvm-*",

0 commit comments

Comments
 (0)