Skip to content
Closed
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
4081c14
create_dir_all() operates iteratively instead of recursively
asder8215 Dec 14, 2025
167ad11
check if current path is root through seeing if its parent is None
asder8215 Dec 14, 2025
1ff953d
Fix and expand direct-access-external-data test
nbdd0121 Dec 29, 2025
5467a39
Fix dso_local for external statics with linkage
nbdd0121 Dec 29, 2025
2b76903
Use all thread::current static variables from realstd in tests.
Dec 18, 2025
abbbd77
Use re-exports from test_internals.
Dec 18, 2025
1cd8752
Unix implementation for stdio set/take/replace
the8472 Jan 4, 2026
a3359bd
Compile-Time Reflection MVP: tuples
oli-obk Mar 12, 2025
82028b0
Add size information
oli-obk Mar 14, 2025
665770e
Remove std_detect_file_io and std_detect_dlsym_getauxval features
bjorn3 Jan 8, 2026
3fed6e6
Remove a couple of outdated fields in std_detect Cargo.toml
bjorn3 Jan 8, 2026
c873d16
Remove unnecessary module
bjorn3 Jan 8, 2026
484ea76
adding minicore to test file to avoid duplicating lang error
paradoxicalguy Dec 31, 2025
0495a73
Prepare for `thir::Pat` nodes having multiple user-type ascriptions
Zalathar Jan 7, 2026
f85b898
Prefer to return `Box<thir::Pat>` instead of `thir::PatKind`
Zalathar Jan 6, 2026
bd77048
Initial plumbing for `thir::PatExtra`
Zalathar Jan 6, 2026
8516c64
Replace `AscribeUserType` and `ExpandedConstant` with per-node data
Zalathar Jan 6, 2026
7e433eb
[miri] make closing stdio file descriptions noops
the8472 Jan 9, 2026
fb296d7
Use f64 NaN in documentation instead of sqrt(-1.0)
tyilo Jan 9, 2026
87d7167
Reenable GCC CI download
Kobzol Jan 9, 2026
58a9fdd
Bump `download-ci-gcc-stamp`
Kobzol Jan 9, 2026
e0324b5
Emit an error for linking staticlibs on BPF
bjorn3 Jan 9, 2026
90c84d0
Reduce visibility of some errors
bjorn3 Jan 9, 2026
6426635
Fix unpacking of gcc-dev component
Kobzol Jan 9, 2026
f6f901f
std: sys: fs: uefi: Implement File::{flush, *sync}
Ayush1325 Jan 9, 2026
f982bc6
Fix ICE: can't type-check body of DefId, since type_consts don't have…
Keith-Cancel Jan 8, 2026
fc06a57
Introduce hir::ConstArgKind::Array
reddevilmidzy Jan 7, 2026
618b0b5
Lower hir::ConstArgKind::Array to a ValTree
reddevilmidzy Jan 8, 2026
522be7f
Fix clippy
reddevilmidzy Jan 8, 2026
f2f45ff
Add mGCA array expression tests
reddevilmidzy Jan 9, 2026
ccc86f2
std: sys: fs: uefi: Implement File::write
Ayush1325 Jan 9, 2026
26e666c
Rollup merge of #146923 - comptime-reflect, r=BoxyUwU
Zalathar Jan 10, 2026
9f800a3
Rollup merge of #148196 - std-fs-iterative-create-dir-all, r=Mark-Sim…
Zalathar Jan 10, 2026
3c12560
Rollup merge of #150131 - realstd_thread_variables, r=Mark-Simulacrum
Zalathar Jan 10, 2026
5b02485
Rollup merge of #150368 - minicore-ordering, r=workingjubilee
Zalathar Jan 10, 2026
6cceb00
Rollup merge of #150494 - extern_linkage_dso_local, r=bjorn3
Zalathar Jan 10, 2026
ea1e30f
Rollup merge of #150668 - stdio-swap, r=Mark-Simulacrum,RalfJung
Zalathar Jan 10, 2026
8b58a13
Rollup merge of #150786 - mgca-array, r=BoxyUwU
Zalathar Jan 10, 2026
989cdfe
Rollup merge of #150788 - thir-pat, r=Nadrieril
Zalathar Jan 10, 2026
d4afd4f
Rollup merge of #150799 - mcga, r=BoxyUwU
Zalathar Jan 10, 2026
0138235
Rollup merge of #150804 - std_detect_less_features, r=tgross35
Zalathar Jan 10, 2026
2ba1963
Rollup merge of #150852 - uefi-fs-write, r=joboet
Zalathar Jan 10, 2026
23e3528
Rollup merge of #150862 - uefi-fs-flush, r=the8472
Zalathar Jan 10, 2026
f233c1a
Rollup merge of #150871 - simplify-partialord-doc, r=jhpratt
Zalathar Jan 10, 2026
c91eb06
Rollup merge of #150873 - reenable-gcc-download-ci, r=marcoieni
Zalathar Jan 10, 2026
27cd10c
Rollup merge of #150878 - bpf_staticlib_error, r=Urgau
Zalathar Jan 10, 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
23 changes: 23 additions & 0 deletions compiler/rustc_ast_lowering/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2517,6 +2517,28 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
span,
}
}
ExprKind::Array(elements) => {
let lowered_elems = self.arena.alloc_from_iter(elements.iter().map(|element| {
let const_arg = if let ExprKind::ConstBlock(anon_const) = &element.kind {
let def_id = self.local_def_id(anon_const.id);
assert_eq!(DefKind::AnonConst, self.tcx.def_kind(def_id));
self.lower_anon_const_to_const_arg(anon_const)
} else {
self.lower_expr_to_const_arg_direct(element)
};
&*self.arena.alloc(const_arg)
}));
let array_expr = self.arena.alloc(hir::ConstArgArrayExpr {
span: self.lower_span(expr.span),
elems: lowered_elems,
});

ConstArg {
hir_id: self.next_id(),
kind: hir::ConstArgKind::Array(array_expr),
span,
}
}
ExprKind::Underscore => ConstArg {
hir_id: self.lower_node_id(expr.id),
kind: hir::ConstArgKind::Infer(()),
Expand All @@ -2532,6 +2554,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
| ExprKind::Struct(..)
| ExprKind::Call(..)
| ExprKind::Tup(..)
| ExprKind::Array(..)
)
{
return self.lower_expr_to_const_arg_direct(expr);
Expand Down
4 changes: 4 additions & 0 deletions compiler/rustc_codegen_llvm/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ fn check_and_apply_linkage<'ll, 'tcx>(
};
llvm::set_linkage(g1, base::linkage_to_llvm(linkage));

// Normally this is done in `get_static_inner`, but when as we generate an internal global,
// it will apply the dso_local to the internal global instead, so do it here, too.
cx.assume_dso_local(g1, true);

// Declare an internal global `extern_with_linkage_foo` which
// is initialized with the address of `foo`. If `foo` is
// discarded during linking (for example, if `foo` has weak
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_codegen_ssa/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ codegen_ssa_archive_build_failure = failed to build archive at `{$path}`: {$erro
codegen_ssa_binary_output_to_tty = option `-o` or `--emit` is used to write binary output type `{$shorthand}` to stdout, but stdout is a tty
codegen_ssa_bpf_staticlib_not_supported = linking static libraries is not supported for BPF
codegen_ssa_cgu_not_recorded =
CGU-reuse for `{$cgu_user_name}` is (mangled: `{$cgu_name}`) was not recorded
Expand Down
7 changes: 4 additions & 3 deletions compiler/rustc_codegen_ssa/src/back/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@ use tracing::trace;

use super::metadata::{create_compressed_metadata_file, search_for_section};
use crate::common;
// Re-exporting for rustc_codegen_llvm::back::archive
pub use crate::errors::{ArchiveBuildFailure, ExtractBundledLibsError, UnknownArchiveKind};
// Public for ArchiveBuilderBuilder::extract_bundled_libs
pub use crate::errors::ExtractBundledLibsError;
use crate::errors::{
DlltoolFailImportLibrary, ErrorCallingDllTool, ErrorCreatingImportLibrary, ErrorWritingDEFFile,
ArchiveBuildFailure, DlltoolFailImportLibrary, ErrorCallingDllTool, ErrorCreatingImportLibrary,
ErrorWritingDEFFile, UnknownArchiveKind,
};

/// An item to be included in an import library.
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/back/linker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2075,7 +2075,7 @@ impl<'a> Linker for BpfLinker<'a> {
}

fn link_staticlib_by_name(&mut self, _name: &str, _verbatim: bool, _whole_archive: bool) {
panic!("staticlibs not supported")
self.sess.dcx().emit_fatal(errors::BpfStaticlibNotSupported)
}

fn link_staticlib_by_path(&mut self, path: &Path, _whole_archive: bool) {
Expand Down
12 changes: 7 additions & 5 deletions compiler/rustc_codegen_ssa/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ pub(crate) struct RlibArchiveBuildFailure {
}

#[derive(Diagnostic)]
// Public for rustc_codegen_llvm::back::archive
// Public for ArchiveBuilderBuilder::extract_bundled_libs
pub enum ExtractBundledLibsError<'a> {
#[diag(codegen_ssa_extract_bundled_libs_open_file)]
OpenFile { rlib: &'a Path, error: Box<dyn std::error::Error> },
Expand Down Expand Up @@ -700,19 +700,21 @@ pub(crate) struct UnsupportedLinkSelfContained;

#[derive(Diagnostic)]
#[diag(codegen_ssa_archive_build_failure)]
// Public for rustc_codegen_llvm::back::archive
pub struct ArchiveBuildFailure {
pub(crate) struct ArchiveBuildFailure {
pub path: PathBuf,
pub error: std::io::Error,
}

#[derive(Diagnostic)]
#[diag(codegen_ssa_unknown_archive_kind)]
// Public for rustc_codegen_llvm::back::archive
pub struct UnknownArchiveKind<'a> {
pub(crate) struct UnknownArchiveKind<'a> {
pub kind: &'a str,
}

#[derive(Diagnostic)]
#[diag(codegen_ssa_bpf_staticlib_not_supported)]
pub(crate) struct BpfStaticlibNotSupported;

#[derive(Diagnostic)]
#[diag(codegen_ssa_multiple_main_functions)]
#[help]
Expand Down
12 changes: 3 additions & 9 deletions compiler/rustc_const_eval/src/check_consts/qualifs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
// having basically only two use-cases that act in different ways.

use rustc_errors::ErrorGuaranteed;
use rustc_hir::attrs::AttributeKind;
use rustc_hir::def::DefKind;
use rustc_hir::{LangItem, find_attr};
use rustc_hir::LangItem;
use rustc_infer::infer::TyCtxtInferExt;
use rustc_middle::mir::*;
use rustc_middle::ty::{self, AdtDef, Ty};
Expand Down Expand Up @@ -366,14 +364,10 @@ where
// check performed after the promotion. Verify that with an assertion.
assert!(promoted.is_none() || Q::ALLOW_PROMOTED);

// Avoid looking at attrs of anon consts as that will ICE
let is_type_const_item =
matches!(cx.tcx.def_kind(def), DefKind::Const | DefKind::AssocConst)
&& find_attr!(cx.tcx.get_all_attrs(def), AttributeKind::TypeConst(_));

// Don't peak inside trait associated constants, also `#[type_const] const` items
// don't have bodies so there's nothing to look at
if promoted.is_none() && cx.tcx.trait_of_assoc(def).is_none() && !is_type_const_item {
if promoted.is_none() && cx.tcx.trait_of_assoc(def).is_none() && !cx.tcx.is_type_const(def)
{
let qualifs = cx.tcx.at(constant.span).mir_const_qualif(def);

if !Q::in_qualifs(&qualifs) {
Expand Down
9 changes: 7 additions & 2 deletions compiler/rustc_const_eval/src/const_eval/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use rustc_data_structures::fx::{FxHashMap, FxIndexMap, IndexEntry};
use rustc_hir::def_id::{DefId, LocalDefId};
use rustc_hir::{self as hir, CRATE_HIR_ID, LangItem};
use rustc_middle::mir::AssertMessage;
use rustc_middle::mir::interpret::ReportedErrorInfo;
use rustc_middle::mir::interpret::{Pointer, ReportedErrorInfo};
use rustc_middle::query::TyCtxtAt;
use rustc_middle::ty::layout::{HasTypingEnv, TyAndLayout, ValidityRequirement};
use rustc_middle::ty::{self, Ty, TyCtxt};
Expand All @@ -22,7 +22,7 @@ use crate::errors::{LongRunning, LongRunningWarn};
use crate::fluent_generated as fluent;
use crate::interpret::{
self, AllocId, AllocInit, AllocRange, ConstAllocation, CtfeProvenance, FnArg, Frame,
GlobalAlloc, ImmTy, InterpCx, InterpResult, OpTy, PlaceTy, Pointer, RangeSet, Scalar,
GlobalAlloc, ImmTy, InterpCx, InterpResult, OpTy, PlaceTy, RangeSet, Scalar,
compile_time_machine, err_inval, interp_ok, throw_exhaust, throw_inval, throw_ub,
throw_ub_custom, throw_unsup, throw_unsup_format,
};
Expand Down Expand Up @@ -586,6 +586,11 @@ impl<'tcx> interpret::Machine<'tcx> for CompileTimeMachine<'tcx> {
}
}

sym::type_of => {
let ty = ecx.read_type_id(&args[0])?;
ecx.write_type_info(ty, dest)?;
}

_ => {
// We haven't handled the intrinsic, let's see if we can use a fallback body.
if ecx.tcx.intrinsic(instance.def_id()).unwrap().must_be_overridden {
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_const_eval/src/const_eval/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ mod error;
mod eval_queries;
mod fn_queries;
mod machine;
mod type_info;
mod valtrees;

pub use self::dummy_machine::*;
Expand Down
175 changes: 175 additions & 0 deletions compiler/rustc_const_eval/src/const_eval/type_info.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
use rustc_abi::FieldIdx;
use rustc_hir::LangItem;
use rustc_middle::mir::interpret::CtfeProvenance;
use rustc_middle::span_bug;
use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{self, ScalarInt, Ty};
use rustc_span::{Symbol, sym};

use crate::const_eval::CompileTimeMachine;
use crate::interpret::{
Immediate, InterpCx, InterpResult, MPlaceTy, MemoryKind, Writeable, interp_ok,
};

impl<'tcx> InterpCx<'tcx, CompileTimeMachine<'tcx>> {
/// Writes a `core::mem::type_info::TypeInfo` for a given type, `ty` to the given place.
pub(crate) fn write_type_info(
&mut self,
ty: Ty<'tcx>,
dest: &impl Writeable<'tcx, CtfeProvenance>,
) -> InterpResult<'tcx> {
let ty_struct = self.tcx.require_lang_item(LangItem::Type, self.tcx.span);
let ty_struct = self.tcx.type_of(ty_struct).no_bound_vars().unwrap();
assert_eq!(ty_struct, dest.layout().ty);
let ty_struct = ty_struct.ty_adt_def().unwrap().non_enum_variant();
// Fill all fields of the `TypeInfo` struct.
for (idx, field) in ty_struct.fields.iter_enumerated() {
let field_dest = self.project_field(dest, idx)?;
let downcast = |name: Symbol| {
let variants = field_dest.layout().ty.ty_adt_def().unwrap().variants();
let variant_id = variants
.iter_enumerated()
.find(|(_idx, var)| var.name == name)
.unwrap_or_else(|| panic!("got {name} but expected one of {variants:#?}"))
.0;

interp_ok((variant_id, self.project_downcast(&field_dest, variant_id)?))
};
match field.name {
sym::kind => {
let variant_index = match ty.kind() {
ty::Tuple(fields) => {
let (variant, variant_place) = downcast(sym::Tuple)?;
// project to the single tuple variant field of `type_info::Tuple` struct type
let tuple_place = self.project_field(&variant_place, FieldIdx::ZERO)?;
assert_eq!(
1,
tuple_place
.layout()
.ty
.ty_adt_def()
.unwrap()
.non_enum_variant()
.fields
.len()
);
self.write_tuple_fields(tuple_place, fields, ty)?;
variant
}
// For now just merge all primitives into one `Leaf` variant with no data
ty::Uint(_) | ty::Int(_) | ty::Float(_) | ty::Char | ty::Bool => {
downcast(sym::Leaf)?.0
}
ty::Adt(_, _)
| ty::Foreign(_)
| ty::Str
| ty::Array(_, _)
| ty::Pat(_, _)
| ty::Slice(_)
| ty::RawPtr(..)
| ty::Ref(..)
| ty::FnDef(..)
| ty::FnPtr(..)
| ty::UnsafeBinder(..)
| ty::Dynamic(..)
| ty::Closure(..)
| ty::CoroutineClosure(..)
| ty::Coroutine(..)
| ty::CoroutineWitness(..)
| ty::Never
| ty::Alias(..)
| ty::Param(_)
| ty::Bound(..)
| ty::Placeholder(_)
| ty::Infer(..)
| ty::Error(_) => downcast(sym::Other)?.0,
};
self.write_discriminant(variant_index, &field_dest)?
}
sym::size => {
let layout = self.layout_of(ty)?;
let variant_index = if layout.is_sized() {
let (variant, variant_place) = downcast(sym::Some)?;
let size_field_place =
self.project_field(&variant_place, FieldIdx::ZERO)?;
self.write_scalar(
ScalarInt::try_from_target_usize(layout.size.bytes(), self.tcx.tcx)
.unwrap(),
&size_field_place,
)?;
variant
} else {
downcast(sym::None)?.0
};
self.write_discriminant(variant_index, &field_dest)?;
}
other => span_bug!(self.tcx.span, "unknown `Type` field {other}"),
}
}

interp_ok(())
}

pub(crate) fn write_tuple_fields(
&mut self,
tuple_place: impl Writeable<'tcx, CtfeProvenance>,
fields: &[Ty<'tcx>],
tuple_ty: Ty<'tcx>,
) -> InterpResult<'tcx> {
// project into the `type_info::Tuple::fields` field
let fields_slice_place = self.project_field(&tuple_place, FieldIdx::ZERO)?;
// get the `type_info::Field` type from `fields: &[Field]`
let field_type = fields_slice_place
.layout()
.ty
.builtin_deref(false)
.unwrap()
.sequence_element_type(self.tcx.tcx);
// Create an array with as many elements as the number of fields in the inspected tuple
let fields_layout =
self.layout_of(Ty::new_array(self.tcx.tcx, field_type, fields.len() as u64))?;
let fields_place = self.allocate(fields_layout, MemoryKind::Stack)?;
let mut fields_places = self.project_array_fields(&fields_place)?;

let tuple_layout = self.layout_of(tuple_ty)?;

while let Some((i, place)) = fields_places.next(self)? {
let field_ty = fields[i as usize];
self.write_field(field_ty, place, tuple_layout, i)?;
}

let fields_place = fields_place.map_provenance(CtfeProvenance::as_immutable);

let ptr = Immediate::new_slice(fields_place.ptr(), fields.len() as u64, self);

self.write_immediate(ptr, &fields_slice_place)
}

fn write_field(
&mut self,
field_ty: Ty<'tcx>,
place: MPlaceTy<'tcx>,
layout: TyAndLayout<'tcx>,
idx: u64,
) -> InterpResult<'tcx> {
for (field_idx, field_ty_field) in
place.layout.ty.ty_adt_def().unwrap().non_enum_variant().fields.iter_enumerated()
{
let field_place = self.project_field(&place, field_idx)?;
match field_ty_field.name {
sym::ty => self.write_type_id(field_ty, &field_place)?,
sym::offset => {
let offset = layout.fields.offset(idx as usize);
self.write_scalar(
ScalarInt::try_from_target_usize(offset.bytes(), self.tcx.tcx).unwrap(),
&field_place,
)?;
}
other => {
span_bug!(self.tcx.def_span(field_ty_field.did), "unimplemented field {other}")
}
}
}
interp_ok(())
}
}
5 changes: 3 additions & 2 deletions compiler/rustc_const_eval/src/interpret/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ use super::{
throw_ub_custom, throw_ub_format,
};
use crate::fluent_generated as fluent;
use crate::interpret::Writeable;

#[derive(Copy, Clone, Debug, PartialEq, Eq)]
enum MulAddType {
Expand Down Expand Up @@ -68,10 +69,10 @@ pub(crate) fn alloc_type_name<'tcx>(tcx: TyCtxt<'tcx>, ty: Ty<'tcx>) -> (AllocId
}
impl<'tcx, M: Machine<'tcx>> InterpCx<'tcx, M> {
/// Generates a value of `TypeId` for `ty` in-place.
fn write_type_id(
pub(crate) fn write_type_id(
&mut self,
ty: Ty<'tcx>,
dest: &PlaceTy<'tcx, M::Provenance>,
dest: &impl Writeable<'tcx, M::Provenance>,
) -> InterpResult<'tcx, ()> {
let tcx = self.tcx;
let type_id_hash = tcx.type_id_hash(ty).as_u128();
Expand Down
Loading
Loading