Skip to content

Commit

Permalink
Auto merge of rust-lang#127207 - GuillaumeGomez:rollup-2hc83i2, r=Gui…
Browse files Browse the repository at this point in the history
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#126753 (Add nightly style guide section for `precise_capturing` `use<>` syntax)
 - rust-lang#126880 (Migrate `volatile-intrinsics`, `weird-output-filenames`, `wasm-override-linker`, `wasm-exceptions-nostd` to `rmake`)
 - rust-lang#126941 (Migrate `run-make/llvm-ident` to `rmake.rs`)
 - rust-lang#127128 (Stabilize `duration_abs_diff`)
 - rust-lang#127129 (Use full expr span for return suggestion on type error/ambiguity)
 - rust-lang#127188 ( improve the way bootstrap handles rustlib components)
 - rust-lang#127201 (Improve run-make-support API)

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Jul 1, 2024
2 parents 221e274 + 02e58d3 commit 9078705
Show file tree
Hide file tree
Showing 29 changed files with 252 additions and 150 deletions.
3 changes: 2 additions & 1 deletion compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2042,7 +2042,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
}
if block_num > 1 && found_semi {
err.span_suggestion_verbose(
span.shrink_to_lo(),
// use the span of the *whole* expr
self.tcx.hir().span(binding_hir_id).shrink_to_lo(),
"you might have meant to return this to infer its type parameters",
"return ",
Applicability::MaybeIncorrect,
Expand Down
5 changes: 3 additions & 2 deletions library/core/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -620,13 +620,14 @@ impl Duration {
/// Basic usage:
///
/// ```
/// #![feature(duration_abs_diff)]
/// use std::time::Duration;
///
/// assert_eq!(Duration::new(100, 0).abs_diff(Duration::new(80, 0)), Duration::new(20, 0));
/// assert_eq!(Duration::new(100, 400_000_000).abs_diff(Duration::new(110, 0)), Duration::new(9, 600_000_000));
/// ```
#[unstable(feature = "duration_abs_diff", issue = "117618")]
#[stable(feature = "duration_abs_diff", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "duration_abs_diff", since = "CURRENT_RUSTC_VERSION")]
#[rustc_allow_const_fn_unstable(const_option)]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
Expand Down
1 change: 0 additions & 1 deletion library/core/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#![feature(core_private_bignum)]
#![feature(core_private_diy_float)]
#![feature(dec2flt)]
#![feature(duration_abs_diff)]
#![feature(duration_consts_float)]
#![feature(duration_constants)]
#![feature(duration_constructors)]
Expand Down
59 changes: 31 additions & 28 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,10 @@ impl Step for Std {
// This check is specific to testing std itself; see `test::Std` for more details.
&& !self.force_recompile
{
let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });
cp_rustc_component_to_ci_sysroot(
builder,
compiler,
&sysroot,
builder.config.ci_rust_std_contents(),
);
return;
Expand Down Expand Up @@ -797,12 +798,7 @@ impl Step for StartupObjects {
}
}

fn cp_rustc_component_to_ci_sysroot(
builder: &Builder<'_>,
compiler: Compiler,
contents: Vec<String>,
) {
let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });
fn cp_rustc_component_to_ci_sysroot(builder: &Builder<'_>, sysroot: &Path, contents: Vec<String>) {
let ci_rustc_dir = builder.config.ci_rustc_dir();

for file in contents {
Expand Down Expand Up @@ -881,13 +877,7 @@ impl Step for Rustc {
// NOTE: the ABI of the beta compiler is different from the ABI of the downloaded compiler,
// so its artifacts can't be reused.
if builder.download_rustc() && compiler.stage != 0 {
// Copy the existing artifacts instead of rebuilding them.
// NOTE: this path is only taken for tools linking to rustc-dev (including ui-fulldeps tests).
cp_rustc_component_to_ci_sysroot(
builder,
compiler,
builder.config.ci_rustc_dev_contents(),
);
builder.ensure(Sysroot { compiler, force_recompile: false });
return compiler.stage;
}

Expand Down Expand Up @@ -1634,31 +1624,44 @@ impl Step for Sysroot {
let sysroot_lib_rustlib_src_rust = sysroot_lib_rustlib_src.join("rust");
if let Err(e) = symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_src_rust) {
eprintln!(
"WARNING: creating symbolic link `{}` to `{}` failed with {}",
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
sysroot_lib_rustlib_src_rust.display(),
builder.src.display(),
e,
);
if builder.config.rust_remap_debuginfo {
eprintln!(
"WARNING: some `tests/ui` tests will fail when lacking `{}`",
"ERROR: some `tests/ui` tests will fail when lacking `{}`",
sysroot_lib_rustlib_src_rust.display(),
);
}
build_helper::exit!(1);
}
// Same for the rustc-src component.
let sysroot_lib_rustlib_rustcsrc = sysroot.join("lib/rustlib/rustc-src");
t!(fs::create_dir_all(&sysroot_lib_rustlib_rustcsrc));
let sysroot_lib_rustlib_rustcsrc_rust = sysroot_lib_rustlib_rustcsrc.join("rust");
if let Err(e) =
symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_rustcsrc_rust)
{
eprintln!(
"WARNING: creating symbolic link `{}` to `{}` failed with {}",
sysroot_lib_rustlib_rustcsrc_rust.display(),
builder.src.display(),
e,

// Unlike rust-src component, we have to handle rustc-src a bit differently.
// When using CI rustc, we copy rustc-src component from its sysroot,
// otherwise we handle it in a similar way what we do for rust-src above.
if builder.download_rustc() {
cp_rustc_component_to_ci_sysroot(
builder,
&sysroot,
builder.config.ci_rustc_dev_contents(),
);
} else {
let sysroot_lib_rustlib_rustcsrc = sysroot.join("lib/rustlib/rustc-src");
t!(fs::create_dir_all(&sysroot_lib_rustlib_rustcsrc));
let sysroot_lib_rustlib_rustcsrc_rust = sysroot_lib_rustlib_rustcsrc.join("rust");
if let Err(e) =
symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_rustcsrc_rust)
{
eprintln!(
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
sysroot_lib_rustlib_rustcsrc_rust.display(),
builder.src.display(),
e,
);
build_helper::exit!(1);
}
}

sysroot
Expand Down
12 changes: 12 additions & 0 deletions src/doc/style-guide/src/nightly.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,15 @@ This chapter documents style and formatting for nightly-only syntax. The rest of
Style and formatting for nightly-only syntax should be removed from this chapter and integrated into the appropriate sections of the style guide at the time of stabilization.

There is no guarantee of the stability of this chapter in contrast to the rest of the style guide. Refer to the style team policy for nightly formatting procedure regarding breaking changes to this chapter.

### `feature(precise_capturing)`

A `use<'a, T>` precise capturing bound is formatted as if it were a single path segment with non-turbofished angle-bracketed args, like a trait bound whose identifier is `use`.

```
fn foo() -> impl Sized + use<'a> {}
// is formatted analogously to:
fn foo() -> impl Sized + Use<'a> {}
```
8 changes: 4 additions & 4 deletions src/tools/run-make-support/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,14 @@ impl CompletedProcess {
/// Checks that `stdout` does not contain `unexpected`.
#[track_caller]
pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
assert_not_contains(&self.stdout_utf8(), unexpected.as_ref());
assert_not_contains(&self.stdout_utf8(), unexpected);
self
}

/// Checks that `stdout` contains `expected`.
#[track_caller]
pub fn assert_stdout_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
assert_contains(&self.stdout_utf8(), expected.as_ref());
assert_contains(&self.stdout_utf8(), expected);
self
}

Expand All @@ -206,14 +206,14 @@ impl CompletedProcess {
/// Checks that `stderr` contains `expected`.
#[track_caller]
pub fn assert_stderr_contains<S: AsRef<str>>(&self, expected: S) -> &Self {
assert_contains(&self.stderr_utf8(), expected.as_ref());
assert_contains(&self.stderr_utf8(), expected);
self
}

/// Checks that `stderr` does not contain `unexpected`.
#[track_caller]
pub fn assert_stderr_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
assert_not_contains(&self.stdout_utf8(), unexpected.as_ref());
assert_not_contains(&self.stdout_utf8(), unexpected);
self
}

Expand Down
12 changes: 9 additions & 3 deletions src/tools/run-make-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ pub fn read_dir<F: FnMut(&Path)>(dir: impl AsRef<Path>, mut callback: F) {

/// Check that `actual` is equal to `expected`. Panic otherwise.
#[track_caller]
pub fn assert_equals(actual: &str, expected: &str) {
pub fn assert_equals<S1: AsRef<str>, S2: AsRef<str>>(actual: S1, expected: S2) {
let actual = actual.as_ref();
let expected = expected.as_ref();
if actual != expected {
eprintln!("=== ACTUAL TEXT ===");
eprintln!("{}", actual);
Expand All @@ -421,7 +423,9 @@ pub fn assert_equals(actual: &str, expected: &str) {

/// Check that `haystack` contains `needle`. Panic otherwise.
#[track_caller]
pub fn assert_contains(haystack: &str, needle: &str) {
pub fn assert_contains<S1: AsRef<str>, S2: AsRef<str>>(haystack: S1, needle: S2) {
let haystack = haystack.as_ref();
let needle = needle.as_ref();
if !haystack.contains(needle) {
eprintln!("=== HAYSTACK ===");
eprintln!("{}", haystack);
Expand All @@ -433,7 +437,9 @@ pub fn assert_contains(haystack: &str, needle: &str) {

/// Check that `haystack` does not contain `needle`. Panic otherwise.
#[track_caller]
pub fn assert_not_contains(haystack: &str, needle: &str) {
pub fn assert_not_contains<S1: AsRef<str>, S2: AsRef<str>>(haystack: S1, needle: S2) {
let haystack = haystack.as_ref();
let needle = needle.as_ref();
if haystack.contains(needle) {
eprintln!("=== HAYSTACK ===");
eprintln!("{}", haystack);
Expand Down
7 changes: 7 additions & 0 deletions src/tools/run-make-support/src/llvm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,13 @@ impl LlvmFilecheck {
self.cmd.arg(path.as_ref());
self
}

/// `--input-file` option.
pub fn input_file<P: AsRef<Path>>(&mut self, input_file: P) -> &mut Self {
self.cmd.arg("--input-file");
self.cmd.arg(input_file.as_ref());
self
}
}

impl LlvmObjdump {
Expand Down
3 changes: 2 additions & 1 deletion src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ impl Rustc {
}

/// Specify the target triple, or a path to a custom target json spec file.
pub fn target(&mut self, target: &str) -> &mut Self {
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
let target = target.as_ref();
self.cmd.arg(format!("--target={target}"));
self
}
Expand Down
3 changes: 2 additions & 1 deletion src/tools/run-make-support/src/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ impl Rustdoc {
}

/// Specify the target triple, or a path to a custom target json spec file.
pub fn target(&mut self, target: &str) -> &mut Self {
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
let target = target.as_ref();
self.cmd.arg(format!("--target={target}"));
self
}
Expand Down
5 changes: 0 additions & 5 deletions src/tools/tidy/src/allowed_run_make_makefiles.txt
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ run-make/link-cfg/Makefile
run-make/link-framework/Makefile
run-make/link-path-order/Makefile
run-make/linkage-attr-on-static/Makefile
run-make/llvm-ident/Makefile
run-make/long-linker-command-lines-cmd-exe/Makefile
run-make/long-linker-command-lines/Makefile
run-make/longjmp-across-rust/Makefile
Expand Down Expand Up @@ -175,8 +174,4 @@ run-make/track-pgo-dep-info/Makefile
run-make/translation/Makefile
run-make/type-mismatch-same-crate-name/Makefile
run-make/unstable-flag-required/Makefile
run-make/volatile-intrinsics/Makefile
run-make/wasm-exceptions-nostd/Makefile
run-make/wasm-override-linker/Makefile
run-make/weird-output-filenames/Makefile
run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile
2 changes: 1 addition & 1 deletion tests/run-make/comment-section/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
.stdin("fn main() {}")
.emit("link,obj")
.arg("-Csave-temps")
.target(&target)
.target(target)
.run();

// Check linked output has a `.comment` section with the expected content.
Expand Down
9 changes: 4 additions & 5 deletions tests/run-make/compressed-debuginfo/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

// FIXME: This test isn't comprehensive and isn't covering all possible combinations.

use run_make_support::{assert_contains, cmd, run_in_tmpdir, rustc};
use run_make_support::{assert_contains, cmd, llvm_readobj, run_in_tmpdir, rustc};

fn check_compression(compression: &str, to_find: &str) {
run_in_tmpdir(|| {
Expand All @@ -19,12 +19,11 @@ fn check_compression(compression: &str, to_find: &str) {
.run();
let stderr = out.stderr_utf8();
if stderr.is_empty() {
// FIXME: `readelf` might need to be replaced with `llvm-readelf`.
cmd("readelf").arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
llvm_readobj().arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
} else {
assert_contains(
&stderr,
&format!("unknown debuginfo compression algorithm {compression}"),
stderr,
format!("unknown debuginfo compression algorithm {compression}"),
);
}
});
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/inaccessible-temp-dir/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() {
// Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one,
// so that it can't create `tmp`.
rustc()
.target(&target())
.target(target())
.input("program.rs")
.arg("-Ztemps-dir=inaccessible/tmp")
.run_fail()
Expand Down
19 changes: 0 additions & 19 deletions tests/run-make/llvm-ident/Makefile

This file was deleted.

41 changes: 41 additions & 0 deletions tests/run-make/llvm-ident/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//@ only-linux
//@ ignore-cross-compile

use run_make_support::llvm::llvm_bin_dir;
use run_make_support::{cmd, env_var, llvm_filecheck, read_dir, rustc, source_root};

use std::ffi::OsStr;

fn main() {
// `-Ccodegen-units=16 -Copt-level=2` is used here to trigger thin LTO
// across codegen units to test deduplication of the named metadata
// (see `LLVMRustPrepareThinLTOImport` for details).
rustc()
.emit("link,obj")
.arg("-")
.arg("-Csave-temps")
.codegen_units(16)
.opt_level("2")
.target(&env_var("TARGET"))
.stdin("fn main(){}")
.run();

// `llvm-dis` is used here since `--emit=llvm-ir` does not emit LLVM IR
// for temporary outputs.
let mut files = Vec::new();
read_dir(".", |path| {
if path.is_file() && path.extension().is_some_and(|ext| ext == OsStr::new("bc")) {
files.push(path.to_path_buf());
}
});
cmd(llvm_bin_dir().join("llvm-dis")).args(&files).run();

// Check LLVM IR files (including temporary outputs) have `!llvm.ident`
// named metadata, reusing the related codegen test.
let llvm_ident_path = source_root().join("tests/codegen/llvm-ident.rs");
read_dir(".", |path| {
if path.is_file() && path.extension().is_some_and(|ext| ext == OsStr::new("ll")) {
llvm_filecheck().input_file(path).arg(&llvm_ident_path).run();
}
});
}
2 changes: 1 addition & 1 deletion tests/run-make/static-pie/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn test(compiler: &str) {

rustc()
.input("test-aslr.rs")
.target(&target())
.target(target())
.linker(compiler)
.arg("-Clinker-flavor=gcc")
.arg("-Ctarget-feature=+crt-static")
Expand Down
10 changes: 0 additions & 10 deletions tests/run-make/volatile-intrinsics/Makefile

This file was deleted.

Loading

0 comments on commit 9078705

Please sign in to comment.