Skip to content

Commit d84b903

Browse files
committed
Auto merge of #125294 - matthiaskrgr:rollup-w42c829, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #124948 (chore: Remove repeated words (extension of #124924)) - #124992 (Add example to IsTerminal::is_terminal) - #125279 (make `Debug` impl for `Term` simpler) - #125286 (Miri subtree update) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 1d1283e + 7a45322 commit d84b903

File tree

93 files changed

+1372
-650
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1372
-650
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -3426,9 +3426,9 @@ dependencies = [
34263426

34273427
[[package]]
34283428
name = "rustc-build-sysroot"
3429-
version = "0.4.7"
3429+
version = "0.5.2"
34303430
source = "registry+https://github.com/rust-lang/crates.io-index"
3431-
checksum = "ab1dbbd1bdf65fdac44c885f6cca147ba179108ce284b60a08ccc04b1f1dbac0"
3431+
checksum = "fa3ca63cc537c1cb69e4c2c0afc5fda2ccd36ac84c97d5a4ae05e69b1c834afb"
34323432
dependencies = [
34333433
"anyhow",
34343434
"rustc_version",

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -652,7 +652,7 @@ impl<'cx, 'tcx> MirBorrowckCtxt<'cx, 'tcx> {
652652
}
653653

654654
// FIXME: We make sure that this is a normal top-level binding,
655-
// but we could suggest `todo!()` for all uninitialized bindings in the pattern pattern
655+
// but we could suggest `todo!()` for all uninitialized bindings in the pattern
656656
if let hir::StmtKind::Let(hir::LetStmt { span, ty, init: None, pat, .. }) =
657657
&ex.kind
658658
&& let hir::PatKind::Binding(..) = pat.kind

compiler/rustc_hir_typeck/src/expr.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3112,7 +3112,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
31123112

31133113
let true_errors = ocx.select_where_possible();
31143114

3115-
// Do a leak check -- we can't really report report a useful error here,
3115+
// Do a leak check -- we can't really report a useful error here,
31163116
// but it at least avoids an ICE when the error has to do with higher-ranked
31173117
// lifetimes.
31183118
self.leak_check(outer_universe, Some(snapshot))?;

compiler/rustc_lint/src/non_local_def.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ declare_lint! {
3838
///
3939
/// Creating non-local definitions go against expectation and can create discrepancies
4040
/// in tooling. It should be avoided. It may become deny-by-default in edition 2024
41-
/// and higher, see see the tracking issue <https://github.com/rust-lang/rust/issues/120363>.
41+
/// and higher, see the tracking issue <https://github.com/rust-lang/rust/issues/120363>.
4242
///
4343
/// An `impl` definition is non-local if it is nested inside an item and neither
4444
/// the type nor the trait are at the same nesting level as the `impl` block.

compiler/rustc_middle/src/ty/mod.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -536,14 +536,10 @@ unsafe impl<'tcx> Sync for Term<'tcx> where &'tcx (Ty<'tcx>, Const<'tcx>): Sync
536536

537537
impl Debug for Term<'_> {
538538
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
539-
let data = if let Some(ty) = self.ty() {
540-
format!("Term::Ty({ty:?})")
541-
} else if let Some(ct) = self.ct() {
542-
format!("Term::Ct({ct:?})")
543-
} else {
544-
unreachable!()
545-
};
546-
f.write_str(&data)
539+
match self.unpack() {
540+
TermKind::Ty(ty) => write!(f, "Term::Ty({ty:?})"),
541+
TermKind::Const(ct) => write!(f, "Term::Const({ct:?})"),
542+
}
547543
}
548544
}
549545

compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ fn trait_object_ty<'tcx>(tcx: TyCtxt<'tcx>, poly_trait_ref: ty::PolyTraitRef<'tc
269269
/// if a function is member of the group derived from this type id. Therefore, in the first call to
270270
/// typeid_for_fnabi (when type ids are attached to functions and methods), it can only include at
271271
/// most as much information that would be available in the second call (i.e., during code
272-
/// generation at call sites); otherwise, the type ids would not not match.
272+
/// generation at call sites); otherwise, the type ids would not match.
273273
///
274274
/// For this, it:
275275
///

library/portable-simd/crates/core_simd/src/ops.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ macro_rules! for_base_types {
122122
#[inline]
123123
#[must_use = "operator returns a new vector without mutating the inputs"]
124124
// TODO: only useful for int Div::div, but we hope that this
125-
// will essentially always always get inlined anyway.
125+
// will essentially always get inlined anyway.
126126
#[track_caller]
127127
fn $call(self, rhs: Self) -> Self::Output {
128128
$macro_impl!(self, rhs, $inner, $scalar)

library/std/src/io/stdio.rs

+34
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,41 @@ pub trait IsTerminal: crate::sealed::Sealed {
11611161
/// starting with `msys-` or `cygwin-` and ending in `-pty` will be considered terminals.
11621162
/// Note that this [may change in the future][changes].
11631163
///
1164+
/// # Examples
1165+
///
1166+
/// An example of a type for which `IsTerminal` is implemented is [`Stdin`]:
1167+
///
1168+
/// ```no_run
1169+
/// use std::io::{self, IsTerminal, Write};
1170+
///
1171+
/// fn main() -> io::Result<()> {
1172+
/// let stdin = io::stdin();
1173+
///
1174+
/// // Indicate that the user is prompted for input, if this is a terminal.
1175+
/// if stdin.is_terminal() {
1176+
/// print!("> ");
1177+
/// io::stdout().flush()?;
1178+
/// }
1179+
///
1180+
/// let mut name = String::new();
1181+
/// let _ = stdin.read_line(&mut name)?;
1182+
///
1183+
/// println!("Hello {}", name.trim_end());
1184+
///
1185+
/// Ok(())
1186+
/// }
1187+
/// ```
1188+
///
1189+
/// The example can be run in two ways:
1190+
///
1191+
/// - If you run this example by piping some text to it, e.g. `echo "foo" | path/to/executable`
1192+
/// it will print: `Hello foo`.
1193+
/// - If you instead run the example interactively by running the executable directly, it will
1194+
/// panic with the message "Expected input to be piped to the process".
1195+
///
1196+
///
11641197
/// [changes]: io#platform-specific-behavior
1198+
/// [`Stdin`]: crate::io::Stdin
11651199
#[stable(feature = "is_terminal", since = "1.70.0")]
11661200
fn is_terminal(&self) -> bool;
11671201
}

src/tools/clippy/clippy_lints/src/methods/needless_collect.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ pub(super) fn check<'tcx>(
127127
}
128128
}
129129

130-
/// checks for for collecting into a (generic) method or function argument
130+
/// checks for collecting into a (generic) method or function argument
131131
/// taking an `IntoIterator`
132132
fn check_collect_into_intoiterator<'tcx>(
133133
cx: &LateContext<'tcx>,

src/tools/clippy/tests/ui/ptr_arg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ mod issue_9218 {
282282
todo!()
283283
}
284284

285-
// These two's return types don't use use 'a so it's not okay
285+
// These two's return types don't use 'a so it's not okay
286286
fn cow_bad_ret_ty_1<'a>(input: &'a Cow<'a, str>) -> &'static str {
287287
//~^ ERROR: using a reference to `Cow` is not recommended
288288
todo!()

src/tools/compiletest/src/common.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub struct Config {
250250
/// Only run tests that match these filters
251251
pub filters: Vec<String>,
252252

253-
/// Skip tests tests matching these substrings. Corresponds to
253+
/// Skip tests matching these substrings. Corresponds to
254254
/// `test::TestOpts::skip`. `filter_exact` does not apply to these flags.
255255
pub skip: Vec<String>,
256256

@@ -381,7 +381,7 @@ pub struct Config {
381381
/// Whether to rerun tests even if the inputs are unchanged.
382382
pub force_rerun: bool,
383383

384-
/// Only rerun the tests that result has been modified accoring to Git status
384+
/// Only rerun the tests that result has been modified according to Git status
385385
pub only_modified: bool,
386386

387387
pub target_cfgs: OnceLock<TargetCfgs>,

src/tools/compiletest/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ fn is_android_gdb_target(target: &str) -> bool {
950950
)
951951
}
952952

953-
/// Returns `true` if the given target is a MSVC target for the purpouses of CDB testing.
953+
/// Returns `true` if the given target is a MSVC target for the purposes of CDB testing.
954954
fn is_pc_windows_msvc_target(target: &str) -> bool {
955955
target.ends_with("-pc-windows-msvc")
956956
}

src/tools/jsondoclint/src/validator.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ const LOCAL_CRATE_ID: u32 = 0;
2121
/// it is well formed. This involves calling `check_*` functions on
2222
/// fields of that item, and `add_*` functions on [`Id`]s.
2323
/// - `add_*`: These add an [`Id`] to the worklist, after validating it to check if
24-
/// the `Id` is a kind expected in this suituation.
24+
/// the `Id` is a kind expected in this situation.
2525
#[derive(Debug)]
2626
pub struct Validator<'a> {
2727
pub(crate) errs: Vec<Error>,

src/tools/lld-wrapper/src/main.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Script to invoke the bundled rust-lld with the correct flavor.
22
//!
3-
//! lld supports multiple command line interfaces. If `-flavor <flavor>` are passed as the first
3+
//! `lld` supports multiple command line interfaces. If `-flavor <flavor>` are passed as the first
44
//! two arguments the `<flavor>` command line interface is used to process the remaining arguments.
55
//! If no `-flavor` argument is present the flavor is determined by the executable name.
66
//!

src/tools/miri/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ tex/*/out
55
*.out
66
*.rs.bk
77
.vscode
8+
.helix
89
*.mm_profdata
910
perf.data
1011
perf.data.old

src/tools/miri/cargo-miri/Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,9 @@ dependencies = [
178178

179179
[[package]]
180180
name = "rustc-build-sysroot"
181-
version = "0.4.7"
181+
version = "0.5.2"
182182
source = "registry+https://github.com/rust-lang/crates.io-index"
183-
checksum = "ab1dbbd1bdf65fdac44c885f6cca147ba179108ce284b60a08ccc04b1f1dbac0"
183+
checksum = "fa3ca63cc537c1cb69e4c2c0afc5fda2ccd36ac84c97d5a4ae05e69b1c834afb"
184184
dependencies = [
185185
"anyhow",
186186
"rustc_version",

src/tools/miri/cargo-miri/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ directories = "5"
1818
rustc_version = "0.4"
1919
serde_json = "1.0.40"
2020
cargo_metadata = "0.18.0"
21-
rustc-build-sysroot = "0.4.6"
21+
rustc-build-sysroot = "0.5.2"
2222

2323
# Enable some feature flags that dev-dependencies need but dependencies
2424
# do not. This makes `./miri install` after `./miri build` faster.

src/tools/miri/cargo-miri/src/setup.rs

+44-43
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
33
use std::env;
44
use std::ffi::OsStr;
5-
use std::fmt::Write;
65
use std::path::PathBuf;
76
use std::process::{self, Command};
87

9-
use rustc_build_sysroot::{BuildMode, SysrootBuilder, SysrootConfig};
8+
use rustc_build_sysroot::{BuildMode, SysrootBuilder, SysrootConfig, SysrootStatus};
109
use rustc_version::VersionMeta;
1110

1211
use crate::util::*;
@@ -24,6 +23,7 @@ pub fn setup(
2423
let only_setup = matches!(subcommand, MiriCommand::Setup);
2524
let ask_user = !only_setup;
2625
let print_sysroot = only_setup && has_arg_flag("--print-sysroot"); // whether we just print the sysroot path
26+
let show_setup = only_setup && !print_sysroot;
2727
if !only_setup {
2828
if let Some(sysroot) = std::env::var_os("MIRI_SYSROOT") {
2929
// Skip setup step if MIRI_SYSROOT is explicitly set, *unless* we are `cargo miri setup`.
@@ -115,18 +115,16 @@ pub fn setup(
115115
// `config.toml`.
116116
command.env("RUSTC_WRAPPER", "");
117117

118-
if only_setup && !print_sysroot {
118+
if show_setup {
119119
// Forward output. Even make it verbose, if requested.
120+
command.stdout(process::Stdio::inherit());
121+
command.stderr(process::Stdio::inherit());
120122
for _ in 0..verbose {
121123
command.arg("-v");
122124
}
123125
if quiet {
124126
command.arg("--quiet");
125127
}
126-
} else {
127-
// Suppress output.
128-
command.stdout(process::Stdio::null());
129-
command.stderr(process::Stdio::null());
130128
}
131129

132130
command
@@ -137,49 +135,52 @@ pub fn setup(
137135
// not apply `RUSTFLAGS` to the sysroot either.
138136
let rustflags = &["-Cdebug-assertions=off", "-Coverflow-checks=on"];
139137

140-
// Do the build.
141-
if print_sysroot || quiet {
142-
// Be silent.
143-
} else {
144-
let mut msg = String::new();
145-
write!(msg, "Preparing a sysroot for Miri (target: {target})").unwrap();
146-
if verbose > 0 {
147-
write!(msg, " in {}", sysroot_dir.display()).unwrap();
148-
}
149-
write!(msg, "...").unwrap();
150-
if only_setup {
151-
// We want to be explicit.
152-
eprintln!("{msg}");
153-
} else {
154-
// We want to be quiet, but still let the user know that something is happening.
155-
eprint!("{msg} ");
138+
let mut after_build_output = String::new(); // what should be printed when the build is done.
139+
let notify = || {
140+
if !quiet {
141+
eprint!("Preparing a sysroot for Miri (target: {target})");
142+
if verbose > 0 {
143+
eprint!(" in {}", sysroot_dir.display());
144+
}
145+
if show_setup {
146+
// Cargo will print things, so we need to finish this line.
147+
eprintln!("...");
148+
after_build_output = format!(
149+
"A sysroot for Miri is now available in `{}`.\n",
150+
sysroot_dir.display()
151+
);
152+
} else {
153+
// Keep all output on a single line.
154+
eprint!("... ");
155+
after_build_output = format!("done\n");
156+
}
156157
}
157-
}
158-
SysrootBuilder::new(&sysroot_dir, target)
158+
};
159+
160+
// Do the build.
161+
let status = SysrootBuilder::new(&sysroot_dir, target)
159162
.build_mode(BuildMode::Check)
160163
.rustc_version(rustc_version.clone())
161164
.sysroot_config(sysroot_config)
162165
.rustflags(rustflags)
163166
.cargo(cargo_cmd)
164-
.build_from_source(&rust_src)
165-
.unwrap_or_else(|err| {
166-
if print_sysroot {
167-
show_error!("failed to build sysroot")
168-
} else if only_setup {
169-
show_error!("failed to build sysroot: {err:?}")
170-
} else {
171-
show_error!(
172-
"failed to build sysroot; run `cargo miri setup` to see the error details"
173-
)
174-
}
175-
});
176-
if print_sysroot || quiet {
177-
// Be silent.
178-
} else if only_setup {
179-
eprintln!("A sysroot for Miri is now available in `{}`.", sysroot_dir.display());
180-
} else {
181-
eprintln!("done");
167+
.when_build_required(notify)
168+
.build_from_source(&rust_src);
169+
match status {
170+
Ok(SysrootStatus::AlreadyCached) =>
171+
if !quiet && show_setup {
172+
eprintln!(
173+
"A sysroot for Miri is already available in `{}`.",
174+
sysroot_dir.display()
175+
);
176+
},
177+
Ok(SysrootStatus::SysrootBuilt) => {
178+
// Print what `notify` prepared.
179+
eprint!("{after_build_output}");
180+
}
181+
Err(err) => show_error!("failed to build sysroot: {err:?}"),
182182
}
183+
183184
if print_sysroot {
184185
// Print just the sysroot and nothing else to stdout; this way we do not need any escaping.
185186
println!("{}", sysroot_dir.display());

src/tools/miri/cargo-miri/src/util.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ pub fn get_target_dir(meta: &Metadata) -> PathBuf {
269269
output
270270
}
271271

272-
/// Determines where the sysroot of this exeuction is
272+
/// Determines where the sysroot of this execution is
273273
///
274274
/// Either in a user-specified spot by an envar, or in a default cache location.
275275
pub fn get_sysroot_dir() -> PathBuf {

src/tools/miri/ci/ci.sh

+10-10
Original file line numberDiff line numberDiff line change
@@ -144,16 +144,16 @@ case $HOST_TARGET in
144144
TEST_TARGET=arm-unknown-linux-gnueabi run_tests
145145
TEST_TARGET=s390x-unknown-linux-gnu run_tests # big-endian architecture of choice
146146
# Partially supported targets (tier 2)
147-
VERY_BASIC="integer vec string btreemap" # common things we test on all of them (if they have std), requires no target-specific shims
148-
BASIC="$VERY_BASIC hello hashmap alloc align" # ensures we have the shims for stdout and basic data structures
149-
TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus
150-
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC panic/panic concurrency/simple atomic threadname libc-mem libc-misc libc-random libc-time fs env num_cpus
151-
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random
152-
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $VERY_BASIC hello panic/panic concurrency/simple pthread-sync libc-mem libc-misc libc-random
153-
TEST_TARGET=aarch64-linux-android run_tests_minimal $VERY_BASIC hello panic/panic
154-
TEST_TARGET=wasm32-wasi run_tests_minimal $VERY_BASIC wasm
155-
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal $VERY_BASIC wasm
156-
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
147+
BASIC="empty_main integer vec string btreemap hello hashmap heap_alloc align" # ensures we have the basics: stdout/stderr, system allocator, randomness (for HashMap initialization)
148+
UNIX="panic/panic panic/unwind concurrency/simple atomic libc-mem libc-misc libc-random env num_cpus" # the things that are very similar across all Unixes, and hence easily supported there
149+
TEST_TARGET=x86_64-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname libc-time fs
150+
TEST_TARGET=i686-unknown-freebsd run_tests_minimal $BASIC $UNIX threadname libc-time fs
151+
TEST_TARGET=x86_64-unknown-illumos run_tests_minimal $BASIC $UNIX pthread-sync
152+
TEST_TARGET=x86_64-pc-solaris run_tests_minimal $BASIC $UNIX pthread-sync
153+
TEST_TARGET=aarch64-linux-android run_tests_minimal $BASIC $UNIX
154+
TEST_TARGET=wasm32-wasip2 run_tests_minimal empty_main wasm heap_alloc libc-mem
155+
TEST_TARGET=wasm32-unknown-unknown run_tests_minimal empty_main wasm
156+
TEST_TARGET=thumbv7em-none-eabihf run_tests_minimal no_std
157157
# Custom target JSON file
158158
TEST_TARGET=tests/avr.json MIRI_NO_STD=1 run_tests_minimal no_std
159159
;;

0 commit comments

Comments
 (0)