Skip to content

Commit

Permalink
Auto merge of #131387 - Zalathar:rollup-kprp512, r=Zalathar
Browse files Browse the repository at this point in the history
Rollup of 7 pull requests

Successful merges:

 - #130824 (Add missing module flags for `-Zfunction-return=thunk-extern`)
 - #131170 (Fix `target_vendor` in non-IDF Xtensa ESP32 targets)
 - #131355 (Add tests for some old fixed issues)
 - #131369 (Update books)
 - #131370 (rustdoc: improve `<wbr>`-insertion for SCREAMING_CAMEL_CASE)
 - #131379 (Fix utf8-bom test)
 - #131385 (Un-vacation myself)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Oct 8, 2024
2 parents b8495e5 + e0555e9 commit e6c46db
Show file tree
Hide file tree
Showing 24 changed files with 210 additions and 65 deletions.
14 changes: 13 additions & 1 deletion compiler/rustc_codegen_llvm/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use rustc_middle::ty::{self, Instance, Ty, TyCtxt};
use rustc_middle::{bug, span_bug};
use rustc_session::Session;
use rustc_session::config::{
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, PAuthKey, PacRet,
BranchProtection, CFGuard, CFProtection, CrateType, DebugInfo, FunctionReturn, PAuthKey, PacRet,
};
use rustc_span::source_map::Spanned;
use rustc_span::{DUMMY_SP, Span};
Expand Down Expand Up @@ -378,6 +378,18 @@ pub(crate) unsafe fn create_module<'ll>(
}
}

match sess.opts.unstable_opts.function_return {
FunctionReturn::Keep => {}
FunctionReturn::ThunkExtern => unsafe {
llvm::LLVMRustAddModuleFlagU32(
llmod,
llvm::LLVMModFlagBehavior::Override,
c"function_return_thunk_extern".as_ptr(),
1,
)
},
}

match (sess.opts.unstable_opts.small_data_threshold, sess.target.small_data_threshold_support())
{
// Set up the small-data optimization limit for architectures that use
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
},

options: TargetOptions {
vendor: "espressif".into(),
cpu: "esp32".into(),
linker: Some("xtensa-esp32-elf-gcc".into()),
max_atomic_width: Some(32),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
},

options: TargetOptions {
vendor: "espressif".into(),
cpu: "esp32-s2".into(),
linker: Some("xtensa-esp32s2-elf-gcc".into()),
max_atomic_width: Some(32),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub(crate) fn target() -> Target {
},

options: TargetOptions {
vendor: "espressif".into(),
cpu: "esp32-s3".into(),
linker: Some("xtensa-esp32s3-elf-gcc".into()),
max_atomic_width: Some(32),
Expand Down
2 changes: 1 addition & 1 deletion src/doc/embedded-book
2 changes: 1 addition & 1 deletion src/doc/nomicon
Submodule nomicon updated 1 files
+3 −3 src/destructors.md
2 changes: 1 addition & 1 deletion src/doc/rust-by-example
Submodule rust-by-example updated 97 files
+1 −1 .github/workflows/rbe.yml
+2 −0 .gitignore
+2 −2 CONTRIBUTING.md
+1 −1 README.md
+1 −1 TRANSLATING.md
+32 −0 TRANSLATING_ZH.md
+16,910 −0 po/zh.po
+4 −2 src/attribute.md
+0 −1 src/cargo/deps.md
+8 −6 src/cargo/test.md
+1 −1 src/compatibility.md
+2 −2 src/conversion/from_into.md
+1 −1 src/conversion/string.md
+1 −1 src/crates/lib.md
+1 −1 src/crates/using_lib.md
+1 −1 src/custom_types.md
+1 −1 src/custom_types/enum/enum_use.md
+1 −3 src/error/abort_unwind.md
+4 −4 src/error/multiple_error_types/define_error_type.md
+0 −1 src/error/multiple_error_types/wrap_error.md
+1 −1 src/error/option_unwrap.md
+5 −5 src/error/option_unwrap/and_then.md
+6 −4 src/error/option_unwrap/defaults.md
+5 −5 src/error/option_unwrap/map.md
+2 −2 src/error/option_unwrap/question_mark.md
+0 −1 src/error/result.md
+0 −1 src/error/result/enter_question_mark.md
+1 −4 src/flow_control/let_else.md
+1 −1 src/flow_control/loop.md
+1 −0 src/flow_control/match/binding.md
+0 −1 src/flow_control/match/destructuring.md
+2 −2 src/flow_control/match/destructuring/destructure_pointers.md
+1 −0 src/fn/closures.md
+1 −1 src/fn/closures/closure_examples.md
+2 −2 src/fn/closures/closure_examples/iter_find.md
+2 −2 src/fn/diverging.md
+6 −6 src/generics.md
+2 −2 src/generics/assoc_items.md
+5 −5 src/generics/assoc_items/the_problem.md
+1 −1 src/generics/assoc_items/types.md
+1 −1 src/generics/bounds.md
+3 −3 src/generics/gen_fn.md
+0 −1 src/generics/impl.md
+1 −1 src/generics/new_types.md
+3 −3 src/generics/where.md
+0 −1 src/hello/print/print_debug.md
+2 −3 src/index.md
+1 −1 src/macros.md
+2 −2 src/macros/overload.md
+1 −1 src/meta/playground.md
+1 −1 src/mod.md
+3 −3 src/mod/struct_visibility.md
+2 −2 src/scope.md
+1 −1 src/scope/borrow.md
+3 −2 src/scope/borrow/mut.md
+2 −2 src/scope/borrow/ref.md
+6 −6 src/scope/lifetime/explicit.md
+1 −1 src/scope/lifetime/fn.md
+2 −2 src/scope/lifetime/lifetime_bounds.md
+2 −2 src/scope/lifetime/lifetime_coercion.md
+2 −0 src/scope/lifetime/static_lifetime.md
+0 −1 src/scope/lifetime/struct.md
+0 −1 src/scope/lifetime/trait.md
+4 −4 src/scope/move.md
+1 −1 src/scope/move/mut.md
+13 −11 src/scope/move/partial_move.md
+2 −2 src/std/box.md
+9 −9 src/std/hash.md
+8 −8 src/std/hash/alt_key_types.md
+8 −8 src/std/hash/hashset.md
+9 −3 src/std/rc.md
+1 −1 src/std/result.md
+1 −1 src/std/result/question_mark.md
+5 −4 src/std/vec.md
+1 −1 src/std_misc/file.md
+1 −0 src/std_misc/file/create.md
+1 −1 src/std_misc/file/read_lines.md
+3 −3 src/std_misc/path.md
+5 −3 src/std_misc/threads/testcase_mapreduce.md
+1 −0 src/testing/dev_dependencies.md
+2 −2 src/testing/doc_testing.md
+1 −0 src/testing/unit_testing.md
+2 −2 src/trait.md
+3 −1 src/trait/derive.md
+1 −1 src/trait/disambiguating.md
+2 −2 src/trait/drop.md
+12 −4 src/trait/dyn.md
+0 −1 src/trait/impl_trait.md
+2 −1 src/trait/iter.md
+1 −0 src/types.md
+1 −1 src/types/inference.md
+1 −1 src/types/literals.md
+5 −4 src/unsafe.md
+18 −8 src/unsafe/asm.md
+1 −1 src/variable_bindings/freeze.md
+5 −1 src/variable_bindings/scope.md
+3 −0 theme/index.hbs
2 changes: 1 addition & 1 deletion src/doc/rustc-dev-guide
Submodule rustc-dev-guide updated 45 files
+5 −2 examples/rustc-driver-getting-diagnostics.rs
+8 −6 src/SUMMARY.md
+14 −12 src/building/build-install-distribution-artifacts.md
+24 −4 src/building/how-to-build-and-run.md
+10 −2 src/building/new-target.md
+31 −21 src/building/quickstart.md
+179 −139 src/building/suggested.md
+1 −1 src/compiler-debugging.md
+92 −79 src/compiler-src.md
+1 −1 src/diagnostics/diagnostic-items.md
+13 −0 src/git.md
+206 −194 src/macro-expansion.md
+33 −19 src/memory.md
+7 −7 src/mir/index.md
+44 −32 src/name-resolution.md
+8 −31 src/profiling/with_perf.md
+37 −0 src/profiling/with_rustc_perf.md
+40 −41 src/queries/salsa.md
+0 −45 src/rustc-driver.md
+3 −3 src/rustc-driver/getting-diagnostics.md
+1 −1 src/rustc-driver/interacting-with-the-ast.md
+50 −0 src/rustc-driver/intro.md
+73 −3 src/rustdoc-internals/search.md
+2 −2 src/rustdoc.md
+73 −53 src/serialization.md
+16 −4 src/stability.md
+16 −10 src/syntax-intro.md
+96 −91 src/tests/adding.md
+194 −0 src/tests/best-practices.md
+244 −117 src/tests/ci.md
+342 −278 src/tests/compiletest.md
+15 −15 src/tests/crater.md
+443 −0 src/tests/directives.md
+28 −0 src/tests/ecosystem.md
+10 −9 src/tests/fuchsia.md
+0 −449 src/tests/headers.md
+0 −49 src/tests/integration.md
+54 −47 src/tests/intro.md
+27 −23 src/tests/perf.md
+140 −109 src/tests/running.md
+26 −13 src/tests/rust-for-linux.md
+23 −19 src/tests/suggest-tests.md
+245 −253 src/tests/ui.md
+41 −37 src/the-parser.md
+3 −3 src/traits/unsize.md
12 changes: 11 additions & 1 deletion src/librustdoc/html/escape.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,17 @@ impl<'a> fmt::Display for EscapeBodyTextWithWbr<'a> {
|| pk.map_or(true, |(_, t)| t.chars().any(|c| c.is_uppercase()));
let next_is_underscore = || pk.map_or(true, |(_, t)| t.contains('_'));
let next_is_colon = || pk.map_or(true, |(_, t)| t.contains(':'));
if i - last > 3 && is_uppercase() && !next_is_uppercase() {
// Check for CamelCase.
//
// `i - last > 3` avoids turning FmRadio into Fm<wbr>Radio, which is technically
// correct, but needlessly bloated.
//
// is_uppercase && !next_is_uppercase checks for camelCase. HTTPSProxy,
// for example, should become HTTPS<wbr>Proxy.
//
// !next_is_underscore avoids turning TEST_RUN into TEST<wbr>_<wbr>RUN, which is also
// needlessly bloated.
if i - last > 3 && is_uppercase() && !next_is_uppercase() && !next_is_underscore() {
EscapeBodyText(&text[last..i]).fmt(fmt)?;
fmt.write_str("<wbr>")?;
last = i;
Expand Down
4 changes: 4 additions & 0 deletions src/librustdoc/html/escape/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ fn escape_body_text_with_wbr() {
assert_eq!(&E("first:second").to_string(), "first:<wbr>second");
assert_eq!(&E("first::second").to_string(), "first::<wbr>second");
assert_eq!(&E("MY_CONSTANT").to_string(), "MY_<wbr>CONSTANT");
assert_eq!(
&E("_SIDD_MASKED_NEGATIVE_POLARITY").to_string(),
"_SIDD_<wbr>MASKED_<wbr>NEGATIVE_<wbr>POLARITY"
);
// a string won't get wrapped if it's less than 8 bytes
assert_eq!(&E("HashSet").to_string(), "HashSet");
// an individual word won't get wrapped if it's less than 4 bytes
Expand Down
24 changes: 24 additions & 0 deletions src/tools/run-make-support/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ macro_rules! impl_common_helpers {
self
}

/// Configuration for the child process’s standard input (stdin) handle.
///
/// See [`std::process::Command::stdin`].
pub fn stdin<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
self.cmd.stdin(cfg);
self
}

/// Configuration for the child process’s standard output (stdout) handle.
///
/// See [`std::process::Command::stdout`].
pub fn stdout<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
self.cmd.stdout(cfg);
self
}

/// Configuration for the child process’s standard error (stderr) handle.
///
/// See [`std::process::Command::stderr`].
pub fn stderr<T: Into<::std::process::Stdio>>(&mut self, cfg: T) -> &mut Self {
self.cmd.stderr(cfg);
self
}

/// Inspect what the underlying [`Command`] is up to the
/// current construction.
pub fn inspect<I>(&mut self, inspector: I) -> &mut Self
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
run-make/branch-protection-check-IBT/Makefile
run-make/cat-and-grep-sanity-check/Makefile
run-make/emit-to-stdout/Makefile
run-make/extern-fn-reachable/Makefile
run-make/incr-add-rust-src-component/Makefile
run-make/issue-84395-lto-embed-bitcode/Makefile
Expand Down
1 change: 0 additions & 1 deletion src/tools/tidy/src/issues.txt
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,6 @@ ui/consts/issue-70942-trait-vs-impl-mismatch.rs
ui/consts/issue-73976-monomorphic.rs
ui/consts/issue-73976-polymorphic.rs
ui/consts/issue-76064.rs
ui/consts/issue-77062-large-zst-array.rs
ui/consts/issue-78655.rs
ui/consts/issue-79137-monomorphic.rs
ui/consts/issue-79137-toogeneric.rs
Expand Down
6 changes: 6 additions & 0 deletions tests/codegen/function-return.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,9 @@ pub fn foo() {
// keep-thunk-extern: attributes #0 = { {{.*}}fn_ret_thunk_extern{{.*}} }
// thunk-extern-keep-NOT: fn_ret_thunk_extern
}

// unset-NOT: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
// keep-NOT: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
// thunk-extern: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
// keep-thunk-extern: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
// thunk-extern-keep-NOT: !{{[0-9]+}} = !{i32 4, !"function_return_thunk_extern", i32 1}
51 changes: 0 additions & 51 deletions tests/run-make/emit-to-stdout/Makefile

This file was deleted.

73 changes: 73 additions & 0 deletions tests/run-make/emit-to-stdout/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
//! If `-o -` or `--emit KIND=-` is provided, output should be written to stdout
//! instead. Binary output (`obj`, `llvm-bc`, `link` and `metadata`)
//! being written this way will result in an error if stdout is a tty.
//! Multiple output types going to stdout will trigger an error too,
//! as they would all be mixed together.
//!
//! See <https://github.com/rust-lang/rust/pull/111626>.
use std::fs::File;

use run_make_support::{diff, run_in_tmpdir, rustc};

// Test emitting text outputs to stdout works correctly
fn run_diff(name: &str, file_args: &[&str]) {
rustc().emit(format!("{name}={name}")).input("test.rs").args(file_args).run();
let out = rustc().emit(format!("{name}=-")).input("test.rs").run().stdout_utf8();
diff().expected_file(name).actual_text("stdout", &out).run();
}

// Test that emitting binary formats to a terminal gives the correct error
fn run_terminal_err_diff(name: &str) {
#[cfg(not(windows))]
let terminal = File::create("/dev/ptmx").unwrap();
// FIXME: If this test fails and the compiler does print to the console,
// then this will produce a lot of output.
// We should spawn a new console instead to print stdout.
#[cfg(windows)]
let terminal = File::options().read(true).write(true).open(r"\\.\CONOUT$").unwrap();

let err = File::create(name).unwrap();
rustc().emit(format!("{name}=-")).input("test.rs").stdout(terminal).stderr(err).run_fail();
diff().expected_file(format!("emit-{name}.stderr")).actual_file(name).run();
}

fn main() {
run_in_tmpdir(|| {
run_diff("asm", &[]);
run_diff("llvm-ir", &[]);
run_diff("dep-info", &["-Zdep-info-omit-d-target=yes"]);
run_diff("mir", &[]);

run_terminal_err_diff("llvm-bc");
run_terminal_err_diff("obj");
run_terminal_err_diff("metadata");
run_terminal_err_diff("link");

// Test error for emitting multiple types to stdout
rustc()
.input("test.rs")
.emit("asm=-")
.emit("llvm-ir=-")
.emit("dep-info=-")
.emit("mir=-")
.stderr(File::create("multiple-types").unwrap())
.run_fail();
diff().expected_file("emit-multiple-types.stderr").actual_file("multiple-types").run();

// Same as above, but using `-o`
rustc()
.input("test.rs")
.output("-")
.emit("asm,llvm-ir,dep-info,mir")
.stderr(File::create("multiple-types-option-o").unwrap())
.run_fail();
diff()
.expected_file("emit-multiple-types.stderr")
.actual_file("multiple-types-option-o")
.run();

// Test that `-o -` redirected to a file works correctly (#26719)
rustc().input("test.rs").output("-").stdout(File::create("out-stdout").unwrap()).run();
});
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
//@ build-pass
pub static FOO: [(); usize::MAX] = [(); usize::MAX];

fn main() {
let _ = &[(); usize::MAX];
Expand Down
32 changes: 32 additions & 0 deletions tests/ui/traits/assoc-type-hrtb-normalization-30472.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//@ check-pass
//! Tests that associated type projections normalize properly in the presence of HRTBs.
//! Original issue: <https://github.com/rust-lang/rust/issues/30472>

pub trait MyFrom<T> {}
impl<T> MyFrom<T> for T {}

pub trait MyInto<T> {}
impl<T, U> MyInto<U> for T where U: MyFrom<T> {}


pub trait A<'self_> {
type T;
}
pub trait B: for<'self_> A<'self_> {
// Originally caused the `type U = usize` example below to fail with a type mismatch error
type U: for<'self_> MyFrom<<Self as A<'self_>>::T>;
}


pub struct M;
impl<'self_> A<'self_> for M {
type T = usize;
}

impl B for M {
type U = usize;
}


fn main() {}
22 changes: 22 additions & 0 deletions tests/ui/traits/fn-pointer/hrtb-assoc-fn-traits-28994.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
//@ check-pass
//! Tests that a HRTB + FnOnce bound involving an associated type don't prevent
//! a function pointer from implementing `Fn` traits.
//! Test for <https://github.com/rust-lang/rust/issues/28994>
trait LifetimeToType<'a> {
type Out;
}

impl<'a> LifetimeToType<'a> for () {
type Out = &'a ();
}

fn id<'a>(val: &'a ()) -> <() as LifetimeToType<'a>>::Out {
val
}

fn assert_fn<F: for<'a> FnOnce(&'a ()) -> <() as LifetimeToType<'a>>::Out>(_func: F) { }

fn main() {
assert_fn(id);
}
14 changes: 14 additions & 0 deletions tests/ui/traits/hrtb-related-type-params-30867.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//@ check-pass
//! Tests that HRTB impl selection covers type parameters not directly related
//! to the trait.
//! Test for <https://github.com/rust-lang/rust/issues/30867>
#![crate_type = "lib"]

trait Unary<T> {}
impl<T, U, F: Fn(T) -> U> Unary<T> for F {}
fn unary<F: for<'a> Unary<&'a T>, T>() {}

pub fn test<F: for<'a> Fn(&'a i32) -> &'a i32>() {
unary::<F, i32>()
}
4 changes: 1 addition & 3 deletions tests/ui/utf8-bom.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
// This file has utf-8 BOM, it should be compiled normally without error.
//@ run-pass
//

// This file has utf-8 BOM, it should be compiled normally without error.

pub fn main() {}
1 change: 0 additions & 1 deletion triagebot.toml
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,6 @@ users_on_vacation = [
"jhpratt",
"jyn514",
"oli-obk",
"jieyouxu",
]

[assign.adhoc_groups]
Expand Down

0 comments on commit e6c46db

Please sign in to comment.