Skip to content

Commit e6c46db

Browse files
committed
Auto merge of rust-lang#131387 - Zalathar:rollup-kprp512, r=Zalathar
Rollup of 7 pull requests Successful merges: - rust-lang#130824 (Add missing module flags for `-Zfunction-return=thunk-extern`) - rust-lang#131170 (Fix `target_vendor` in non-IDF Xtensa ESP32 targets) - rust-lang#131355 (Add tests for some old fixed issues) - rust-lang#131369 (Update books) - rust-lang#131370 (rustdoc: improve `<wbr>`-insertion for SCREAMING_CAMEL_CASE) - rust-lang#131379 (Fix utf8-bom test) - rust-lang#131385 (Un-vacation myself) r? `@ghost` `@rustbot` modify labels: rollup
2 parents b8495e5 + e0555e9 commit e6c46db

24 files changed

+210
-65
lines changed

compiler/rustc_codegen_llvm/src/context.rs

+13-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
1919
use rustc_middle::{bug, span_bug};
2020
use rustc_session::Session;
2121
use rustc_session::config::{
22-
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, PAuthKey, PacRet,
22+
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, FunctionReturn, PAuthKey, PacRet,
2323
};
2424
use rustc_span::source_map::Spanned;
2525
use rustc_span::{DUMMY_SP, Span};
@@ -378,6 +378,18 @@ pub(crate) unsafe fn create_module<'ll>(
378378
}
379379
}
380380

381+
match sess.opts.unstable_opts.function_return {
382+
FunctionReturn::Keep => {}
383+
FunctionReturn::ThunkExtern => unsafe {
384+
llvm::LLVMRustAddModuleFlagU32(
385+
llmod,
386+
llvm::LLVMModFlagBehavior::Override,
387+
c"function_return_thunk_extern".as_ptr(),
388+
1,
389+
)
390+
},
391+
}
392+
381393
match (sess.opts.unstable_opts.small_data_threshold, sess.target.small_data_threshold_support())
382394
{
383395
// Set up the small-data optimization limit for architectures that use

compiler/rustc_target/src/spec/targets/xtensa_esp32_none_elf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
1515
},
1616

1717
options: TargetOptions {
18+
vendor: "espressif".into(),
1819
cpu: "esp32".into(),
1920
linker: Some("xtensa-esp32-elf-gcc".into()),
2021
max_atomic_width: Some(32),

compiler/rustc_target/src/spec/targets/xtensa_esp32s2_none_elf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
1515
},
1616

1717
options: TargetOptions {
18+
vendor: "espressif".into(),
1819
cpu: "esp32-s2".into(),
1920
linker: Some("xtensa-esp32s2-elf-gcc".into()),
2021
max_atomic_width: Some(32),

compiler/rustc_target/src/spec/targets/xtensa_esp32s3_none_elf.rs

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
1515
},
1616

1717
options: TargetOptions {
18+
vendor: "espressif".into(),
1819
cpu: "esp32-s3".into(),
1920
linker: Some("xtensa-esp32s3-elf-gcc".into()),
2021
max_atomic_width: Some(32),

src/doc/nomicon

src/doc/rust-by-example

Submodule rust-by-example updated 97 files

src/librustdoc/html/escape.rs

+11-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,17 @@ impl<'a> fmt::Display for EscapeBodyTextWithWbr<'a> {
108108
|| pk.map_or(true, |(_, t)| t.chars().any(|c| c.is_uppercase()));
109109
let next_is_underscore = || pk.map_or(true, |(_, t)| t.contains('_'));
110110
let next_is_colon = || pk.map_or(true, |(_, t)| t.contains(':'));
111-
if i - last > 3 && is_uppercase() && !next_is_uppercase() {
111+
// Check for CamelCase.
112+
//
113+
// `i - last > 3` avoids turning FmRadio into Fm<wbr>Radio, which is technically
114+
// correct, but needlessly bloated.
115+
//
116+
// is_uppercase && !next_is_uppercase checks for camelCase. HTTPSProxy,
117+
// for example, should become HTTPS<wbr>Proxy.
118+
//
119+
// !next_is_underscore avoids turning TEST_RUN into TEST<wbr>_<wbr>RUN, which is also
120+
// needlessly bloated.
121+
if i - last > 3 && is_uppercase() && !next_is_uppercase() && !next_is_underscore() {
112122
EscapeBodyText(&text[last..i]).fmt(fmt)?;
113123
fmt.write_str("<wbr>")?;
114124
last = i;

src/librustdoc/html/escape/tests.rs

+4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ fn escape_body_text_with_wbr() {
2424
assert_eq!(&E("first:second").to_string(), "first:<wbr>second");
2525
assert_eq!(&E("first::second").to_string(), "first::<wbr>second");
2626
assert_eq!(&E("MY_CONSTANT").to_string(), "MY_<wbr>CONSTANT");
27+
assert_eq!(
28+
&E("_SIDD_MASKED_NEGATIVE_POLARITY").to_string(),
29+
"_SIDD_<wbr>MASKED_<wbr>NEGATIVE_<wbr>POLARITY"
30+
);
2731
// a string won't get wrapped if it's less than 8 bytes
2832
assert_eq!(&E("HashSet").to_string(), "HashSet");
2933
// an individual word won't get wrapped if it's less than 4 bytes

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

+24
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,30 @@ macro_rules! impl_common_helpers {
7070
self
7171
}
7272

73+
/// Configuration for the child process’s standard input (stdin) handle.
74+
///
75+
/// See [`std::process::Command::stdin`].
76+
pub fn stdin<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
77+
self.cmd.stdin(cfg);
78+
self
79+
}
80+
81+
/// Configuration for the child process’s standard output (stdout) handle.
82+
///
83+
/// See [`std::process::Command::stdout`].
84+
pub fn stdout<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
85+
self.cmd.stdout(cfg);
86+
self
87+
}
88+
89+
/// Configuration for the child process’s standard error (stderr) handle.
90+
///
91+
/// See [`std::process::Command::stderr`].
92+
pub fn stderr<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
93+
self.cmd.stderr(cfg);
94+
self
95+
}
96+
7397
/// Inspect what the underlying [`Command`] is up to the
7498
/// current construction.
7599
pub fn inspect<I>(&mut self, inspector: I) -> &mut Self

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
run-make/branch-protection-check-IBT/Makefile
22
run-make/cat-and-grep-sanity-check/Makefile
3-
run-make/emit-to-stdout/Makefile
43
run-make/extern-fn-reachable/Makefile
54
run-make/incr-add-rust-src-component/Makefile
65
run-make/issue-84395-lto-embed-bitcode/Makefile

src/tools/tidy/src/issues.txt

-1
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,6 @@ ui/consts/issue-70942-trait-vs-impl-mismatch.rs
802802
ui/consts/issue-73976-monomorphic.rs
803803
ui/consts/issue-73976-polymorphic.rs
804804
ui/consts/issue-76064.rs
805-
ui/consts/issue-77062-large-zst-array.rs
806805
ui/consts/issue-78655.rs
807806
ui/consts/issue-79137-monomorphic.rs
808807
ui/consts/issue-79137-toogeneric.rs

tests/codegen/function-return.rs

+6
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,9 @@ pub fn foo() {
2626
// keep-thunk-extern: attributes #0 = { {{.*}}fn_ret_thunk_extern{{.*}} }
2727
// thunk-extern-keep-NOT: fn_ret_thunk_extern
2828
}
29+
30+
// unset-NOT: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
31+
// keep-NOT: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
32+
// thunk-extern: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
33+
// keep-thunk-extern: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
34+
// thunk-extern-keep-NOT: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}

tests/run-make/emit-to-stdout/Makefile

-51
This file was deleted.
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
//! If `-o -` or `--emit KIND=-` is provided, output should be written to stdout
2+
//! instead. Binary output (`obj`, `llvm-bc`, `link` and `metadata`)
3+
//! being written this way will result in an error if stdout is a tty.
4+
//! Multiple output types going to stdout will trigger an error too,
5+
//! as they would all be mixed together.
6+
//!
7+
//! See <https://github.com/rust-lang/rust/pull/111626>.
8+
9+
use std::fs::File;
10+
11+
use run_make_support::{diff, run_in_tmpdir, rustc};
12+
13+
// Test emitting text outputs to stdout works correctly
14+
fn run_diff(name: &str, file_args: &[&str]) {
15+
rustc().emit(format!("{name}={name}")).input("test.rs").args(file_args).run();
16+
let out = rustc().emit(format!("{name}=-")).input("test.rs").run().stdout_utf8();
17+
diff().expected_file(name).actual_text("stdout", &out).run();
18+
}
19+
20+
// Test that emitting binary formats to a terminal gives the correct error
21+
fn run_terminal_err_diff(name: &str) {
22+
#[cfg(not(windows))]
23+
let terminal = File::create("/dev/ptmx").unwrap();
24+
// FIXME: If this test fails and the compiler does print to the console,
25+
// then this will produce a lot of output.
26+
// We should spawn a new console instead to print stdout.
27+
#[cfg(windows)]
28+
let terminal = File::options().read(true).write(true).open(r"\\.\CONOUT$").unwrap();
29+
30+
let err = File::create(name).unwrap();
31+
rustc().emit(format!("{name}=-")).input("test.rs").stdout(terminal).stderr(err).run_fail();
32+
diff().expected_file(format!("emit-{name}.stderr")).actual_file(name).run();
33+
}
34+
35+
fn main() {
36+
run_in_tmpdir(|| {
37+
run_diff("asm", &[]);
38+
run_diff("llvm-ir", &[]);
39+
run_diff("dep-info", &["-Zdep-info-omit-d-target=yes"]);
40+
run_diff("mir", &[]);
41+
42+
run_terminal_err_diff("llvm-bc");
43+
run_terminal_err_diff("obj");
44+
run_terminal_err_diff("metadata");
45+
run_terminal_err_diff("link");
46+
47+
// Test error for emitting multiple types to stdout
48+
rustc()
49+
.input("test.rs")
50+
.emit("asm=-")
51+
.emit("llvm-ir=-")
52+
.emit("dep-info=-")
53+
.emit("mir=-")
54+
.stderr(File::create("multiple-types").unwrap())
55+
.run_fail();
56+
diff().expected_file("emit-multiple-types.stderr").actual_file("multiple-types").run();
57+
58+
// Same as above, but using `-o`
59+
rustc()
60+
.input("test.rs")
61+
.output("-")
62+
.emit("asm,llvm-ir,dep-info,mir")
63+
.stderr(File::create("multiple-types-option-o").unwrap())
64+
.run_fail();
65+
diff()
66+
.expected_file("emit-multiple-types.stderr")
67+
.actual_file("multiple-types-option-o")
68+
.run();
69+
70+
// Test that `-o -` redirected to a file works correctly (#26719)
71+
rustc().input("test.rs").output("-").stdout(File::create("out-stdout").unwrap()).run();
72+
});
73+
}

tests/ui/consts/issue-77062-large-zst-array.rs tests/ui/consts/large-zst-array-77062.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
//@ build-pass
2+
pub static FOO: [(); usize::MAX] = [(); usize::MAX];
23

34
fn main() {
45
let _ = &[(); usize::MAX];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//@ check-pass
2+
//! Tests that associated type projections normalize properly in the presence of HRTBs.
3+
//! Original issue: <https://github.com/rust-lang/rust/issues/30472>
4+
5+
6+
pub trait MyFrom<T> {}
7+
impl<T> MyFrom<T> for T {}
8+
9+
pub trait MyInto<T> {}
10+
impl<T, U> MyInto<U> for T where U: MyFrom<T> {}
11+
12+
13+
pub trait A<'self_> {
14+
type T;
15+
}
16+
pub trait B: for<'self_> A<'self_> {
17+
// Originally caused the `type U = usize` example below to fail with a type mismatch error
18+
type U: for<'self_> MyFrom<<Self as A<'self_>>::T>;
19+
}
20+
21+
22+
pub struct M;
23+
impl<'self_> A<'self_> for M {
24+
type T = usize;
25+
}
26+
27+
impl B for M {
28+
type U = usize;
29+
}
30+
31+
32+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//@ check-pass
2+
//! Tests that a HRTB + FnOnce bound involving an associated type don't prevent
3+
//! a function pointer from implementing `Fn` traits.
4+
//! Test for <https://github.com/rust-lang/rust/issues/28994>
5+
6+
trait LifetimeToType<'a> {
7+
type Out;
8+
}
9+
10+
impl<'a> LifetimeToType<'a> for () {
11+
type Out = &'a ();
12+
}
13+
14+
fn id<'a>(val: &'a ()) -> <() as LifetimeToType<'a>>::Out {
15+
val
16+
}
17+
18+
fn assert_fn<F: for<'a> FnOnce(&'a ()) -> <() as LifetimeToType<'a>>::Out>(_func: F) { }
19+
20+
fn main() {
21+
assert_fn(id);
22+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//@ check-pass
2+
//! Tests that HRTB impl selection covers type parameters not directly related
3+
//! to the trait.
4+
//! Test for <https://github.com/rust-lang/rust/issues/30867>
5+
6+
#![crate_type = "lib"]
7+
8+
trait Unary<T> {}
9+
impl<T, U, F: Fn(T) -> U> Unary<T> for F {}
10+
fn unary<F: for<'a> Unary<&'a T>, T>() {}
11+
12+
pub fn test<F: for<'a> Fn(&'a i32) -> &'a i32>() {
13+
unary::<F, i32>()
14+
}

tests/ui/utf8-bom.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1+
// This file has utf-8 BOM, it should be compiled normally without error.
12
//@ run-pass
2-
//
3-
4-
// This file has utf-8 BOM, it should be compiled normally without error.
53

64
pub fn main() {}

triagebot.toml

-1
Original file line numberDiff line numberDiff line change
@@ -926,7 +926,6 @@ users_on_vacation = [
926926
"jhpratt",
927927
"jyn514",
928928
"oli-obk",
929-
"jieyouxu",
930929
]
931930

932931
[assign.adhoc_groups]

0 commit comments

Comments
 (0)