Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 19ebdce

Browse files
committed
Auto merge of rust-lang#128883 - matthiaskrgr:rollup-mkzi7my, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang#128815 (Add `Steal::is_stolen()`) - rust-lang#128817 (VxWorks code refactored ) - rust-lang#128822 (add `builder-config` into tarball sources) - rust-lang#128838 (rustdoc: do not run doctests with invalid langstrings) - rust-lang#128852 (use stable sort to sort multipart diagnostics) - rust-lang#128859 (Fix the name of signal 19 in library/std/src/sys/pal/unix/process/process_unix/tests.rs for mips/sparc linux) - rust-lang#128864 (Use `SourceMap::end_point` instead of `- BytePos(1)` in arg removal suggestion) - rust-lang#128865 (Ensure let stmt compound assignment removal suggestion respect codepoint boundaries) - rust-lang#128874 (Disable verbose bootstrap command failure logging by default) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 899eb03 + cea3b42 commit 19ebdce

File tree

20 files changed

+218
-50
lines changed

20 files changed

+218
-50
lines changed

compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1124,8 +1124,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
11241124
err.multipart_suggestion(
11251125
"consider moving the expression out of the loop so it is only moved once",
11261126
vec![
1127-
(parent.span, "value".to_string()),
11281127
(span.shrink_to_lo(), format!("let mut value = {value};{indent}")),
1128+
(parent.span, "value".to_string()),
11291129
],
11301130
Applicability::MaybeIncorrect,
11311131
);

compiler/rustc_data_structures/src/steal.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ impl<T> Steal<T> {
5151
let value = value_ref.take();
5252
value.expect("attempt to steal from stolen value")
5353
}
54+
55+
/// Writers of rustc drivers often encounter stealing issues. This function makes it possible to
56+
/// handle these errors gracefully.
57+
///
58+
/// This should not be used within rustc as it leaks information not tracked
59+
/// by the query system, breaking incremental compilation.
60+
pub fn is_stolen(&self) -> bool {
61+
self.value.borrow().is_none()
62+
}
5463
}
5564

5665
impl<CTX, T: HashStable<CTX>> HashStable<CTX> for Steal<T> {

compiler/rustc_errors/src/diagnostic.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,8 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
920920
applicability: Applicability,
921921
style: SuggestionStyle,
922922
) -> &mut Self {
923-
suggestion.sort_unstable();
924-
suggestion.dedup_by(|(s1, m1), (s2, m2)| s1.source_equal(*s2) && m1 == m2);
923+
let mut seen = crate::FxHashSet::default();
924+
suggestion.retain(|(span, msg)| seen.insert((span.lo(), span.hi(), msg.clone())));
925925

926926
let parts = suggestion
927927
.into_iter()

compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt};
2222
use rustc_middle::{bug, span_bug};
2323
use rustc_session::Session;
2424
use rustc_span::symbol::{kw, Ident};
25-
use rustc_span::{sym, BytePos, Span, DUMMY_SP};
25+
use rustc_span::{sym, Span, DUMMY_SP};
2626
use rustc_trait_selection::error_reporting::infer::{FailureCode, ObligationCauseExt};
2727
use rustc_trait_selection::infer::InferCtxtExt;
2828
use rustc_trait_selection::traits::{self, ObligationCauseCode, SelectionContext};
@@ -1140,8 +1140,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
11401140
.get(arg_idx + 1)
11411141
.map(|&(_, sp)| sp)
11421142
.unwrap_or_else(|| {
1143-
// Subtract one to move before `)`
1144-
call_expr.span.with_lo(call_expr.span.hi() - BytePos(1))
1143+
// Try to move before `)`. Note that `)` here is not necessarily
1144+
// the latin right paren, it could be a Unicode-confusable that
1145+
// looks like a `)`, so we must not use `- BytePos(1)`
1146+
// manipulations here.
1147+
self.tcx().sess.source_map().end_point(call_expr.span)
11451148
});
11461149

11471150
// Include next comma

compiler/rustc_parse/src/parser/stmt.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -408,10 +408,14 @@ impl<'a> Parser<'a> {
408408
fn parse_initializer(&mut self, eq_optional: bool) -> PResult<'a, Option<P<Expr>>> {
409409
let eq_consumed = match self.token.kind {
410410
token::BinOpEq(..) => {
411-
// Recover `let x <op>= 1` as `let x = 1`
411+
// Recover `let x <op>= 1` as `let x = 1` We must not use `+ BytePos(1)` here
412+
// because `<op>` can be a multi-byte lookalike that was recovered, e.g. `➖=` (the
413+
// `➖` is a U+2796 Heavy Minus Sign Unicode Character) that was recovered as a
414+
// `-=`.
415+
let extra_op_span = self.psess.source_map().start_point(self.token.span);
412416
self.dcx().emit_err(errors::CompoundAssignmentExpressionInLet {
413417
span: self.token.span,
414-
suggestion: self.token.span.with_hi(self.token.span.lo() + BytePos(1)),
418+
suggestion: extra_op_span,
415419
});
416420
self.bump();
417421
true

library/std/src/sys/pal/unix/process/process_unix/tests.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,20 @@ fn exitstatus_display_tests() {
2424
// The purpose of this test is to test our string formatting, not our understanding of the wait
2525
// status magic numbers. So restrict these to Linux.
2626
if cfg!(target_os = "linux") {
27+
#[cfg(any(target_arch = "mips", target_arch = "mips64"))]
28+
t(0x0137f, "stopped (not terminated) by signal: 19 (SIGPWR)");
29+
30+
#[cfg(any(target_arch = "sparc", target_arch = "sparc64"))]
31+
t(0x0137f, "stopped (not terminated) by signal: 19 (SIGCONT)");
32+
33+
#[cfg(not(any(
34+
target_arch = "mips",
35+
target_arch = "mips64",
36+
target_arch = "sparc",
37+
target_arch = "sparc64"
38+
)))]
2739
t(0x0137f, "stopped (not terminated) by signal: 19 (SIGSTOP)");
40+
2841
t(0x0ffff, "continued (WIFCONTINUED)");
2942
}
3043

library/std/src/sys/pal/unix/thread.rs

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,7 @@ use crate::mem::{self, ManuallyDrop};
33
use crate::num::NonZero;
44
#[cfg(all(target_os = "linux", target_env = "gnu"))]
55
use crate::sys::weak::dlsym;
6-
#[cfg(any(
7-
target_os = "solaris",
8-
target_os = "illumos",
9-
target_os = "nto",
10-
target_os = "vxworks"
11-
))]
6+
#[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto",))]
127
use crate::sys::weak::weak;
138
use crate::sys::{os, stack_overflow};
149
use crate::time::Duration;
@@ -220,23 +215,16 @@ impl Thread {
220215
#[cfg(target_os = "vxworks")]
221216
pub fn set_name(name: &CStr) {
222217
// FIXME(libc): adding real STATUS, ERROR type eventually.
223-
weak! {
224-
fn taskNameSet(
225-
libc::TASK_ID, *mut libc::c_char
226-
) -> libc::c_int
218+
extern "C" {
219+
fn taskNameSet(task_id: libc::TASK_ID, task_name: *mut libc::c_char) -> libc::c_int;
227220
}
228221

229-
// We can't assume taskNameSet is necessarily available.
230-
// VX_TASK_NAME_LEN can be found set to 31,
231-
// however older versions can be set to only 10.
232-
// FIXME(vxworks): if the minimum supported VxWorks is >= 7, the maximum length can be changed to 31.
233-
if let Some(f) = taskNameSet.get() {
234-
const VX_TASK_NAME_LEN: usize = 10;
222+
// VX_TASK_NAME_LEN is 31 in VxWorks 7.
223+
const VX_TASK_NAME_LEN: usize = 31;
235224

236-
let name = truncate_cstr::<{ VX_TASK_NAME_LEN }>(name);
237-
let status = unsafe { f(libc::taskIdSelf(), name.as_mut_ptr()) };
238-
debug_assert_eq!(res, libc::OK);
239-
}
225+
let mut name = truncate_cstr::<{ VX_TASK_NAME_LEN }>(name);
226+
let res = unsafe { taskNameSet(libc::taskIdSelf(), name.as_mut_ptr()) };
227+
debug_assert_eq!(res, libc::OK);
240228
}
241229

242230
#[cfg(any(
@@ -489,9 +477,11 @@ pub fn available_parallelism() -> io::Result<NonZero<usize>> {
489477
fn vxCpuEnabledGet() -> libc::cpuset_t;
490478
}
491479

492-
// always fetches a valid bitmask
493-
let set = unsafe { vxCpuEnabledGet() };
494-
Ok(NonZero::new_unchecked(set.count_ones() as usize))
480+
// SAFETY: `vxCpuEnabledGet` always fetches a mask with at least one bit set
481+
unsafe{
482+
let set = vxCpuEnabledGet();
483+
Ok(NonZero::new_unchecked(set.count_ones() as usize))
484+
}
495485
} else {
496486
// FIXME: implement on Redox, l4re
497487
Err(io::const_io_error!(io::ErrorKind::Unsupported, "Getting the number of hardware threads is not supported on the target platform"))

src/bootstrap/src/core/config/config.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1325,7 +1325,11 @@ impl Config {
13251325
// Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path,
13261326
// but not if `config.toml` hasn't been created.
13271327
let mut toml = if !using_default_path || toml_path.exists() {
1328-
config.config = Some(toml_path.clone());
1328+
config.config = Some(if cfg!(not(feature = "bootstrap-self-test")) {
1329+
toml_path.canonicalize().unwrap()
1330+
} else {
1331+
toml_path.clone()
1332+
});
13291333
get_toml(&toml_path)
13301334
} else {
13311335
config.config = None;

src/bootstrap/src/lib.rs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,8 @@ impl Build {
986986
}
987987

988988
/// Execute a command and return its output.
989-
/// This method should be used for all command executions in bootstrap.
989+
/// Note: Ideally, you should use one of the BootstrapCommand::run* functions to
990+
/// execute commands. They internally call this method.
990991
#[track_caller]
991992
fn run(
992993
&self,
@@ -1057,20 +1058,28 @@ Executed at: {executed_at}"#,
10571058
CommandOutput::did_not_start(stdout, stderr)
10581059
}
10591060
};
1061+
1062+
let fail = |message: &str| {
1063+
if self.is_verbose() {
1064+
println!("{message}");
1065+
} else {
1066+
println!("Command has failed. Rerun with -v to see more details.");
1067+
}
1068+
exit!(1);
1069+
};
1070+
10601071
if !output.is_success() {
10611072
match command.failure_behavior {
10621073
BehaviorOnFailure::DelayFail => {
10631074
if self.fail_fast {
1064-
println!("{message}");
1065-
exit!(1);
1075+
fail(&message);
10661076
}
10671077

10681078
let mut failures = self.delayed_failures.borrow_mut();
10691079
failures.push(message);
10701080
}
10711081
BehaviorOnFailure::Exit => {
1072-
println!("{message}");
1073-
exit!(1);
1082+
fail(&message);
10741083
}
10751084
BehaviorOnFailure::Ignore => {
10761085
// If failures are allowed, either the error has been printed already

src/bootstrap/src/utils/tarball.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,12 @@ impl<'a> Tarball<'a> {
317317
channel::write_commit_hash_file(&self.overlay_dir, &info.sha);
318318
channel::write_commit_info_file(&self.overlay_dir, info);
319319
}
320+
321+
// Add config file if present.
322+
if let Some(config) = &self.builder.config.config {
323+
self.add_renamed_file(config, &self.overlay_dir, "builder-config");
324+
}
325+
320326
for file in self.overlay.legal_and_readme() {
321327
self.builder.install(&self.builder.src.join(file), &self.overlay_dir, 0o644);
322328
}

0 commit comments

Comments
 (0)