Skip to content

Rollup of 7 pull requests #141437

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 46 commits into from
May 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
57af157
Update std doctests for android
ehuss May 15, 2025
dcef449
discuss deadlocks in the std::io::pipe() example
oconnor663 May 17, 2025
f9a75a0
Add more comment to libc-fs-with-isolation test
tiif May 18, 2025
3c50b9b
Merge pull request #4322 from tiif/move_test
RalfJung May 18, 2025
eb11adc
bump rustc-build-sysroot
RalfJung May 18, 2025
a4eb91f
Merge pull request #4330 from RalfJung/build-sysroot-bump
RalfJung May 18, 2025
b2a8690
Preparing for merge from rustc
May 19, 2025
1bb2d73
Merge from rustc
May 19, 2025
d5240cc
Merge pull request #4331 from rust-lang/rustup-2025-05-19
RalfJung May 19, 2025
0ba2a3a
enable clippy::as_conversions to fully rule out as-casts
RalfJung May 18, 2025
446fa22
add to_u64() helper method and use it where appropriate
RalfJung May 19, 2025
44d3c93
Merge pull request #4329 from RalfJung/no-casts
RalfJung May 19, 2025
aa4d16a
run tests on mips-unknown-linux-gnu
RalfJung May 19, 2025
8d46118
Merge pull request #4333 from RalfJung/mips-tests
RalfJung May 19, 2025
758b799
GetUserProfileDirectoryW: reference issue regarding implementation de…
RalfJung May 19, 2025
26e9172
Merge pull request #4334 from RalfJung/GetUserProfileDirectoryW-issue
RalfJung May 19, 2025
969a25b
Preparing for merge from rustc
RalfJung May 20, 2025
b13251e
Merge from rustc
RalfJung May 20, 2025
49482ca
Merge pull request #4335 from RalfJung/rustup
RalfJung May 20, 2025
293b0ac
Preparing for merge from rustc
May 21, 2025
b5688fb
Merge from rustc
May 21, 2025
2f34354
test direct usage of io::{stdout,stderr,stdin}
RalfJung May 21, 2025
e12f911
Merge pull request #4336 from rust-lang/rustup-2025-05-21
RalfJung May 21, 2025
fe51193
Merge pull request #4337 from RalfJung/io
RalfJung May 21, 2025
0523554
FileDescription: improve read/write docs
RalfJung May 21, 2025
febe988
Merge pull request #4338 from RalfJung/FileDescription
RalfJung May 21, 2025
5dfcb12
Implement FreeBSD syscall cpuset_getaffinity.
LorrensP-2158466 Apr 22, 2025
e065e27
Merge pull request #4287 from LorrensP-2158466/freebsd-num-cpus
RalfJung May 21, 2025
5955969
run the full test suite under FreeBSD
RalfJung May 21, 2025
4a18888
document that the entire test suite passes under freebsd
RalfJung May 21, 2025
268a369
Merge pull request #4341 from RalfJung/freebsd
RalfJung May 21, 2025
849cabf
Rename `kw::Empty` as `sym::empty`.
nnethercote May 22, 2025
1e79637
Implement file read/write on Windows
CraftSpider Apr 10, 2025
9e1f3a5
enable isolated-stdin test on Windows
RalfJung May 22, 2025
2eb935d
Merge pull request #4275 from CraftSpider/windows-file-rw
RalfJung May 22, 2025
3f0c39d
update lockfile
RalfJung May 22, 2025
3005a09
rustdoc: improve diagnostics on raw doc fragments
lolbinarycat Feb 1, 2025
98bd1a6
rustdoc JSON: Don't apply `#[repr]` privacy heuristics
fmease May 17, 2025
cb8fdb4
Async drop poll shim for error dropee generates noop body (fixes #140…
azhogin May 13, 2025
1c2ea28
Rollup merge of #136400 - lolbinarycat:rustdoc-link-lint-135851, r=Gu…
matthiaskrgr May 23, 2025
f7a1179
Rollup merge of #140967 - azhogin:azhogin/async-drop-poll-shim-for-er…
matthiaskrgr May 23, 2025
036607e
Rollup merge of #141019 - ehuss:android-doctest-xcompile, r=Mark-Simu…
matthiaskrgr May 23, 2025
dfa3110
Rollup merge of #141109 - oconnor663:pipe_example, r=Mark-Simulacrum
matthiaskrgr May 23, 2025
893494c
Rollup merge of #141126 - fmease:rev-rjson-priv-repr, r=aDotInTheVoid
matthiaskrgr May 23, 2025
225ed8b
Rollup merge of #141376 - nnethercote:rename-kw-Empty, r=petrochenkov
matthiaskrgr May 23, 2025
ee1768c
Rollup merge of #141383 - RalfJung:miri-sync, r=RalfJung
matthiaskrgr May 23, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3116,9 +3116,9 @@ dependencies = [

[[package]]
name = "rustc-build-sysroot"
version = "0.5.5"
version = "0.5.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fb332121f7845c6bd016f9655cf22f03c2999df936694b624a88669a78667d98"
checksum = "10edc2e4393515193bd766e2f6c050b0536a68e56f2b6d56c07ababfdc114ff0"
dependencies = [
"anyhow",
"rustc_version",
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_ast_lowering/src/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_ast::*;
use rustc_data_structures::fx::FxIndexMap;
use rustc_hir as hir;
use rustc_session::config::FmtDebug;
use rustc_span::{Ident, Span, Symbol, kw, sym};
use rustc_span::{Ident, Span, Symbol, sym};

use super::LoweringContext;

Expand Down Expand Up @@ -418,7 +418,7 @@ fn expand_format_args<'hir>(
&FormatArgsPiece::Placeholder(_) => {
// Inject empty string before placeholders when not already preceded by a literal piece.
if i == 0 || matches!(fmt.template[i - 1], FormatArgsPiece::Placeholder(_)) {
Some(ctx.expr_str(fmt.span, kw::Empty))
Some(ctx.expr_str(fmt.span, sym::empty))
} else {
None
}
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_codegen_ssa/src/mir/debuginfo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use rustc_middle::ty::layout::{LayoutOf, TyAndLayout};
use rustc_middle::ty::{Instance, Ty};
use rustc_middle::{bug, mir, ty};
use rustc_session::config::DebugInfo;
use rustc_span::{BytePos, Span, Symbol, hygiene, kw};
use rustc_span::{BytePos, Span, Symbol, hygiene, sym};

use super::operand::{OperandRef, OperandValue};
use super::place::{PlaceRef, PlaceValue};
Expand Down Expand Up @@ -283,7 +283,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
// (after #67586 gets fixed).
None
} else {
let name = kw::Empty;
let name = sym::empty;
let decl = &self.mir.local_decls[local];
let dbg_var = if full_debug_info {
self.adjusted_span_and_dbg_scope(decl.source_info).map(
Expand Down Expand Up @@ -318,7 +318,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
None
} else {
Some(match whole_local_var.or(fallback_var.clone()) {
Some(var) if var.name != kw::Empty => var.name.to_string(),
Some(var) if var.name != sym::empty => var.name.to_string(),
_ => format!("{local:?}"),
})
};
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ impl From<Ident> for LifetimeSyntax {
fn from(ident: Ident) -> Self {
let name = ident.name;

if name == kw::Empty {
if name == sym::empty {
unreachable!("A lifetime name should never be empty");
} else if name == kw::UnderscoreLifetime {
LifetimeSyntax::Anonymous
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use rustc_middle::mir::{
BasicBlock, BasicBlockData, Body, Local, LocalDecl, MirSource, Operand, Place, Rvalue,
SourceInfo, Statement, StatementKind, Terminator, TerminatorKind,
};
use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt};
use rustc_middle::ty::{self, EarlyBinder, Ty, TyCtxt, TypeVisitableExt};

use super::*;
use crate::patch::MirPatch;
Expand Down Expand Up @@ -121,9 +121,10 @@ pub(super) fn build_async_drop_shim<'tcx>(
parent_args.as_coroutine().resume_ty(),
)));
body.phase = MirPhase::Runtime(RuntimePhase::Initial);
if !needs_async_drop {
if !needs_async_drop || drop_ty.references_error() {
// Returning noop body for types without `need async drop`
// (or sync Drop in case of !`need async drop` && `need drop`)
// (or sync Drop in case of !`need async drop` && `need drop`).
// And also for error types.
return body;
}

Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_passes/src/check_attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use rustc_session::lint::builtin::{
UNKNOWN_OR_MALFORMED_DIAGNOSTIC_ATTRIBUTES, UNUSED_ATTRIBUTES,
};
use rustc_session::parse::feature_err;
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, edition, kw, sym};
use rustc_span::{BytePos, DUMMY_SP, Span, Symbol, edition, sym};
use rustc_trait_selection::error_reporting::InferCtxtErrorExt;
use rustc_trait_selection::infer::{TyCtxtInferExt, ValuePairs};
use rustc_trait_selection::traits::ObligationCtxt;
Expand Down Expand Up @@ -936,7 +936,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
let span = meta.name_value_literal_span().unwrap_or_else(|| meta.span());
let attr_str =
&format!("`#[doc(alias{})]`", if is_list { "(\"...\")" } else { " = \"...\"" });
if doc_alias == kw::Empty {
if doc_alias == sym::empty {
tcx.dcx().emit_err(errors::DocAliasEmpty { span, attr_str });
return;
}
Expand Down Expand Up @@ -1068,7 +1068,7 @@ impl<'tcx> CheckAttrVisitor<'tcx> {
}

let doc_keyword = match meta.value_str() {
Some(value) if value != kw::Empty => value,
Some(value) if value != sym::empty => value,
_ => return self.doc_attr_str_error(meta, "keyword"),
};

Expand Down
57 changes: 50 additions & 7 deletions compiler/rustc_resolve/src/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use rustc_data_structures::fx::FxIndexMap;
use rustc_data_structures::unord::UnordSet;
use rustc_middle::ty::TyCtxt;
use rustc_span::def_id::DefId;
use rustc_span::{DUMMY_SP, InnerSpan, Span, Symbol, kw, sym};
use rustc_span::{DUMMY_SP, InnerSpan, Span, Symbol, sym};
use thin_vec::ThinVec;
use tracing::{debug, trace};

Expand Down Expand Up @@ -157,7 +157,7 @@ pub fn unindent_doc_fragments(docs: &mut [DocFragment]) {
};

for fragment in docs {
if fragment.doc == kw::Empty {
if fragment.doc == sym::empty {
continue;
}

Expand All @@ -177,7 +177,7 @@ pub fn unindent_doc_fragments(docs: &mut [DocFragment]) {
///
/// Note: remove the trailing newline where appropriate
pub fn add_doc_fragment(out: &mut String, frag: &DocFragment) {
if frag.doc == kw::Empty {
if frag.doc == sym::empty {
out.push('\n');
return;
}
Expand Down Expand Up @@ -514,20 +514,30 @@ pub fn span_of_fragments(fragments: &[DocFragment]) -> Option<Span> {
/// This method does not always work, because markdown bytes don't necessarily match source bytes,
/// like if escapes are used in the string. In this case, it returns `None`.
///
/// This method will return `Some` only if:
/// `markdown` is typically the entire documentation for an item,
/// after combining fragments.
///
/// This method will return `Some` only if one of the following is true:
///
/// - The doc is made entirely from sugared doc comments, which cannot contain escapes
/// - The doc is entirely from a single doc fragment, with a string literal, exactly equal
/// - The doc is entirely from a single doc fragment with a string literal exactly equal to `markdown`.
/// - The doc comes from `include_str!`
/// - The doc includes exactly one substring matching `markdown[md_range]` which is contained in a single doc fragment.
///
/// This function is defined in the compiler so it can be used by
/// both `rustdoc` and `clippy`.
pub fn source_span_for_markdown_range(
tcx: TyCtxt<'_>,
markdown: &str,
md_range: &Range<usize>,
fragments: &[DocFragment],
) -> Option<Span> {
use rustc_span::BytePos;

let map = tcx.sess.source_map();
if let &[fragment] = &fragments
&& fragment.kind == DocFragmentKind::RawDoc
&& let Ok(snippet) = tcx.sess.source_map().span_to_snippet(fragment.span)
&& let Ok(snippet) = map.span_to_snippet(fragment.span)
&& snippet.trim_end() == markdown.trim_end()
&& let Ok(md_range_lo) = u32::try_from(md_range.start)
&& let Ok(md_range_hi) = u32::try_from(md_range.end)
Expand All @@ -544,10 +554,43 @@ pub fn source_span_for_markdown_range(
let is_all_sugared_doc = fragments.iter().all(|frag| frag.kind == DocFragmentKind::SugaredDoc);

if !is_all_sugared_doc {
// This case ignores the markdown outside of the range so that it can
// work in cases where the markdown is made from several different
// doc fragments, but the target range does not span across multiple
// fragments.
let mut match_data = None;
let pat = &markdown[md_range.clone()];
// This heirustic doesn't make sense with a zero-sized range.
if pat.is_empty() {
return None;
}
for (i, fragment) in fragments.iter().enumerate() {
if let Ok(snippet) = map.span_to_snippet(fragment.span)
&& let Some(match_start) = snippet.find(pat)
{
// If there is either a match in a previous fragment, or
// multiple matches in this fragment, there is ambiguity.
if match_data.is_none() && !snippet[match_start + 1..].contains(pat) {
match_data = Some((i, match_start));
} else {
// Heirustic produced ambiguity, return nothing.
return None;
}
}
}
if let Some((i, match_start)) = match_data {
let sp = fragments[i].span;
// we need to calculate the span start,
// then use that in our calulations for the span end
let lo = sp.lo() + BytePos(match_start as u32);
return Some(
sp.with_lo(lo).with_hi(lo + BytePos((md_range.end - md_range.start) as u32)),
);
}
return None;
}

let snippet = tcx.sess.source_map().span_to_snippet(span_of_fragments(fragments)?).ok()?;
let snippet = map.span_to_snippet(span_of_fragments(fragments)?).ok()?;

let starting_line = markdown[..md_range.start].matches('\n').count();
let ending_line = starting_line + markdown[md_range.start..md_range.end].matches('\n').count();
Expand Down
27 changes: 13 additions & 14 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,8 @@ symbols! {
// unnamed method parameters, crate root module, error recovery etc.
// Matching predicates: `is_special`/`is_reserved`
//
// Notes about `kw::Empty`:
// - Its use can blur the lines between "empty symbol" and "no symbol".
// Using `Option<Symbol>` is preferable, where possible, because that
// is unambiguous.
// - For dummy symbols that are never used and absolutely must be
// present, it's better to use `sym::dummy` than `kw::Empty`, because
// it's clearer that it's intended as a dummy value, and more likely
// to be detected if it accidentally does get used.
// tidy-alphabetical-start
DollarCrate: "$crate",
Empty: "",
PathRoot: "{{root}}",
Underscore: "_",
// tidy-alphabetical-end
Expand Down Expand Up @@ -863,7 +854,7 @@ symbols! {
drop_types_in_const,
dropck_eyepatch,
dropck_parametricity,
dummy: "<!dummy!>", // use this instead of `kw::Empty` for symbols that won't be used
dummy: "<!dummy!>", // use this instead of `sym::empty` for symbols that won't be used
dummy_cgu_name,
dylib,
dyn_compatible_for_dispatch,
Expand All @@ -882,6 +873,14 @@ symbols! {
emit_enum_variant_arg,
emit_struct,
emit_struct_field,
// Notes about `sym::empty`:
// - It should only be used when it genuinely means "empty symbol". Use
// `Option<Symbol>` when "no symbol" is a possibility.
// - For dummy symbols that are never used and absolutely must be
// present, it's better to use `sym::dummy` than `sym::empty`, because
// it's clearer that it's intended as a dummy value, and more likely
// to be detected if it accidentally does get used.
empty: "",
emscripten_wasm_eh,
enable,
encode,
Expand Down Expand Up @@ -2361,7 +2360,7 @@ impl Ident {
#[inline]
/// Constructs a new identifier from a symbol and a span.
pub fn new(name: Symbol, span: Span) -> Ident {
debug_assert_ne!(name, kw::Empty);
debug_assert_ne!(name, sym::empty);
Ident { name, span }
}

Expand Down Expand Up @@ -2583,7 +2582,7 @@ impl Symbol {
}

pub fn is_empty(self) -> bool {
self == kw::Empty
self == sym::empty
}

/// This method is supposed to be used in error messages, so it's expected to be
Expand All @@ -2592,7 +2591,7 @@ impl Symbol {
/// or edition, so we have to guess the rawness using the global edition.
pub fn to_ident_string(self) -> String {
// Avoid creating an empty identifier, because that asserts in debug builds.
if self == kw::Empty { String::new() } else { Ident::with_dummy_span(self).to_string() }
if self == sym::empty { String::new() } else { Ident::with_dummy_span(self).to_string() }
}
}

Expand Down Expand Up @@ -2772,7 +2771,7 @@ impl Symbol {

/// Returns `true` if this symbol can be a raw identifier.
pub fn can_be_raw(self) -> bool {
self != kw::Empty && self != kw::Underscore && !self.is_path_segment_keyword()
self != sym::empty && self != kw::Underscore && !self.is_path_segment_keyword()
}

/// Was this symbol predefined in the compiler's `symbols!` macro
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_symbol_mangling/src/v0.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use rustc_middle::ty::{
self, FloatTy, GenericArg, GenericArgKind, Instance, IntTy, ReifyReason, Ty, TyCtxt,
TypeVisitable, TypeVisitableExt, UintTy,
};
use rustc_span::kw;
use rustc_span::sym;

pub(super) fn mangle<'tcx>(
tcx: TyCtxt<'tcx>,
Expand Down Expand Up @@ -902,7 +902,7 @@ impl<'tcx> Printer<'tcx> for SymbolMangler<'tcx> {
print_prefix,
ns,
disambiguated_data.disambiguator as u64,
name.unwrap_or(kw::Empty).as_str(),
name.unwrap_or(sym::empty).as_str(),
)
}

Expand Down
38 changes: 26 additions & 12 deletions library/std/src/io/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,30 +38,44 @@ use crate::sys_common::{FromInner, IntoInner};
/// > not rely on a particular capacity: an application should be designed so that a reading process
/// > consumes data as soon as it is available, so that a writing process does not remain blocked.
///
/// # Examples
/// # Example
///
/// ```no_run
/// # #[cfg(miri)] fn main() {}
/// # #[cfg(not(miri))]
/// # fn main() -> std::io::Result<()> {
/// use std::io::{Read, Write, pipe};
/// use std::process::Command;
/// use std::io::{pipe, Read, Write};
/// let (ping_rx, mut ping_tx) = pipe()?;
/// let (mut pong_rx, pong_tx) = pipe()?;
/// let (ping_reader, mut ping_writer) = pipe()?;
/// let (mut pong_reader, pong_writer) = pipe()?;
///
/// // Spawn a process that echoes its input.
/// let mut echo_server = Command::new("cat").stdin(ping_rx).stdout(pong_tx).spawn()?;
/// // Spawn a child process that echoes its input.
/// let mut echo_command = Command::new("cat");
/// echo_command.stdin(ping_reader);
/// echo_command.stdout(pong_writer);
/// let mut echo_child = echo_command.spawn()?;
///
/// ping_tx.write_all(b"hello")?;
/// // Close to unblock echo_server's reader.
/// drop(ping_tx);
/// // Send input to the child process. Note that because we're writing all the input before we
/// // read any output, this could deadlock if the child's input and output pipe buffers both
/// // filled up. Those buffers are usually at least a few KB, so "hello" is fine, but for longer
/// // inputs we'd need to read and write at the same time, e.g. using threads.
/// ping_writer.write_all(b"hello")?;
///
/// // `cat` exits when it reads EOF from stdin, but that can't happen while any ping writer
/// // remains open. We need to drop our ping writer, or read_to_string will deadlock below.
/// drop(ping_writer);
///
/// // The pong reader can't report EOF while any pong writer remains open. Our Command object is
/// // holding a pong writer, and again read_to_string will deadlock if we don't drop it.
/// drop(echo_command);
///
/// let mut buf = String::new();
/// // Block until echo_server's writer is closed.
/// pong_rx.read_to_string(&mut buf)?;
/// // Block until `cat` closes its stdout (a pong writer).
/// pong_reader.read_to_string(&mut buf)?;
/// assert_eq!(&buf, "hello");
///
/// echo_server.wait()?;
/// // At this point we know `cat` has exited, but we still need to wait to clean up the "zombie".
/// echo_child.wait()?;
/// # Ok(())
/// # }
/// ```
Expand Down
6 changes: 6 additions & 0 deletions library/std/src/os/net/linux_ext/addr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ pub trait SocketAddrExt: Sealed {
///
/// ```no_run
/// use std::os::unix::net::{UnixListener, SocketAddr};
/// #[cfg(target_os = "linux")]
/// use std::os::linux::net::SocketAddrExt;
/// #[cfg(target_os = "android")]
/// use std::os::android::net::SocketAddrExt;
///
/// fn main() -> std::io::Result<()> {
/// let addr = SocketAddr::from_abstract_name(b"hidden")?;
Expand All @@ -48,7 +51,10 @@ pub trait SocketAddrExt: Sealed {
///
/// ```no_run
/// use std::os::unix::net::{UnixListener, SocketAddr};
/// #[cfg(target_os = "linux")]
/// use std::os::linux::net::SocketAddrExt;
/// #[cfg(target_os = "android")]
/// use std::os::android::net::SocketAddrExt;
///
/// fn main() -> std::io::Result<()> {
/// let name = b"hidden";
Expand Down
Loading
Loading