Skip to content

Commit

Permalink
Auto merge of rust-lang#128883 - matthiaskrgr:rollup-mkzi7my, r=matth…
Browse files Browse the repository at this point in the history
…iaskrgr

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
  • Loading branch information
bors committed Aug 9, 2024
2 parents 899eb03 + cea3b42 commit 19ebdce
Show file tree
Hide file tree
Showing 20 changed files with 218 additions and 50 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_borrowck/src/diagnostics/conflict_errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1124,8 +1124,8 @@ impl<'infcx, 'tcx> MirBorrowckCtxt<'_, '_, 'infcx, 'tcx> {
err.multipart_suggestion(
"consider moving the expression out of the loop so it is only moved once",
vec![
(parent.span, "value".to_string()),
(span.shrink_to_lo(), format!("let mut value = {value};{indent}")),
(parent.span, "value".to_string()),
],
Applicability::MaybeIncorrect,
);
Expand Down
9 changes: 9 additions & 0 deletions compiler/rustc_data_structures/src/steal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ impl<T> Steal<T> {
let value = value_ref.take();
value.expect("attempt to steal from stolen value")
}

/// Writers of rustc drivers often encounter stealing issues. This function makes it possible to
/// handle these errors gracefully.
///
/// This should not be used within rustc as it leaks information not tracked
/// by the query system, breaking incremental compilation.
pub fn is_stolen(&self) -> bool {
self.value.borrow().is_none()
}
}

impl<CTX, T: HashStable<CTX>> HashStable<CTX> for Steal<T> {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_errors/src/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -920,8 +920,8 @@ impl<'a, G: EmissionGuarantee> Diag<'a, G> {
applicability: Applicability,
style: SuggestionStyle,
) -> &mut Self {
suggestion.sort_unstable();
suggestion.dedup_by(|(s1, m1), (s2, m2)| s1.source_equal(*s2) && m1 == m2);
let mut seen = crate::FxHashSet::default();
suggestion.retain(|(span, msg)| seen.insert((span.lo(), span.hi(), msg.clone())));

let parts = suggestion
.into_iter()
Expand Down
9 changes: 6 additions & 3 deletions compiler/rustc_hir_typeck/src/fn_ctxt/checks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use rustc_middle::ty::{self, IsSuggestable, Ty, TyCtxt};
use rustc_middle::{bug, span_bug};
use rustc_session::Session;
use rustc_span::symbol::{kw, Ident};
use rustc_span::{sym, BytePos, Span, DUMMY_SP};
use rustc_span::{sym, Span, DUMMY_SP};
use rustc_trait_selection::error_reporting::infer::{FailureCode, ObligationCauseExt};
use rustc_trait_selection::infer::InferCtxtExt;
use rustc_trait_selection::traits::{self, ObligationCauseCode, SelectionContext};
Expand Down Expand Up @@ -1140,8 +1140,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
.get(arg_idx + 1)
.map(|&(_, sp)| sp)
.unwrap_or_else(|| {
// Subtract one to move before `)`
call_expr.span.with_lo(call_expr.span.hi() - BytePos(1))
// Try to move before `)`. Note that `)` here is not necessarily
// the latin right paren, it could be a Unicode-confusable that
// looks like a `)`, so we must not use `- BytePos(1)`
// manipulations here.
self.tcx().sess.source_map().end_point(call_expr.span)
});

// Include next comma
Expand Down
8 changes: 6 additions & 2 deletions compiler/rustc_parse/src/parser/stmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,14 @@ impl<'a> Parser<'a> {
fn parse_initializer(&mut self, eq_optional: bool) -> PResult<'a, Option<P<Expr>>> {
let eq_consumed = match self.token.kind {
token::BinOpEq(..) => {
// Recover `let x <op>= 1` as `let x = 1`
// Recover `let x <op>= 1` as `let x = 1` We must not use `+ BytePos(1)` here
// because `<op>` can be a multi-byte lookalike that was recovered, e.g. `➖=` (the
// `➖` is a U+2796 Heavy Minus Sign Unicode Character) that was recovered as a
// `-=`.
let extra_op_span = self.psess.source_map().start_point(self.token.span);
self.dcx().emit_err(errors::CompoundAssignmentExpressionInLet {
span: self.token.span,
suggestion: self.token.span.with_hi(self.token.span.lo() + BytePos(1)),
suggestion: extra_op_span,
});
self.bump();
true
Expand Down
13 changes: 13 additions & 0 deletions library/std/src/sys/pal/unix/process/process_unix/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,20 @@ fn exitstatus_display_tests() {
// The purpose of this test is to test our string formatting, not our understanding of the wait
// status magic numbers. So restrict these to Linux.
if cfg!(target_os = "linux") {
#[cfg(any(target_arch = "mips", target_arch = "mips64"))]
t(0x0137f, "stopped (not terminated) by signal: 19 (SIGPWR)");

#[cfg(any(target_arch = "sparc", target_arch = "sparc64"))]
t(0x0137f, "stopped (not terminated) by signal: 19 (SIGCONT)");

#[cfg(not(any(
target_arch = "mips",
target_arch = "mips64",
target_arch = "sparc",
target_arch = "sparc64"
)))]
t(0x0137f, "stopped (not terminated) by signal: 19 (SIGSTOP)");

t(0x0ffff, "continued (WIFCONTINUED)");
}

Expand Down
36 changes: 13 additions & 23 deletions library/std/src/sys/pal/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,7 @@ use crate::mem::{self, ManuallyDrop};
use crate::num::NonZero;
#[cfg(all(target_os = "linux", target_env = "gnu"))]
use crate::sys::weak::dlsym;
#[cfg(any(
target_os = "solaris",
target_os = "illumos",
target_os = "nto",
target_os = "vxworks"
))]
#[cfg(any(target_os = "solaris", target_os = "illumos", target_os = "nto",))]
use crate::sys::weak::weak;
use crate::sys::{os, stack_overflow};
use crate::time::Duration;
Expand Down Expand Up @@ -220,23 +215,16 @@ impl Thread {
#[cfg(target_os = "vxworks")]
pub fn set_name(name: &CStr) {
// FIXME(libc): adding real STATUS, ERROR type eventually.
weak! {
fn taskNameSet(
libc::TASK_ID, *mut libc::c_char
) -> libc::c_int
extern "C" {
fn taskNameSet(task_id: libc::TASK_ID, task_name: *mut libc::c_char) -> libc::c_int;
}

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

let name = truncate_cstr::<{ VX_TASK_NAME_LEN }>(name);
let status = unsafe { f(libc::taskIdSelf(), name.as_mut_ptr()) };
debug_assert_eq!(res, libc::OK);
}
let mut name = truncate_cstr::<{ VX_TASK_NAME_LEN }>(name);
let res = unsafe { taskNameSet(libc::taskIdSelf(), name.as_mut_ptr()) };
debug_assert_eq!(res, libc::OK);
}

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

// always fetches a valid bitmask
let set = unsafe { vxCpuEnabledGet() };
Ok(NonZero::new_unchecked(set.count_ones() as usize))
// SAFETY: `vxCpuEnabledGet` always fetches a mask with at least one bit set
unsafe{
let set = vxCpuEnabledGet();
Ok(NonZero::new_unchecked(set.count_ones() as usize))
}
} else {
// FIXME: implement on Redox, l4re
Err(io::const_io_error!(io::ErrorKind::Unsupported, "Getting the number of hardware threads is not supported on the target platform"))
Expand Down
6 changes: 5 additions & 1 deletion src/bootstrap/src/core/config/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1325,7 +1325,11 @@ impl Config {
// Give a hard error if `--config` or `RUST_BOOTSTRAP_CONFIG` are set to a missing path,
// but not if `config.toml` hasn't been created.
let mut toml = if !using_default_path || toml_path.exists() {
config.config = Some(toml_path.clone());
config.config = Some(if cfg!(not(feature = "bootstrap-self-test")) {
toml_path.canonicalize().unwrap()
} else {
toml_path.clone()
});
get_toml(&toml_path)
} else {
config.config = None;
Expand Down
19 changes: 14 additions & 5 deletions src/bootstrap/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,8 @@ impl Build {
}

/// Execute a command and return its output.
/// This method should be used for all command executions in bootstrap.
/// Note: Ideally, you should use one of the BootstrapCommand::run* functions to
/// execute commands. They internally call this method.
#[track_caller]
fn run(
&self,
Expand Down Expand Up @@ -1057,20 +1058,28 @@ Executed at: {executed_at}"#,
CommandOutput::did_not_start(stdout, stderr)
}
};

let fail = |message: &str| {
if self.is_verbose() {
println!("{message}");
} else {
println!("Command has failed. Rerun with -v to see more details.");
}
exit!(1);
};

if !output.is_success() {
match command.failure_behavior {
BehaviorOnFailure::DelayFail => {
if self.fail_fast {
println!("{message}");
exit!(1);
fail(&message);
}

let mut failures = self.delayed_failures.borrow_mut();
failures.push(message);
}
BehaviorOnFailure::Exit => {
println!("{message}");
exit!(1);
fail(&message);
}
BehaviorOnFailure::Ignore => {
// If failures are allowed, either the error has been printed already
Expand Down
6 changes: 6 additions & 0 deletions src/bootstrap/src/utils/tarball.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,12 @@ impl<'a> Tarball<'a> {
channel::write_commit_hash_file(&self.overlay_dir, &info.sha);
channel::write_commit_info_file(&self.overlay_dir, info);
}

// Add config file if present.
if let Some(config) = &self.builder.config.config {
self.add_renamed_file(config, &self.overlay_dir, "builder-config");
}

for file in self.overlay.legal_and_readme() {
self.builder.install(&self.builder.src.join(file), &self.overlay_dir, 0o644);
}
Expand Down
12 changes: 6 additions & 6 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ target | std | host | notes
[`armv7-unknown-linux-uclibceabihf`](platform-support/armv7-unknown-linux-uclibceabihf.md) | ✓ | ? | Armv7-A Linux with uClibc, hardfloat
`armv7-unknown-freebsd` | ✓ | ✓ | Armv7-A FreeBSD
[`armv7-unknown-netbsd-eabihf`](platform-support/netbsd.md) | ✓ | ✓ | Armv7-A NetBSD w/hard-float
[`armv7-wrs-vxworks-eabihf`](platform-support/vxworks.md) | ? | | Armv7-A for VxWorks
[`armv7-wrs-vxworks-eabihf`](platform-support/vxworks.md) | | | Armv7-A for VxWorks
[`armv7a-kmc-solid_asp3-eabi`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3
[`armv7a-kmc-solid_asp3-eabihf`](platform-support/kmc-solid.md) | ✓ | | ARM SOLID with TOPPERS/ASP3, hardfloat
[`armv7a-none-eabihf`](platform-support/arm-none-eabi.md) | * | | Bare Armv7-A, hardfloat
Expand All @@ -308,7 +308,7 @@ target | std | host | notes
`i686-uwp-windows-gnu` | ✓ | | [^x86_32-floats-return-ABI]
`i686-uwp-windows-msvc` | ✓ | | [^x86_32-floats-return-ABI]
[`i686-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 32-bit Windows 7 support [^x86_32-floats-return-ABI]
[`i686-wrs-vxworks`](platform-support/vxworks.md) | ? | | [^x86_32-floats-return-ABI]
[`i686-wrs-vxworks`](platform-support/vxworks.md) | | | [^x86_32-floats-return-ABI]
[`m68k-unknown-linux-gnu`](platform-support/m68k-unknown-linux-gnu.md) | ? | | Motorola 680x0 Linux
`mips-unknown-linux-gnu` | ✓ | ✓ | MIPS Linux (kernel 4.4, glibc 2.23)
`mips-unknown-linux-musl` | ✓ | | MIPS Linux with musl 1.2.3
Expand All @@ -334,13 +334,13 @@ target | std | host | notes
`powerpc-unknown-linux-musl` | ? | | PowerPC Linux with musl 1.2.3
[`powerpc-unknown-netbsd`](platform-support/netbsd.md) | ✓ | ✓ | NetBSD 32-bit powerpc systems
[`powerpc-unknown-openbsd`](platform-support/powerpc-unknown-openbsd.md) | * | |
[`powerpc-wrs-vxworks-spe`](platform-support/vxworks.md) | ? | |
[`powerpc-wrs-vxworks`](platform-support/vxworks.md) | ? | |
[`powerpc-wrs-vxworks-spe`](platform-support/vxworks.md) | | |
[`powerpc-wrs-vxworks`](platform-support/vxworks.md) | | |
`powerpc64-unknown-freebsd` | ✓ | ✓ | PPC64 FreeBSD (ELFv1 and ELFv2)
`powerpc64le-unknown-freebsd` | | | PPC64LE FreeBSD
`powerpc-unknown-freebsd` | | | PowerPC FreeBSD
`powerpc64-unknown-linux-musl` | ? | | 64-bit PowerPC Linux with musl 1.2.3
`powerpc64-wrs-vxworks` | ? | |
[`powerpc64-wrs-vxworks`](platform-support/vxworks.md) | | |
`powerpc64le-unknown-linux-musl` | ? | | 64-bit PowerPC Linux with musl 1.2.3, Little Endian
[`powerpc64-unknown-openbsd`](platform-support/openbsd.md) | ✓ | ✓ | OpenBSD/powerpc64
[`powerpc64-ibm-aix`](platform-support/aix.md) | ? | | 64-bit AIX (7.2 and newer)
Expand Down Expand Up @@ -383,7 +383,7 @@ target | std | host | notes
`x86_64-uwp-windows-gnu` | ✓ | |
`x86_64-uwp-windows-msvc` | ✓ | |
[`x86_64-win7-windows-msvc`](platform-support/win7-windows-msvc.md) | ✓ | | 64-bit Windows 7 support
[`x86_64-wrs-vxworks`](platform-support/vxworks.md) | ? | |
[`x86_64-wrs-vxworks`](platform-support/vxworks.md) | | |
[`x86_64h-apple-darwin`](platform-support/x86_64h-apple-darwin.md) | ✓ | ✓ | macOS with late-gen Intel (at least Haswell)
[`x86_64-unknown-linux-none`](platform-support/x86_64-unknown-linux-none.md) | * | | 64-bit Linux with no libc
[`xtensa-esp32-none-elf`](platform-support/xtensa.md) | * | | Xtensa ESP32
Expand Down
2 changes: 2 additions & 0 deletions src/doc/rustc/src/platform-support/vxworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Target triplets available:
- `i686-wrs-vxworks`
- `armv7-wrs-vxworks-eabihf`
- `powerpc-wrs-vxworks`
- `powerpc64-wrs-vxworks`
- `powerpc-wrs-vxworks-spe`

## Target maintainers
Expand Down Expand Up @@ -42,6 +43,7 @@ target = [
"i686-wrs-vxworks",
"armv7-wrs-vxworks-eabihf",
"powerpc-wrs-vxworks",
"powerpc64-wrs-vxworks",
"powerpc-wrs-vxworks-spe",
]
```
Expand Down
20 changes: 16 additions & 4 deletions src/librustdoc/html/markdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,7 @@ pub(crate) struct TagIterator<'a, 'tcx> {
data: &'a str,
is_in_attribute_block: bool,
extra: Option<&'a ExtraInfo<'tcx>>,
is_error: bool,
}

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

impl<'a, 'tcx> TagIterator<'a, 'tcx> {
pub(crate) fn new(data: &'a str, extra: Option<&'a ExtraInfo<'tcx>>) -> Self {
Self { inner: data.char_indices().peekable(), data, is_in_attribute_block: false, extra }
Self {
inner: data.char_indices().peekable(),
data,
is_in_attribute_block: false,
extra,
is_error: false,
}
}

fn emit_error(&self, err: impl Into<DiagMessage>) {
fn emit_error(&mut self, err: impl Into<DiagMessage>) {
if let Some(extra) = self.extra {
extra.error_invalid_codeblock_attr(err);
}
self.is_error = true;
}

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

fn next(&mut self) -> Option<Self::Item> {
if self.is_error {
return None;
}
let Some(start) = self.skip_separators() else {
if self.is_in_attribute_block {
self.emit_error("unclosed attribute block (`{}`): missing `}` at the end");
Expand Down Expand Up @@ -1342,14 +1353,15 @@ impl LangString {
}
};

call(&mut TagIterator::new(string, extra));
let mut tag_iter = TagIterator::new(string, extra);
call(&mut tag_iter);

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

data.rust &= !seen_custom_tag && (!seen_other_tags || seen_rust_tags);
data.rust &= !seen_custom_tag && (!seen_other_tags || seen_rust_tags) && !tag_iter.is_error;

data
}
Expand Down
6 changes: 3 additions & 3 deletions src/librustdoc/html/markdown/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ fn test_lang_string_parse() {
..Default::default()
});
// error
t(LangString { original: "{rust}".into(), rust: true, ..Default::default() });
t(LangString { original: "{rust}".into(), rust: false, ..Default::default() });
t(LangString {
original: "{.rust}".into(),
rust: true,
Expand Down Expand Up @@ -233,7 +233,7 @@ fn test_lang_string_parse() {
..Default::default()
});
// error
t(LangString { original: "{class=first=second}".into(), rust: true, ..Default::default() });
t(LangString { original: "{class=first=second}".into(), rust: false, ..Default::default() });
// error
t(LangString {
original: "{class=first.second}".into(),
Expand Down Expand Up @@ -261,7 +261,7 @@ fn test_lang_string_parse() {
..Default::default()
});
// error
t(LangString { original: r#"{class=f"irst"}"#.into(), rust: true, ..Default::default() });
t(LangString { original: r#"{class=f"irst"}"#.into(), rust: false, ..Default::default() });
}

#[test]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//@ compile-flags:--test
//@ check-pass
#![allow(rustdoc::invalid_codeblock_attributes)]

// https://github.com/rust-lang/rust/pull/124577#issuecomment-2276034737

// Test that invalid langstrings don't get run.

/// ```{rust,ignore}
/// panic!();
/// ```
pub struct Foo;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s

Loading

0 comments on commit 19ebdce

Please sign in to comment.