Skip to content

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

+1-1
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

+9
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

+2-2
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

+6-3
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

+6-2
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

+13
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

+13-23
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

+5-1
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

+14-5
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

+6
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
}

src/doc/rustc/src/platform-support.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ target | std | host | notes
282282
[`armv7-unknown-linux-uclibceabihf`](platform-support/armv7-unknown-linux-uclibceabihf.md) | ✓ | ? | Armv7-A Linux with uClibc, hardfloat
283283
`armv7-unknown-freebsd` | ✓ | ✓ | Armv7-A FreeBSD
284284
[`armv7-unknown-netbsd-eabihf`](platform-support/netbsd.md) | ✓ | ✓ | Armv7-A NetBSD w/hard-float
285-
[`armv7-wrs-vxworks-eabihf`](platform-support/vxworks.md) | ? | | Armv7-A for VxWorks
285+
[`armv7-wrs-vxworks-eabihf`](platform-support/vxworks.md) | | | Armv7-A for VxWorks
286286
[`armv7a-kmc-solid_asp3-eabi`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3
287287
[`armv7a-kmc-solid_asp3-eabihf`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3, hardfloat
288288
[`armv7a-none-eabihf`](platform-support/arm-none-eabi.md) | * | | Bare Armv7-A, hardfloat
@@ -308,7 +308,7 @@ target | std | host | notes
308308
`i686-uwp-windows-gnu` | ✓ | | [^x86_32-floats-return-ABI]
309309
`i686-uwp-windows-msvc` | ✓ | | [^x86_32-floats-return-ABI]
310310
[`i686-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 32-bit Windows 7 support [^x86_32-floats-return-ABI]
311-
[`i686-wrs-vxworks`](platform-support/vxworks.md) | ? | | [^x86_32-floats-return-ABI]
311+
[`i686-wrs-vxworks`](platform-support/vxworks.md) | | | [^x86_32-floats-return-ABI]
312312
[`m68k-unknown-linux-gnu`](platform-support/m68k-unknown-linux-gnu.md) | ? | | Motorola 680x0 Linux
313313
`mips-unknown-linux-gnu` | ✓ | ✓ | MIPS Linux (kernel 4.4, glibc 2.23)
314314
`mips-unknown-linux-musl` | ✓ | | MIPS Linux with musl 1.2.3
@@ -334,13 +334,13 @@ target | std | host | notes
334334
`powerpc-unknown-linux-musl` | ? | | PowerPC Linux with musl 1.2.3
335335
[`powerpc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD 32-bit powerpc systems
336336
[`powerpc-unknown-openbsd`](platform-support/powerpc-unknown-openbsd.md) | * | |
337-
[`powerpc-wrs-vxworks-spe`](platform-support/vxworks.md) | ? | |
338-
[`powerpc-wrs-vxworks`](platform-support/vxworks.md) | ? | |
337+
[`powerpc-wrs-vxworks-spe`](platform-support/vxworks.md) | | |
338+
[`powerpc-wrs-vxworks`](platform-support/vxworks.md) | | |
339339
`powerpc64-unknown-freebsd` | ✓ | ✓ | PPC64 FreeBSD (ELFv1 and ELFv2)
340340
`powerpc64le-unknown-freebsd` | | | PPC64LE FreeBSD
341341
`powerpc-unknown-freebsd` | | | PowerPC FreeBSD
342342
`powerpc64-unknown-linux-musl` | ? | | 64-bit PowerPC Linux with musl 1.2.3
343-
`powerpc64-wrs-vxworks` | ? | |
343+
[`powerpc64-wrs-vxworks`](platform-support/vxworks.md) | | |
344344
`powerpc64le-unknown-linux-musl` | ? | | 64-bit PowerPC Linux with musl 1.2.3, Little Endian
345345
[`powerpc64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/powerpc64
346346
[`powerpc64-ibm-aix`](platform-support/aix.md) | ? | | 64-bit AIX (7.2 and newer)
@@ -383,7 +383,7 @@ target | std | host | notes
383383
`x86_64-uwp-windows-gnu` | ✓ | |
384384
`x86_64-uwp-windows-msvc` | ✓ | |
385385
[`x86_64-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 64-bit Windows 7 support
386-
[`x86_64-wrs-vxworks`](platform-support/vxworks.md) | ? | |
386+
[`x86_64-wrs-vxworks`](platform-support/vxworks.md) | | |
387387
[`x86_64h-apple-darwin`](platform-support/x86_64h-apple-darwin.md) | ✓ | ✓ | macOS with late-gen Intel (at least Haswell)
388388
[`x86_64-unknown-linux-none`](platform-support/x86_64-unknown-linux-none.md) | * | | 64-bit Linux with no libc
389389
[`xtensa-esp32-none-elf`](platform-support/xtensa.md) | * | | Xtensa ESP32

src/doc/rustc/src/platform-support/vxworks.md

+2
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ Target triplets available:
1212
- `i686-wrs-vxworks`
1313
- `armv7-wrs-vxworks-eabihf`
1414
- `powerpc-wrs-vxworks`
15+
- `powerpc64-wrs-vxworks`
1516
- `powerpc-wrs-vxworks-spe`
1617

1718
## Target maintainers
@@ -42,6 +43,7 @@ target = [
4243
"i686-wrs-vxworks",
4344
"armv7-wrs-vxworks-eabihf",
4445
"powerpc-wrs-vxworks",
46+
"powerpc64-wrs-vxworks",
4547
"powerpc-wrs-vxworks-spe",
4648
]
4749
```

src/librustdoc/html/markdown.rs

+16-4
Original file line numberDiff line numberDiff line change
@@ -924,6 +924,7 @@ pub(crate) struct TagIterator<'a, 'tcx> {
924924
data: &'a str,
925925
is_in_attribute_block: bool,
926926
extra: Option<&'a ExtraInfo<'tcx>>,
927+
is_error: bool,
927928
}
928929

929930
#[derive(Clone, Debug, Eq, PartialEq)]
@@ -950,13 +951,20 @@ struct Indices {
950951

951952
impl<'a, 'tcx> TagIterator<'a, 'tcx> {
952953
pub(crate) fn new(data: &'a str, extra: Option<&'a ExtraInfo<'tcx>>) -> Self {
953-
Self { inner: data.char_indices().peekable(), data, is_in_attribute_block: false, extra }
954+
Self {
955+
inner: data.char_indices().peekable(),
956+
data,
957+
is_in_attribute_block: false,
958+
extra,
959+
is_error: false,
960+
}
954961
}
955962

956-
fn emit_error(&self, err: impl Into<DiagMessage>) {
963+
fn emit_error(&mut self, err: impl Into<DiagMessage>) {
957964
if let Some(extra) = self.extra {
958965
extra.error_invalid_codeblock_attr(err);
959966
}
967+
self.is_error = true;
960968
}
961969

962970
fn skip_separators(&mut self) -> Option<usize> {
@@ -1154,6 +1162,9 @@ impl<'a, 'tcx> Iterator for TagIterator<'a, 'tcx> {
11541162
type Item = LangStringToken<'a>;
11551163

11561164
fn next(&mut self) -> Option<Self::Item> {
1165+
if self.is_error {
1166+
return None;
1167+
}
11571168
let Some(start) = self.skip_separators() else {
11581169
if self.is_in_attribute_block {
11591170
self.emit_error("unclosed attribute block (`{}`): missing `}` at the end");
@@ -1342,14 +1353,15 @@ impl LangString {
13421353
}
13431354
};
13441355

1345-
call(&mut TagIterator::new(string, extra));
1356+
let mut tag_iter = TagIterator::new(string, extra);
1357+
call(&mut tag_iter);
13461358

13471359
// ignore-foo overrides ignore
13481360
if !ignores.is_empty() {
13491361
data.ignore = Ignore::Some(ignores);
13501362
}
13511363

1352-
data.rust &= !seen_custom_tag && (!seen_other_tags || seen_rust_tags);
1364+
data.rust &= !seen_custom_tag && (!seen_other_tags || seen_rust_tags) && !tag_iter.is_error;
13531365

13541366
data
13551367
}

src/librustdoc/html/markdown/tests.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ fn test_lang_string_parse() {
6161
..Default::default()
6262
});
6363
// error
64-
t(LangString { original: "{rust}".into(), rust: true, ..Default::default() });
64+
t(LangString { original: "{rust}".into(), rust: false, ..Default::default() });
6565
t(LangString {
6666
original: "{.rust}".into(),
6767
rust: true,
@@ -233,7 +233,7 @@ fn test_lang_string_parse() {
233233
..Default::default()
234234
});
235235
// error
236-
t(LangString { original: "{class=first=second}".into(), rust: true, ..Default::default() });
236+
t(LangString { original: "{class=first=second}".into(), rust: false, ..Default::default() });
237237
// error
238238
t(LangString {
239239
original: "{class=first.second}".into(),
@@ -261,7 +261,7 @@ fn test_lang_string_parse() {
261261
..Default::default()
262262
});
263263
// error
264-
t(LangString { original: r#"{class=f"irst"}"#.into(), rust: true, ..Default::default() });
264+
t(LangString { original: r#"{class=f"irst"}"#.into(), rust: false, ..Default::default() });
265265
}
266266

267267
#[test]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
//@ compile-flags:--test
2+
//@ check-pass
3+
#![allow(rustdoc::invalid_codeblock_attributes)]
4+
5+
// https://github.com/rust-lang/rust/pull/124577#issuecomment-2276034737
6+
7+
// Test that invalid langstrings don't get run.
8+
9+
/// ```{rust,ignore}
10+
/// panic!();
11+
/// ```
12+
pub struct Foo;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
running 0 tests
3+
4+
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
5+

0 commit comments

Comments
 (0)