Skip to content

Commit 9078705

Browse files
committed
Auto merge of rust-lang#127207 - GuillaumeGomez:rollup-2hc83i2, r=GuillaumeGomez
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
2 parents 221e274 + 02e58d3 commit 9078705

File tree

29 files changed

+252
-150
lines changed

29 files changed

+252
-150
lines changed

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -2042,7 +2042,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
20422042
}
20432043
if block_num > 1 && found_semi {
20442044
err.span_suggestion_verbose(
2045-
span.shrink_to_lo(),
2045+
// use the span of the *whole* expr
2046+
self.tcx.hir().span(binding_hir_id).shrink_to_lo(),
20462047
"you might have meant to return this to infer its type parameters",
20472048
"return ",
20482049
Applicability::MaybeIncorrect,

library/core/src/time.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -620,13 +620,14 @@ impl Duration {
620620
/// Basic usage:
621621
///
622622
/// ```
623-
/// #![feature(duration_abs_diff)]
624623
/// use std::time::Duration;
625624
///
626625
/// assert_eq!(Duration::new(100, 0).abs_diff(Duration::new(80, 0)), Duration::new(20, 0));
627626
/// assert_eq!(Duration::new(100, 400_000_000).abs_diff(Duration::new(110, 0)), Duration::new(9, 600_000_000));
628627
/// ```
629-
#[unstable(feature = "duration_abs_diff", issue = "117618")]
628+
#[stable(feature = "duration_abs_diff", since = "CURRENT_RUSTC_VERSION")]
629+
#[rustc_const_stable(feature = "duration_abs_diff", since = "CURRENT_RUSTC_VERSION")]
630+
#[rustc_allow_const_fn_unstable(const_option)]
630631
#[must_use = "this returns the result of the operation, \
631632
without modifying the original"]
632633
#[inline]

library/core/tests/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#![feature(core_private_bignum)]
3131
#![feature(core_private_diy_float)]
3232
#![feature(dec2flt)]
33-
#![feature(duration_abs_diff)]
3433
#![feature(duration_consts_float)]
3534
#![feature(duration_constants)]
3635
#![feature(duration_constructors)]

src/bootstrap/src/core/build_steps/compile.rs

+31-28
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,10 @@ impl Step for Std {
161161
// This check is specific to testing std itself; see `test::Std` for more details.
162162
&& !self.force_recompile
163163
{
164+
let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });
164165
cp_rustc_component_to_ci_sysroot(
165166
builder,
166-
compiler,
167+
&sysroot,
167168
builder.config.ci_rust_std_contents(),
168169
);
169170
return;
@@ -797,12 +798,7 @@ impl Step for StartupObjects {
797798
}
798799
}
799800

800-
fn cp_rustc_component_to_ci_sysroot(
801-
builder: &Builder<'_>,
802-
compiler: Compiler,
803-
contents: Vec<String>,
804-
) {
805-
let sysroot = builder.ensure(Sysroot { compiler, force_recompile: false });
801+
fn cp_rustc_component_to_ci_sysroot(builder: &Builder<'_>, sysroot: &Path, contents: Vec<String>) {
806802
let ci_rustc_dir = builder.config.ci_rustc_dir();
807803

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

@@ -1634,31 +1624,44 @@ impl Step for Sysroot {
16341624
let sysroot_lib_rustlib_src_rust = sysroot_lib_rustlib_src.join("rust");
16351625
if let Err(e) = symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_src_rust) {
16361626
eprintln!(
1637-
"WARNING: creating symbolic link `{}` to `{}` failed with {}",
1627+
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
16381628
sysroot_lib_rustlib_src_rust.display(),
16391629
builder.src.display(),
16401630
e,
16411631
);
16421632
if builder.config.rust_remap_debuginfo {
16431633
eprintln!(
1644-
"WARNING: some `tests/ui` tests will fail when lacking `{}`",
1634+
"ERROR: some `tests/ui` tests will fail when lacking `{}`",
16451635
sysroot_lib_rustlib_src_rust.display(),
16461636
);
16471637
}
1638+
build_helper::exit!(1);
16481639
}
1649-
// Same for the rustc-src component.
1650-
let sysroot_lib_rustlib_rustcsrc = sysroot.join("lib/rustlib/rustc-src");
1651-
t!(fs::create_dir_all(&sysroot_lib_rustlib_rustcsrc));
1652-
let sysroot_lib_rustlib_rustcsrc_rust = sysroot_lib_rustlib_rustcsrc.join("rust");
1653-
if let Err(e) =
1654-
symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_rustcsrc_rust)
1655-
{
1656-
eprintln!(
1657-
"WARNING: creating symbolic link `{}` to `{}` failed with {}",
1658-
sysroot_lib_rustlib_rustcsrc_rust.display(),
1659-
builder.src.display(),
1660-
e,
1640+
1641+
// Unlike rust-src component, we have to handle rustc-src a bit differently.
1642+
// When using CI rustc, we copy rustc-src component from its sysroot,
1643+
// otherwise we handle it in a similar way what we do for rust-src above.
1644+
if builder.download_rustc() {
1645+
cp_rustc_component_to_ci_sysroot(
1646+
builder,
1647+
&sysroot,
1648+
builder.config.ci_rustc_dev_contents(),
16611649
);
1650+
} else {
1651+
let sysroot_lib_rustlib_rustcsrc = sysroot.join("lib/rustlib/rustc-src");
1652+
t!(fs::create_dir_all(&sysroot_lib_rustlib_rustcsrc));
1653+
let sysroot_lib_rustlib_rustcsrc_rust = sysroot_lib_rustlib_rustcsrc.join("rust");
1654+
if let Err(e) =
1655+
symlink_dir(&builder.config, &builder.src, &sysroot_lib_rustlib_rustcsrc_rust)
1656+
{
1657+
eprintln!(
1658+
"ERROR: creating symbolic link `{}` to `{}` failed with {}",
1659+
sysroot_lib_rustlib_rustcsrc_rust.display(),
1660+
builder.src.display(),
1661+
e,
1662+
);
1663+
build_helper::exit!(1);
1664+
}
16621665
}
16631666

16641667
sysroot

src/doc/style-guide/src/nightly.md

+12
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,15 @@ This chapter documents style and formatting for nightly-only syntax. The rest of
55
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.
66

77
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.
8+
9+
### `feature(precise_capturing)`
10+
11+
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`.
12+
13+
```
14+
fn foo() -> impl Sized + use<'a> {}
15+
16+
// is formatted analogously to:
17+
18+
fn foo() -> impl Sized + Use<'a> {}
19+
```

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

+4-4
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ impl CompletedProcess {
185185
/// Checks that `stdout` does not contain `unexpected`.
186186
#[track_caller]
187187
pub fn assert_stdout_not_contains<S: AsRef<str>>(&self, unexpected: S) -> &Self {
188-
assert_not_contains(&self.stdout_utf8(), unexpected.as_ref());
188+
assert_not_contains(&self.stdout_utf8(), unexpected);
189189
self
190190
}
191191

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

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

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

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,9 @@ pub fn read_dir<F: FnMut(&Path)>(dir: impl AsRef<Path>, mut callback: F) {
409409

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

422424
/// Check that `haystack` contains `needle`. Panic otherwise.
423425
#[track_caller]
424-
pub fn assert_contains(haystack: &str, needle: &str) {
426+
pub fn assert_contains<S1: AsRef<str>, S2: AsRef<str>>(haystack: S1, needle: S2) {
427+
let haystack = haystack.as_ref();
428+
let needle = needle.as_ref();
425429
if !haystack.contains(needle) {
426430
eprintln!("=== HAYSTACK ===");
427431
eprintln!("{}", haystack);
@@ -433,7 +437,9 @@ pub fn assert_contains(haystack: &str, needle: &str) {
433437

434438
/// Check that `haystack` does not contain `needle`. Panic otherwise.
435439
#[track_caller]
436-
pub fn assert_not_contains(haystack: &str, needle: &str) {
440+
pub fn assert_not_contains<S1: AsRef<str>, S2: AsRef<str>>(haystack: S1, needle: S2) {
441+
let haystack = haystack.as_ref();
442+
let needle = needle.as_ref();
437443
if haystack.contains(needle) {
438444
eprintln!("=== HAYSTACK ===");
439445
eprintln!("{}", haystack);

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

+7
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,13 @@ impl LlvmFilecheck {
180180
self.cmd.arg(path.as_ref());
181181
self
182182
}
183+
184+
/// `--input-file` option.
185+
pub fn input_file<P: AsRef<Path>>(&mut self, input_file: P) -> &mut Self {
186+
self.cmd.arg("--input-file");
187+
self.cmd.arg(input_file.as_ref());
188+
self
189+
}
183190
}
184191

185192
impl LlvmObjdump {

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ impl Rustc {
201201
}
202202

203203
/// Specify the target triple, or a path to a custom target json spec file.
204-
pub fn target(&mut self, target: &str) -> &mut Self {
204+
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
205+
let target = target.as_ref();
205206
self.cmd.arg(format!("--target={target}"));
206207
self
207208
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ impl Rustdoc {
104104
}
105105

106106
/// Specify the target triple, or a path to a custom target json spec file.
107-
pub fn target(&mut self, target: &str) -> &mut Self {
107+
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
108+
let target = target.as_ref();
108109
self.cmd.arg(format!("--target={target}"));
109110
self
110111
}

src/tools/tidy/src/allowed_run_make_makefiles.txt

-5
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ run-make/link-cfg/Makefile
8585
run-make/link-framework/Makefile
8686
run-make/link-path-order/Makefile
8787
run-make/linkage-attr-on-static/Makefile
88-
run-make/llvm-ident/Makefile
8988
run-make/long-linker-command-lines-cmd-exe/Makefile
9089
run-make/long-linker-command-lines/Makefile
9190
run-make/longjmp-across-rust/Makefile
@@ -175,8 +174,4 @@ run-make/track-pgo-dep-info/Makefile
175174
run-make/translation/Makefile
176175
run-make/type-mismatch-same-crate-name/Makefile
177176
run-make/unstable-flag-required/Makefile
178-
run-make/volatile-intrinsics/Makefile
179-
run-make/wasm-exceptions-nostd/Makefile
180-
run-make/wasm-override-linker/Makefile
181-
run-make/weird-output-filenames/Makefile
182177
run-make/x86_64-fortanix-unknown-sgx-lvi/Makefile

tests/run-make/comment-section/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121
.stdin("fn main() {}")
2222
.emit("link,obj")
2323
.arg("-Csave-temps")
24-
.target(&target)
24+
.target(target)
2525
.run();
2626

2727
// Check linked output has a `.comment` section with the expected content.

tests/run-make/compressed-debuginfo/rmake.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

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

8-
use run_make_support::{assert_contains, cmd, run_in_tmpdir, rustc};
8+
use run_make_support::{assert_contains, cmd, llvm_readobj, run_in_tmpdir, rustc};
99

1010
fn check_compression(compression: &str, to_find: &str) {
1111
run_in_tmpdir(|| {
@@ -19,12 +19,11 @@ fn check_compression(compression: &str, to_find: &str) {
1919
.run();
2020
let stderr = out.stderr_utf8();
2121
if stderr.is_empty() {
22-
// FIXME: `readelf` might need to be replaced with `llvm-readelf`.
23-
cmd("readelf").arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
22+
llvm_readobj().arg("-t").arg("foo.o").run().assert_stdout_contains(to_find);
2423
} else {
2524
assert_contains(
26-
&stderr,
27-
&format!("unknown debuginfo compression algorithm {compression}"),
25+
stderr,
26+
format!("unknown debuginfo compression algorithm {compression}"),
2827
);
2928
}
3029
});

tests/run-make/inaccessible-temp-dir/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn main() {
2828
// Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one,
2929
// so that it can't create `tmp`.
3030
rustc()
31-
.target(&target())
31+
.target(target())
3232
.input("program.rs")
3333
.arg("-Ztemps-dir=inaccessible/tmp")
3434
.run_fail()

tests/run-make/llvm-ident/Makefile

-19
This file was deleted.

tests/run-make/llvm-ident/rmake.rs

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//@ only-linux
2+
//@ ignore-cross-compile
3+
4+
use run_make_support::llvm::llvm_bin_dir;
5+
use run_make_support::{cmd, env_var, llvm_filecheck, read_dir, rustc, source_root};
6+
7+
use std::ffi::OsStr;
8+
9+
fn main() {
10+
// `-Ccodegen-units=16 -Copt-level=2` is used here to trigger thin LTO
11+
// across codegen units to test deduplication of the named metadata
12+
// (see `LLVMRustPrepareThinLTOImport` for details).
13+
rustc()
14+
.emit("link,obj")
15+
.arg("-")
16+
.arg("-Csave-temps")
17+
.codegen_units(16)
18+
.opt_level("2")
19+
.target(&env_var("TARGET"))
20+
.stdin("fn main(){}")
21+
.run();
22+
23+
// `llvm-dis` is used here since `--emit=llvm-ir` does not emit LLVM IR
24+
// for temporary outputs.
25+
let mut files = Vec::new();
26+
read_dir(".", |path| {
27+
if path.is_file() && path.extension().is_some_and(|ext| ext == OsStr::new("bc")) {
28+
files.push(path.to_path_buf());
29+
}
30+
});
31+
cmd(llvm_bin_dir().join("llvm-dis")).args(&files).run();
32+
33+
// Check LLVM IR files (including temporary outputs) have `!llvm.ident`
34+
// named metadata, reusing the related codegen test.
35+
let llvm_ident_path = source_root().join("tests/codegen/llvm-ident.rs");
36+
read_dir(".", |path| {
37+
if path.is_file() && path.extension().is_some_and(|ext| ext == OsStr::new("ll")) {
38+
llvm_filecheck().input_file(path).arg(&llvm_ident_path).run();
39+
}
40+
});
41+
}

tests/run-make/static-pie/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn test(compiler: &str) {
5151

5252
rustc()
5353
.input("test-aslr.rs")
54-
.target(&target())
54+
.target(target())
5555
.linker(compiler)
5656
.arg("-Clinker-flavor=gcc")
5757
.arg("-Ctarget-feature=+crt-static")

tests/run-make/volatile-intrinsics/Makefile

-10
This file was deleted.

0 commit comments

Comments
 (0)