Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
88a3c51
std: use `OnceLock` for SGX argument storage
joboet Jun 20, 2026
83f5101
Look for the cdb architecture that corresponds to the target triple
Fulgen301 Jul 10, 2026
f5c700e
riscv: update c-variadic test for LLVM changes
durin42 Jul 10, 2026
64e2dd5
pretty-print: use inline asm's actual macro name
jakobjung10 Jul 10, 2026
920f3f1
Suggest `generic_const_args` + `type const` in const operation diagno…
Dnreikronos May 26, 2026
9211a89
Update const generic diagnostic fixture
Dnreikronos Jul 7, 2026
d905d0a
Add regression test for dollar-prefixed fragments in a repetition
asuto15 Jul 11, 2026
74dc8e7
shrink mir::Statement to 40 bytes
panstromek Jul 9, 2026
fbef898
Fix PR number in bootstrap's change tracker
Kobzol Jul 11, 2026
8d2a7cd
Rollup merge of #159126 - Kobzol:bootstrap-fix-pr-number, r=Mark-Simu…
JonathanBrouwer Jul 11, 2026
eacfb62
Rollup merge of #156968 - Dnreikronos:fix/gca-const-item-diagnostic-1…
JonathanBrouwer Jul 11, 2026
91fead8
Rollup merge of #159012 - panstromek:make-stmtdebuginfos-smaller, r=J…
JonathanBrouwer Jul 11, 2026
1e145d1
Rollup merge of #158182 - joboet:sgx_args_oncelock, r=clarfonthey
JonathanBrouwer Jul 11, 2026
0d0780f
Rollup merge of #159114 - asuto15:macro-fragment-regression, r=chenyu…
JonathanBrouwer Jul 11, 2026
7f020fd
Rollup merge of #159060 - Fulgen301:bootstrap-cdb-discovery-target, r…
JonathanBrouwer Jul 11, 2026
220ed50
Rollup merge of #159089 - durin42:llvm-23-riscv-asm, r=folkertdev
JonathanBrouwer Jul 11, 2026
85f0f56
Rollup merge of #159093 - jakobjung10:pretty-print-asm-macro-name, r=…
JonathanBrouwer Jul 11, 2026
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_pretty/src/pprust/state/expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ impl<'a> State<'a> {
}
ast::ExprKind::InlineAsm(a) => {
// FIXME: Print `builtin # asm` once macro `asm` uses `builtin_syntax`.
self.word("asm!");
self.word(format!("{}!", a.asm_macro.macro_name()));
self.print_inline_asm(a);
}
ast::ExprKind::FormatArgs(fmt) => {
Expand Down
15 changes: 9 additions & 6 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,13 +431,16 @@ impl<'tcx> ForbidParamUsesFolder<'tcx> {
diag.span_note(impl_.self_ty.span, "not a concrete type");
}
}
if matches!(self.context, ForbidParamContext::ConstArgument)
&& self.tcx.features().min_generic_const_args()
{
if !self.tcx.features().generic_const_args() {
diag.help("add `#![feature(generic_const_args)]` to allow generic expressions as the RHS of const items");
} else {
if matches!(self.context, ForbidParamContext::ConstArgument) {
if self.tcx.features().generic_const_args() {
diag.help("consider factoring the expression into a `type const` item and use it as the const argument instead");
} else if self.tcx.features().min_generic_const_args() {
diag.help("add `#![feature(generic_const_args)]` and extract the expression into a `type const` item");
} else if self.tcx.sess.is_nightly_build() {
diag.help(
"add `#![feature(generic_const_exprs)]` to allow generic const expressions",
);
diag.help("alternatively, you can use `#![feature(generic_const_args)]` and extract the expression into a `type const` item");
}
}
diag.emit()
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1739,7 +1739,7 @@ impl<'a> State<'a> {
self.print_expr_cond_paren(result, self.precedence(result) < ExprPrecedence::Jump);
}
hir::ExprKind::InlineAsm(asm) => {
self.word("asm!");
self.word(format!("{}!", asm.asm_macro.macro_name()));
self.print_inline_asm(asm);
}
hir::ExprKind::OffsetOf(container, fields) => {
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_middle/src/mir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1730,10 +1730,10 @@ mod size_asserts {

use super::*;
// tidy-alphabetical-start
static_assert_size!(BasicBlockData<'_>, 160);
static_assert_size!(BasicBlockData<'_>, 144);
static_assert_size!(LocalDecl<'_>, 40);
static_assert_size!(SourceScopeData<'_>, 64);
static_assert_size!(Statement<'_>, 56);
static_assert_size!(Statement<'_>, 40);
static_assert_size!(Terminator<'_>, 104);
static_assert_size!(VarDebugInfo<'_>, 88);
// tidy-alphabetical-end
Expand Down
86 changes: 64 additions & 22 deletions compiler/rustc_middle/src/mir/statement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

use std::ops;

use rustc_data_structures::outline;
use tracing::{debug, instrument};

use super::interpret::GlobalAlloc;
Expand Down Expand Up @@ -1034,66 +1035,107 @@ impl RawPtrKind {
}
}

// FIXME(panstromek)
// I'd like to use real ThinVec here, but it fails to borrow check,
// probably because ThinVec doesn't have #[may_dangle] on Drop impl?
type ThinVec<T> = Option<Box<Vec<T>>>;

// This collection is almost always empty, so we
// use thin representation and optimize all methods
// for that by inlining the empty check
// and outlining the rest.
#[derive(Default, Debug, Clone, TyEncodable, TyDecodable, StableHash, TypeFoldable, TypeVisitable)]
pub struct StmtDebugInfos<'tcx>(Vec<StmtDebugInfo<'tcx>>);
pub struct StmtDebugInfos<'tcx>(ThinVec<StmtDebugInfo<'tcx>>);

impl<'tcx> StmtDebugInfos<'tcx> {
pub fn push(&mut self, debuginfo: StmtDebugInfo<'tcx>) {
self.0.push(debuginfo);
self.0.get_or_insert_default().push(debuginfo);
}

#[inline]
pub fn drop_debuginfo(&mut self) {
self.0.clear();
match &mut self.0 {
None => (),
Some(v) => outline(move || v.clear()),
}
}

#[inline]
pub fn is_empty(&self) -> bool {
self.0.is_empty()
match &self.0 {
None => true,
Some(v) => outline(move || v.is_empty()),
}
}

#[inline]
pub fn prepend(&mut self, debuginfos: &mut Self) {
if debuginfos.is_empty() {
return;
};
debuginfos.0.append(self);
std::mem::swap(debuginfos, self);
outline(move || {
debuginfos.append(self);
std::mem::swap(debuginfos, self);
})
}

#[inline]
pub fn append(&mut self, debuginfos: &mut Self) {
if debuginfos.is_empty() {
return;
};
self.0.append(debuginfos);
outline(move || {
self.0.get_or_insert_default().append(debuginfos.0.as_mut().unwrap().as_mut())
});
}

#[inline]
pub fn extend(&mut self, debuginfos: &Self) {
if debuginfos.is_empty() {
return;
};
self.0.extend_from_slice(debuginfos);
outline(move || self.0.get_or_insert_default().extend_from_slice(debuginfos.as_slice()))
}

#[inline]
pub fn as_slice(&self) -> &[StmtDebugInfo<'tcx>] {
match &self.0 {
None => &[],
Some(items) => outline(move || items.as_slice()),
}
}

#[inline]
pub fn as_mut_slice(&mut self) -> &mut [StmtDebugInfo<'tcx>] {
match &mut self.0 {
None => &mut [],
Some(items) => outline(move || items.as_mut_slice()),
}
}
#[inline]
pub fn retain_locals(&mut self, locals: &DenseBitSet<Local>) {
self.retain(|debuginfo| match debuginfo {
StmtDebugInfo::AssignRef(local, _) | StmtDebugInfo::InvalidAssign(local) => {
locals.contains(*local)
}
});
match &mut self.0 {
None => (),
Some(items) => outline(move || {
items.retain(|debuginfo| match debuginfo {
StmtDebugInfo::AssignRef(local, _) | StmtDebugInfo::InvalidAssign(local) => {
locals.contains(*local)
}
})
}),
}
}
}

impl<'tcx> ops::Deref for StmtDebugInfos<'tcx> {
type Target = Vec<StmtDebugInfo<'tcx>>;
type Target = [StmtDebugInfo<'tcx>];

#[inline]
fn deref(&self) -> &Vec<StmtDebugInfo<'tcx>> {
&self.0
fn deref(&self) -> &Self::Target {
self.as_slice()
}
}

impl<'tcx> ops::DerefMut for StmtDebugInfos<'tcx> {
#[inline]
fn deref_mut(&mut self) -> &mut Vec<StmtDebugInfo<'tcx>> {
&mut self.0
fn deref_mut(&mut self) -> &mut Self::Target {
self.as_mut_slice()
}
}

Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,10 @@ pub(crate) struct ParamInNonTrivialAnonConst {
"consider factoring the expression into a `type const` item and use it as the const argument instead"
)]
pub(crate) help_gca: bool,
#[help(
"alternatively, you can use `#![feature(generic_const_args)]` and extract the expression into a `type const` item"
)]
pub(crate) help_suggest_gca: bool,
}

#[derive(Debug)]
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_resolve/src/error_helper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1288,9 +1288,11 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
span,
name,
param_kind: is_type,
help: self.tcx.sess.is_nightly_build(),
help: self.tcx.sess.is_nightly_build()
&& !self.tcx.features().min_generic_const_args(),
is_gca,
help_gca: is_gca,
help_suggest_gca: self.tcx.sess.is_nightly_build() && !is_gca,
})
}
ResolutionError::ParamInEnumDiscriminant { name, param_kind: is_type } => {
Expand Down
5 changes: 4 additions & 1 deletion compiler/rustc_resolve/src/late/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3981,9 +3981,12 @@ impl<'ast, 'ra, 'tcx> LateResolutionVisitor<'_, 'ast, 'ra, 'tcx> {
span: lifetime_ref.ident.span,
name: lifetime_ref.ident.name,
param_kind: diagnostics::ParamKindInNonTrivialAnonConst::Lifetime,
help: self.r.tcx.sess.is_nightly_build(),
help: self.r.tcx.sess.is_nightly_build()
&& !self.r.features.min_generic_const_args(),
is_gca: self.r.features.generic_const_args(),
help_gca: self.r.features.generic_const_args(),
help_suggest_gca: self.r.tcx.sess.is_nightly_build()
&& !self.r.features.generic_const_args(),
})
.emit()
}
Expand Down
18 changes: 8 additions & 10 deletions library/std/src/sys/args/sgx.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#![allow(implicit_provenance_casts)] // FIXME: this module systematically confuses pointers and integers

use crate::ffi::OsString;
use crate::num::NonZero;
use crate::ops::Try;
use crate::sync::atomic::{Atomic, AtomicUsize, Ordering};
use crate::sync::OnceLock;
use crate::sys::FromInner;
use crate::sys::os_str::Buf;
use crate::sys::pal::abi::usercalls::alloc;
Expand All @@ -13,8 +11,7 @@ use crate::{fmt, slice};
// Specifying linkage/symbol name is solely to ensure a single instance between this crate and its unit tests
#[cfg_attr(test, linkage = "available_externally")]
#[unsafe(export_name = "_ZN16__rust_internals3std3sys3sgx4args4ARGSE")]
static ARGS: Atomic<usize> = AtomicUsize::new(0);
type ArgsStore = Vec<OsString>;
static ARGS: OnceLock<Vec<OsString>> = OnceLock::new();

#[cfg_attr(test, allow(dead_code))]
pub unsafe fn init(argc: isize, argv: *const *const u8) {
Expand All @@ -23,15 +20,16 @@ pub unsafe fn init(argc: isize, argv: *const *const u8) {
let args = args
.iter()
.map(|a| OsString::from_inner(Buf { inner: a.copy_user_buffer() }))
.collect::<ArgsStore>();
ARGS.store(Box::into_raw(Box::new(args)) as _, Ordering::Relaxed);
.collect::<Vec<_>>();

if let Err(_) = ARGS.set(args) {
rtabort!("init called twice");
}
}
}

pub fn args() -> Args {
let args = unsafe { (ARGS.load(Ordering::Relaxed) as *const ArgsStore).as_ref() };
let slice = args.map(|args| args.as_slice()).unwrap_or(&[]);
Args { iter: slice.iter() }
Args { iter: ARGS.get().map_or_default(|args| args.iter()) }
}

pub struct Args {
Expand Down
28 changes: 15 additions & 13 deletions src/bootstrap/src/core/debuggers/cdb.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::env;
use std::path::PathBuf;

use crate::core::config::TargetSelection;
Expand All @@ -8,18 +7,19 @@ pub(crate) struct Cdb {
}

/// We consult the registry to find the installed cdb.exe and try "Program Files" if that fails.
#[cfg(windows)]
pub(crate) fn discover_cdb(target: TargetSelection) -> Option<Cdb> {
if !cfg!(windows) || !target.ends_with("-pc-windows-msvc") {
if !target.ends_with("-pc-windows-msvc") {
return None;
}

let cdb_arch = if cfg!(target_arch = "x86") {
let cdb_arch = if target.starts_with("i686") {
"x86"
} else if cfg!(target_arch = "x86_64") {
} else if target.starts_with("x86_64") {
"x64"
} else if cfg!(target_arch = "aarch64") {
} else if target.starts_with("aarch64") || target.starts_with("arm64") {
"arm64"
} else if cfg!(target_arch = "arm") {
} else if target.starts_with("arm") || target.starts_with("thumb") {
"arm"
} else {
return None; // No compatible CDB.exe in the Windows 10 SDK
Expand All @@ -29,6 +29,11 @@ pub(crate) fn discover_cdb(target: TargetSelection) -> Option<Cdb> {
Some(Cdb { cdb: path })
}

#[cfg(not(windows))]
pub(crate) fn discover_cdb(_target: TargetSelection) -> Option<Cdb> {
None
}

#[cfg(windows)]
fn discover_cdb_registry(cdb_arch: &'static str) -> Option<PathBuf> {
use windows_registry::LOCAL_MACHINE;
Expand All @@ -39,14 +44,11 @@ fn discover_cdb_registry(cdb_arch: &'static str) -> Option<PathBuf> {
path.exists().then_some(path)
}

#[cfg(not(windows))]
fn discover_cdb_registry(_cdb_arch: &'static str) -> Option<PathBuf> {
None
}

#[cfg(windows)]
fn discover_cdb_program_files(cdb_arch: &'static str) -> Option<PathBuf> {
let mut path =
PathBuf::from(env::var_os("ProgramFiles(x86)").or_else(|| env::var_os("ProgramFiles"))?);
let mut path = PathBuf::from(
std::env::var_os("ProgramFiles(x86)").or_else(|| std::env::var_os("ProgramFiles"))?,
);
path.extend([r"Windows Kits\10\Debuggers", cdb_arch, r"cdb.exe"]);
path.exists().then_some(path)
}
2 changes: 1 addition & 1 deletion src/bootstrap/src/utils/change_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ pub const CONFIG_CHANGE_HISTORY: &[ChangeInfo] = &[
summary: "New option `rust.compress-debuginfo` allows configuring whether Rust and C/C++ debuginfo should be compressed.",
},
ChangeInfo {
change_id: 999999,
change_id: 158912,
severity: ChangeSeverity::Info,
summary: "New config section `pgo` was introduced, to configure PGO profiling options. The `--rust-profile-use`/`--rust-profile-generate`/`--llvm-profile-use`/`--llvm-profile-generate` flags and the `rust.profile-use`/`rust.profile-generate` config options have been deprecated.",
},
Expand Down
Loading
Loading