Skip to content

Rollup of 9 pull requests #144490

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 22 commits into from
Jul 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
b676f55
rustdoc: add ways of collapsing all impl blocks
lolbinarycat May 27, 2025
978e11b
Upgrade the `fortanix-sgx-abi` dependency
tgross35 Jul 1, 2025
69b9bae
Guarantee 8 bytes of alignment in Thread::into_raw
orlp Jul 12, 2025
6f4d0bd
Tidy
orlp Jul 12, 2025
1d0eddb
tests: debuginfo: Work around or disable broken tests on powerpc
Gelbpunkt Jul 18, 2025
e1b6cfe
Rephrase comment to include some tracking issues
Gelbpunkt Jul 21, 2025
b8d628c
Use LocalKey<Cell> methods more
camsteffen Jul 22, 2025
e958b20
Fix unused_parens false positive
benschulz Jul 9, 2025
6fc68c1
Add test case for single bound
benschulz Jul 10, 2025
307f664
Replace unwrap_or with explicit match
benschulz Jul 24, 2025
730d33d
`loop_match`: suggest extracting to a `const` item
folkertdev Jul 7, 2025
1f4561b
Don't lint against named labels in `naked_asm!`
Amanieu May 9, 2025
53018dc
Disable has_reliable_f128_math on musl targets
Gelbpunkt Jul 25, 2025
33ed3fc
Rollup merge of #140871 - Amanieu:naked-asm-label, r=compiler-errors
tgross35 Jul 26, 2025
7abb4e2
Rollup merge of #141663 - lolbinarycat:rustdoc-collapse-impl-134429, …
tgross35 Jul 26, 2025
3b99668
Rollup merge of #143272 - tgross35:bump-fortanix, r=jhpratt,jethrogb
tgross35 Jul 26, 2025
d8f4ceb
Rollup merge of #143585 - folkertdev:loop-match-suggest-const-block, …
tgross35 Jul 26, 2025
75ed6de
Rollup merge of #143698 - benschulz:unused-parens-2, r=lcnr,compiler-…
tgross35 Jul 26, 2025
2fcea9f
Rollup merge of #143859 - orlp:thread-into-raw-align, r=jhpratt
tgross35 Jul 26, 2025
0f557ab
Rollup merge of #144160 - Gelbpunkt:debuginfo-tests-ppc, r=oli-obk
tgross35 Jul 26, 2025
bfacbf2
Rollup merge of #144412 - camsteffen:localkey-cell-refactors, r=petro…
tgross35 Jul 26, 2025
39141d0
Rollup merge of #144431 - Gelbpunkt:f128-math-musl, r=petrochenkov,tg…
tgross35 Jul 26, 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
2 changes: 1 addition & 1 deletion compiler/rustc_ast/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2849,7 +2849,7 @@ impl InlineAsmOperand {
}
}

#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable_Generic, Walkable)]
#[derive(Clone, Copy, Encodable, Decodable, Debug, HashStable_Generic, Walkable, PartialEq, Eq)]
pub enum AsmMacro {
/// The `asm!` macro
Asm,
Expand Down
3 changes: 3 additions & 0 deletions compiler/rustc_codegen_llvm/src/llvm_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,9 @@ fn update_target_reliable_float_cfg(sess: &Session, cfg: &mut TargetConfig) {
// This rules out anything that doesn't have `long double` = `binary128`; <= 32 bits
// (ld is `f64`), anything other than Linux (Windows and MacOS use `f64`), and `x86`
// (ld is 80-bit extended precision).
//
// musl does not implement the symbols required for f128 math at all.
_ if target_env == "musl" => false,
("x86_64", _) => false,
(_, "linux") if target_pointer_width == 64 => true,
_ => false,
Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_errors/src/markdown/term.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ thread_local! {
pub(crate) fn entrypoint(stream: &MdStream<'_>, buf: &mut Buffer) -> io::Result<()> {
#[cfg(not(test))]
if let Some((w, _)) = termize::dimensions() {
WIDTH.with(|c| c.set(std::cmp::min(w, DEFAULT_COLUMN_WIDTH)));
WIDTH.set(std::cmp::min(w, DEFAULT_COLUMN_WIDTH));
}
write_stream(stream, buf, None, 0)?;
buf.write_all(b"\n")
Expand Down Expand Up @@ -84,7 +84,7 @@ fn write_tt(tt: &MdTree<'_>, buf: &mut Buffer, indent: usize) -> io::Result<()>
reset_cursor();
}
MdTree::HorizontalRule => {
(0..WIDTH.with(Cell::get)).for_each(|_| buf.write_all(b"-").unwrap());
(0..WIDTH.get()).for_each(|_| buf.write_all(b"-").unwrap());
reset_cursor();
}
MdTree::Heading(n, stream) => {
Expand Down Expand Up @@ -121,7 +121,7 @@ fn write_tt(tt: &MdTree<'_>, buf: &mut Buffer, indent: usize) -> io::Result<()>

/// End of that block, just wrap the line
fn reset_cursor() {
CURSOR.with(|cur| cur.set(0));
CURSOR.set(0);
}

/// Change to be generic on Write for testing. If we have a link URL, we don't
Expand All @@ -144,7 +144,7 @@ fn write_wrapping<B: io::Write>(
buf.write_all(ind_ws)?;
cur.set(indent);
}
let ch_count = WIDTH.with(Cell::get) - cur.get();
let ch_count = WIDTH.get() - cur.get();
let mut iter = to_write.char_indices();
let Some((end_idx, _ch)) = iter.nth(ch_count) else {
// Write entire line
Expand Down
11 changes: 10 additions & 1 deletion compiler/rustc_lint/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2870,14 +2870,23 @@ impl<'tcx> LateLintPass<'tcx> for AsmLabels {
if let hir::Expr {
kind:
hir::ExprKind::InlineAsm(hir::InlineAsm {
asm_macro: AsmMacro::Asm | AsmMacro::NakedAsm,
asm_macro: asm_macro @ (AsmMacro::Asm | AsmMacro::NakedAsm),
template_strs,
options,
..
}),
..
} = expr
{
// Non-generic naked functions are allowed to define arbitrary
// labels.
if *asm_macro == AsmMacro::NakedAsm {
let def_id = expr.hir_id.owner.def_id;
if !cx.tcx.generics_of(def_id).requires_monomorphization(cx.tcx) {
return;
}
}

// asm with `options(raw)` does not do replacement with `{` and `}`.
let raw = options.contains(InlineAsmOptions::RAW);

Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_lint/src/unused.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1340,7 +1340,15 @@ impl EarlyLintPass for UnusedParens {
self.with_self_ty_parens = false;
}
ast::TyKind::Ref(_, mut_ty) | ast::TyKind::Ptr(mut_ty) => {
self.in_no_bounds_pos.insert(mut_ty.ty.id, NoBoundsException::OneBound);
// If this type itself appears in no-bounds position, we propagate its
// potentially tighter constraint or risk a false posive (issue 143653).
let own_constraint = self.in_no_bounds_pos.get(&ty.id);
let constraint = match own_constraint {
Some(NoBoundsException::None) => NoBoundsException::None,
Some(NoBoundsException::OneBound) => NoBoundsException::OneBound,
None => NoBoundsException::OneBound,
};
self.in_no_bounds_pos.insert(mut_ty.ty.id, constraint);
}
ast::TyKind::TraitObject(bounds, _) | ast::TyKind::ImplTrait(_, bounds) => {
for i in 0..bounds.len() {
Expand Down
6 changes: 3 additions & 3 deletions compiler/rustc_middle/src/ty/print/pretty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ macro_rules! define_helper {

impl $helper {
pub fn new() -> $helper {
$helper($tl.with(|c| c.replace(true)))
$helper($tl.replace(true))
}
}

Expand All @@ -100,12 +100,12 @@ macro_rules! define_helper {

impl Drop for $helper {
fn drop(&mut self) {
$tl.with(|c| c.set(self.0))
$tl.set(self.0)
}
}

pub fn $name() -> bool {
$tl.with(|c| c.get())
$tl.get()
}
)+
}
Expand Down
8 changes: 7 additions & 1 deletion compiler/rustc_mir_build/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,16 @@ mir_build_confused = missing patterns are not covered because `{$variable}` is i

mir_build_const_continue_bad_const = could not determine the target branch for this `#[const_continue]`
.label = this value is too generic
.note = the value must be a literal or a monomorphic const

mir_build_const_continue_missing_value = a `#[const_continue]` must break to a label with a value

mir_build_const_continue_not_const = could not determine the target branch for this `#[const_continue]`
.help = try extracting the expression into a `const` item

mir_build_const_continue_not_const_const_block = `const` blocks may use generics, and are not evaluated early enough
mir_build_const_continue_not_const_const_other = this value must be a literal or a monomorphic const
mir_build_const_continue_not_const_constant_parameter = constant parameters may use generics, and are not evaluated early enough

mir_build_const_continue_unknown_jump_target = the target of this `#[const_continue]` is not statically known
.label = this value must be a literal or a monomorphic const

Expand Down
29 changes: 26 additions & 3 deletions compiler/rustc_mir_build/src/builder/scope.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,9 @@ use tracing::{debug, instrument};

use super::matches::BuiltMatchTree;
use crate::builder::{BlockAnd, BlockAndExtension, BlockFrame, Builder, CFG};
use crate::errors::{ConstContinueBadConst, ConstContinueUnknownJumpTarget};
use crate::errors::{
ConstContinueBadConst, ConstContinueNotMonomorphicConst, ConstContinueUnknownJumpTarget,
};

#[derive(Debug)]
pub(crate) struct Scopes<'tcx> {
Expand Down Expand Up @@ -867,7 +869,8 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
span_bug!(span, "break value must be a scope")
};

let constant = match &self.thir[value].kind {
let expr = &self.thir[value];
let constant = match &expr.kind {
ExprKind::Adt(box AdtExpr { variant_index, fields, base, .. }) => {
assert!(matches!(base, AdtExprBase::None));
assert!(fields.is_empty());
Expand All @@ -887,7 +890,27 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
),
}
}
_ => self.as_constant(&self.thir[value]),

ExprKind::Literal { .. }
| ExprKind::NonHirLiteral { .. }
| ExprKind::ZstLiteral { .. }
| ExprKind::NamedConst { .. } => self.as_constant(&self.thir[value]),

other => {
use crate::errors::ConstContinueNotMonomorphicConstReason as Reason;

let span = expr.span;
let reason = match other {
ExprKind::ConstParam { .. } => Reason::ConstantParameter { span },
ExprKind::ConstBlock { .. } => Reason::ConstBlock { span },
_ => Reason::Other { span },
};

self.tcx
.dcx()
.emit_err(ConstContinueNotMonomorphicConst { span: expr.span, reason });
return block.unit();
}
};

let break_index = self
Expand Down
32 changes: 32 additions & 0 deletions compiler/rustc_mir_build/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1213,6 +1213,38 @@ pub(crate) struct LoopMatchArmWithGuard {
pub span: Span,
}

#[derive(Diagnostic)]
#[diag(mir_build_const_continue_not_const)]
#[help]
pub(crate) struct ConstContinueNotMonomorphicConst {
#[primary_span]
pub span: Span,

#[subdiagnostic]
pub reason: ConstContinueNotMonomorphicConstReason,
}

#[derive(Subdiagnostic)]
pub(crate) enum ConstContinueNotMonomorphicConstReason {
#[label(mir_build_const_continue_not_const_constant_parameter)]
ConstantParameter {
#[primary_span]
span: Span,
},

#[label(mir_build_const_continue_not_const_const_block)]
ConstBlock {
#[primary_span]
span: Span,
},

#[label(mir_build_const_continue_not_const_const_other)]
Other {
#[primary_span]
span: Span,
},
}

#[derive(Diagnostic)]
#[diag(mir_build_const_continue_bad_const)]
pub(crate) struct ConstContinueBadConst {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_query_system/src/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ fn incremental_verify_ich_failed<Tcx>(
static INSIDE_VERIFY_PANIC: Cell<bool> = const { Cell::new(false) };
};

let old_in_panic = INSIDE_VERIFY_PANIC.with(|in_panic| in_panic.replace(true));
let old_in_panic = INSIDE_VERIFY_PANIC.replace(true);

if old_in_panic {
tcx.sess().dcx().emit_err(crate::error::Reentrant);
Expand All @@ -739,7 +739,7 @@ fn incremental_verify_ich_failed<Tcx>(
panic!("Found unstable fingerprints for {dep_node:?}: {}", result());
}

INSIDE_VERIFY_PANIC.with(|in_panic| in_panic.set(old_in_panic));
INSIDE_VERIFY_PANIC.set(old_in_panic);
}

/// Ensure that either this query has all green inputs or been executed.
Expand Down
5 changes: 2 additions & 3 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,10 @@ dependencies = [

[[package]]
name = "fortanix-sgx-abi"
version = "0.5.0"
version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57cafc2274c10fab234f176b25903ce17e690fca7597090d50880e047a0389c5"
checksum = "5efc85edd5b83e8394f4371dd0da6859dff63dd387dab8568fece6af4cde6f84"
dependencies = [
"compiler_builtins",
"rustc-std-workspace-core",
]

Expand Down
2 changes: 1 addition & 1 deletion library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ rand_xorshift = "0.4.0"
dlmalloc = { version = "0.2.4", features = ['rustc-dep-of-std'] }

[target.x86_64-fortanix-unknown-sgx.dependencies]
fortanix-sgx-abi = { version = "0.5.0", features = [
fortanix-sgx-abi = { version = "0.6.1", features = [
'rustc-dep-of-std',
], public = true }

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/pal/sgx/abi/usercalls/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ pub fn send(event_set: u64, tcs: Option<Tcs>) -> IoResult<()> {
/// Usercall `insecure_time`. See the ABI documentation for more information.
#[unstable(feature = "sgx_platform", issue = "56975")]
pub fn insecure_time() -> Duration {
let t = unsafe { raw::insecure_time() };
let t = unsafe { raw::insecure_time().0 };
Duration::new(t / 1_000_000_000, (t % 1_000_000_000) as _)
}

Expand Down
8 changes: 7 additions & 1 deletion library/std/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1399,6 +1399,11 @@ where
}

/// The internal representation of a `Thread` handle
///
/// We explicitly set the alignment for our guarantee in Thread::into_raw. This
/// allows applications to stuff extra metadata bits into the alignment, which
/// can be rather useful when working with atomics.
#[repr(align(8))]
struct Inner {
name: Option<ThreadNameString>,
id: ThreadId,
Expand Down Expand Up @@ -1582,7 +1587,8 @@ impl Thread {
/// Consumes the `Thread`, returning a raw pointer.
///
/// To avoid a memory leak the pointer must be converted
/// back into a `Thread` using [`Thread::from_raw`].
/// back into a `Thread` using [`Thread::from_raw`]. The pointer is
/// guaranteed to be aligned to at least 8 bytes.
///
/// # Examples
///
Expand Down
24 changes: 19 additions & 5 deletions src/librustdoc/html/static/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,11 @@ function preLoadCss(cssUrl) {
break;
case "-":
ev.preventDefault();
collapseAllDocs();
collapseAllDocs(false);
break;
case "_":
ev.preventDefault();
collapseAllDocs(true);
break;

case "?":
Expand Down Expand Up @@ -1038,11 +1042,14 @@ function preLoadCss(cssUrl) {
innerToggle.children[0].innerText = "Summary";
}

function collapseAllDocs() {
/**
* @param {boolean} collapseImpls - also collapse impl blocks if set to true
*/
function collapseAllDocs(collapseImpls) {
const innerToggle = document.getElementById(toggleAllDocsId);
addClass(innerToggle, "will-expand");
onEachLazy(document.getElementsByClassName("toggle"), e => {
if (e.parentNode.id !== "implementations-list" ||
if ((collapseImpls || e.parentNode.id !== "implementations-list") ||
(!hasClass(e, "implementors-toggle") &&
!hasClass(e, "type-contents-toggle"))
) {
Expand All @@ -1053,15 +1060,18 @@ function preLoadCss(cssUrl) {
innerToggle.children[0].innerText = "Show all";
}

function toggleAllDocs() {
/**
* @param {MouseEvent=} ev
*/
function toggleAllDocs(ev) {
const innerToggle = document.getElementById(toggleAllDocsId);
if (!innerToggle) {
return;
}
if (hasClass(innerToggle, "will-expand")) {
expandAllDocs();
} else {
collapseAllDocs();
collapseAllDocs(ev !== undefined && ev.shiftKey);
}
}

Expand Down Expand Up @@ -1519,6 +1529,10 @@ function preLoadCss(cssUrl) {
["&#9166;", "Go to active search result"],
["+", "Expand all sections"],
["-", "Collapse all sections"],
// for the sake of brevity, we don't say "inherint impl blocks",
// although that would be more correct,
// since trait impl blocks are collapsed by -
["_", "Collapse all sections, including impl blocks"],
].map(x => "<dt>" +
x[0].split(" ")
.map((y, index) => ((index & 1) === 0 ? "<kbd>" + y + "</kbd>" : " " + y + " "))
Expand Down
4 changes: 3 additions & 1 deletion src/librustdoc/html/static/js/storage.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,9 @@ class RustdocToolbarElement extends HTMLElement {
<div id="help-button" tabindex="-1">
<a href="${rootPath}help.html"><span class="label">Help</span></a>
</div>
<button id="toggle-all-docs"><span class="label">Summary</span></button>`;
<button id="toggle-all-docs"
title="Collapse sections (shift-click to also collapse impl blocks)"><span
class="label">Summary</span></button>`;
}
}
window.customElements.define("rustdoc-toolbar", RustdocToolbarElement);
1 change: 1 addition & 0 deletions src/tools/compiletest/src/directives.rs
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,7 @@ const KNOWN_DIRECTIVE_NAMES: &[&str] = &[
"ignore-openbsd",
"ignore-pass",
"ignore-powerpc",
"ignore-powerpc64",
"ignore-remote",
"ignore-riscv64",
"ignore-rustc-debug-assertions",
Expand Down
7 changes: 6 additions & 1 deletion tests/debuginfo/basic-types-globals-metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,12 @@ static mut F64: f64 = 3.5;
fn main() {
_zzz(); // #break

let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F16, F32, F64) };
let a = unsafe { (B, I, C, I8, I16, I32, I64, U, U8, U16, U32, U64, F32, F64) };
// FIXME: Including f16 and f32 in the same tuple emits `__gnu_h2f_ieee`, which
// does not exist on some targets like PowerPC.
// See https://github.com/llvm/llvm-project/issues/97981 and
// https://github.com/rust-lang/compiler-builtins/issues/655
let b = unsafe { F16 };
}

fn _zzz() {()}
Loading
Loading