Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 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
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
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
fb296d7
Use f64 NaN in documentation instead of sqrt(-1.0)
tyilo 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
f982bc6
Fix ICE: can't type-check body of DefId, since type_consts don't have…
Keith-Cancel Jan 8, 2026
ccc86f2
std: sys: fs: uefi: Implement File::write
Ayush1325 Jan 9, 2026
14c6e60
Add missing documentation for globs feature
oncecelll Jan 10, 2026
a0df7b2
compiler: Forward attributes to eii-expanded macros
Enselic Jan 10, 2026
9b81154
once again reorganize the EII tests a bit
jdonszelmann Jan 10, 2026
5081393
Don't run the longer partial-sort tests under Miri
Zalathar Jan 11, 2026
c680b74
Rollup merge of #150947 - partial-sort-miri, r=tgross35
Zalathar Jan 11, 2026
dda4963
Rollup merge of #148196 - std-fs-iterative-create-dir-all, r=Mark-Sim…
Zalathar Jan 11, 2026
30585eb
Rollup merge of #150494 - extern_linkage_dso_local, r=bjorn3
Zalathar Jan 11, 2026
8a5c66e
Rollup merge of #150788 - thir-pat, r=Nadrieril
Zalathar Jan 11, 2026
e25d7a8
Rollup merge of #150799 - mcga, r=BoxyUwU
Zalathar Jan 11, 2026
26da51d
Rollup merge of #150804 - std_detect_less_features, r=tgross35
Zalathar Jan 11, 2026
ebd5d75
Rollup merge of #150852 - uefi-fs-write, r=joboet
Zalathar Jan 11, 2026
72c9c8c
Rollup merge of #150871 - simplify-partialord-doc, r=jhpratt
Zalathar Jan 11, 2026
5b685d7
Rollup merge of #150878 - bpf_staticlib_error, r=Urgau
Zalathar Jan 11, 2026
c2448d7
Rollup merge of #150911 - master, r=Kivooeo
Zalathar Jan 11, 2026
1987b15
Rollup merge of #150913 - eii-macro-attrs, r=jdonszelmann
Zalathar Jan 11, 2026
c6a3792
Rollup merge of #150916 - eii-test-reorg, r=jieyouxu
Zalathar Jan 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
6 changes: 6 additions & 0 deletions compiler/rustc_builtin_macros/src/eii.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ fn eii_(
macro_name,
foreign_item_name,
impl_unsafe,
&attrs_from_decl,
)));

return_items.into_iter().map(wrap_item).collect()
Expand Down Expand Up @@ -416,9 +417,14 @@ fn generate_attribute_macro_to_implement(
macro_name: Ident,
foreign_item_name: Ident,
impl_unsafe: bool,
attrs_from_decl: &[Attribute],
) -> ast::Item {
let mut macro_attrs = ThinVec::new();

// To avoid e.g. `error: attribute macro has missing stability attribute`
// errors for eii's in std.
macro_attrs.extend_from_slice(attrs_from_decl);

// #[builtin_macro(eii_shared_macro)]
macro_attrs.push(ecx.attr_nested_word(sym::rustc_builtin_macro, sym::eii_shared_macro, span));

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
2 changes: 1 addition & 1 deletion compiler/rustc_feature/src/accepted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ declare_features! (
(accepted, generic_param_attrs, "1.27.0", Some(48848)),
/// Allows the `#[global_allocator]` attribute.
(accepted, global_allocator, "1.28.0", Some(27389)),
// FIXME: explain `globs`.
/// Allows globs imports (`use module::*;`) to import all public items from a module.
(accepted, globs, "1.0.0", None),
/// Allows using `..=X` as a pattern.
(accepted, half_open_range_patterns, "1.66.0", Some(67264)),
Expand Down
17 changes: 16 additions & 1 deletion compiler/rustc_hir_analysis/src/collect/type_of.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,22 @@ fn infer_placeholder_type<'tcx>(
kind: &'static str,
) -> Ty<'tcx> {
let tcx = cx.tcx();
let ty = tcx.typeck(def_id).node_type(hir_id);
// If the type is omitted on a #[type_const] we can't run
// type check on since that requires the const have a body
// which type_consts don't.
let ty = if tcx.is_type_const(def_id.to_def_id()) {
if let Some(trait_item_def_id) = tcx.trait_item_of(def_id.to_def_id()) {
tcx.type_of(trait_item_def_id).instantiate_identity()
} else {
Ty::new_error_with_message(
tcx,
ty_span,
"constant with #[type_const] requires an explicit type",
)
}
} else {
tcx.typeck(def_id).node_type(hir_id)
};

// If this came from a free `const` or `static mut?` item,
// then the user may have written e.g. `const A = 42;`.
Expand Down
38 changes: 17 additions & 21 deletions compiler/rustc_middle/src/thir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,10 +643,26 @@ pub struct FieldPat<'tcx> {
pub pattern: Pat<'tcx>,
}

/// Additional per-node data that is not present on most THIR pattern nodes.
#[derive(Clone, Debug, Default, HashStable, TypeVisitable)]
pub struct PatExtra<'tcx> {
/// If present, this node represents a named constant that was lowered to
/// a pattern using `const_to_pat`.
///
/// This is used by some diagnostics for non-exhaustive matches, to map
/// the pattern node back to the `DefId` of its original constant.
pub expanded_const: Option<DefId>,

/// User-written types that must be preserved into MIR so that they can be
/// checked.
pub ascriptions: Vec<Ascription<'tcx>>,
}

#[derive(Clone, Debug, HashStable, TypeVisitable)]
pub struct Pat<'tcx> {
pub ty: Ty<'tcx>,
pub span: Span,
pub extra: Option<Box<PatExtra<'tcx>>>,
pub kind: PatKind<'tcx>,
}

Expand Down Expand Up @@ -762,11 +778,6 @@ pub enum PatKind<'tcx> {
/// A wildcard pattern: `_`.
Wild,

AscribeUserType {
ascription: Ascription<'tcx>,
subpattern: Box<Pat<'tcx>>,
},

/// `x`, `ref x`, `x @ P`, etc.
Binding {
name: Symbol,
Expand Down Expand Up @@ -831,21 +842,6 @@ pub enum PatKind<'tcx> {
value: ty::Value<'tcx>,
},

/// Wrapper node representing a named constant that was lowered to a pattern
/// using `const_to_pat`.
///
/// This is used by some diagnostics for non-exhaustive matches, to map
/// the pattern node back to the `DefId` of its original constant.
///
/// FIXME(#150498): Can we make this an `Option<DefId>` field on `Pat`
/// instead, so that non-diagnostic code can ignore it more easily?
ExpandedConstant {
/// [DefId] of the constant item.
def_id: DefId,
/// The pattern that the constant lowered to.
subpattern: Box<Pat<'tcx>>,
},

Range(Arc<PatRange<'tcx>>),

/// Matches against a slice, checking the length and extracting elements.
Expand Down Expand Up @@ -1119,7 +1115,7 @@ mod size_asserts {
static_assert_size!(Block, 48);
static_assert_size!(Expr<'_>, 64);
static_assert_size!(ExprKind<'_>, 40);
static_assert_size!(Pat<'_>, 64);
static_assert_size!(Pat<'_>, 72);
static_assert_size!(PatKind<'_>, 48);
static_assert_size!(Stmt<'_>, 48);
static_assert_size!(StmtKind<'_>, 48);
Expand Down
8 changes: 3 additions & 5 deletions compiler/rustc_middle/src/thir/visit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ pub(crate) fn for_each_immediate_subpat<'a, 'tcx>(
pat: &'a Pat<'tcx>,
mut callback: impl FnMut(&'a Pat<'tcx>),
) {
let Pat { kind, ty: _, span: _ } = pat;
let Pat { kind, ty: _, span: _, extra: _ } = pat;
match kind {
PatKind::Missing
| PatKind::Wild
Expand All @@ -269,11 +269,9 @@ pub(crate) fn for_each_immediate_subpat<'a, 'tcx>(
| PatKind::Never
| PatKind::Error(_) => {}

PatKind::AscribeUserType { subpattern, .. }
| PatKind::Binding { subpattern: Some(subpattern), .. }
PatKind::Binding { subpattern: Some(subpattern), .. }
| PatKind::Deref { subpattern }
| PatKind::DerefPattern { subpattern, .. }
| PatKind::ExpandedConstant { subpattern, .. } => callback(subpattern),
| PatKind::DerefPattern { subpattern, .. } => callback(subpattern),

PatKind::Variant { subpatterns, .. } | PatKind::Leaf { subpatterns } => {
for field_pat in subpatterns {
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_middle/src/ty/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1891,6 +1891,12 @@ impl<'tcx> TyCtxt<'tcx> {
self.is_lang_item(self.parent(def_id), LangItem::AsyncDropInPlace)
}

/// Check if the given `def_id` is a const with the `#[type_const]` attribute.
pub fn is_type_const(self, def_id: DefId) -> bool {
matches!(self.def_kind(def_id), DefKind::Const | DefKind::AssocConst)
&& find_attr!(self.get_all_attrs(def_id), AttributeKind::TypeConst(_))
}

/// Returns the movability of the coroutine of `def_id`, or panics
/// if given a `def_id` that is not a coroutine.
pub fn coroutine_movability(self, def_id: DefId) -> hir::Movability {
Expand Down
24 changes: 8 additions & 16 deletions compiler/rustc_mir_build/src/builder/custom/parse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,22 +287,14 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
self.parse_var(pattern)
}

fn parse_var(&mut self, mut pat: &Pat<'tcx>) -> PResult<(LocalVarId, Ty<'tcx>, Span)> {
// Make sure we throw out any `AscribeUserType` we find
loop {
match &pat.kind {
PatKind::Binding { var, ty, .. } => break Ok((*var, *ty, pat.span)),
PatKind::AscribeUserType { subpattern, .. } => {
pat = subpattern;
}
_ => {
break Err(ParseError {
span: pat.span,
item_description: format!("{:?}", pat.kind),
expected: "local".to_string(),
});
}
}
fn parse_var(&mut self, pat: &Pat<'tcx>) -> PResult<(LocalVarId, Ty<'tcx>, Span)> {
match &pat.kind {
PatKind::Binding { var, ty, .. } => Ok((*var, *ty, pat.span)),
_ => Err(ParseError {
span: pat.span,
item_description: format!("{:?}", pat.kind),
expected: "local".to_string(),
}),
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,6 @@ impl<'a, 'tcx> ParseCtxt<'a, 'tcx> {
let arm = &self.thir[*arm];
let value = match arm.pattern.kind {
PatKind::Constant { value } => value,
PatKind::ExpandedConstant { ref subpattern, def_id: _ }
if let PatKind::Constant { value } = subpattern.kind =>
{
value
}
_ => {
return Err(ParseError {
span: arm.pattern.span,
Expand Down
10 changes: 9 additions & 1 deletion compiler/rustc_mir_build/src/builder/expr/as_constant.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! See docs in build/expr/mod.rs

use rustc_abi::Size;
use rustc_ast as ast;
use rustc_ast::{self as ast};
use rustc_hir::LangItem;
use rustc_middle::mir::interpret::{CTFE_ALLOC_SALT, LitToConstInput, Scalar};
use rustc_middle::mir::*;
Expand Down Expand Up @@ -47,6 +47,7 @@ pub(crate) fn as_constant_inner<'tcx>(
tcx: TyCtxt<'tcx>,
) -> ConstOperand<'tcx> {
let Expr { ty, temp_scope_id: _, span, ref kind } = *expr;

match *kind {
ExprKind::Literal { lit, neg } => {
let const_ = lit_to_mir_constant(tcx, LitToConstInput { lit: lit.node, ty, neg });
Expand All @@ -69,6 +70,13 @@ pub(crate) fn as_constant_inner<'tcx>(
}
ExprKind::NamedConst { def_id, args, ref user_ty } => {
let user_ty = user_ty.as_ref().and_then(push_cuta);
if tcx.is_type_const(def_id) {
let uneval = ty::UnevaluatedConst::new(def_id, args);
let ct = ty::Const::new_unevaluated(tcx, uneval);

let const_ = Const::Ty(ty, ct);
return ConstOperand { span, user_ty, const_ };
}

let uneval = mir::UnevaluatedConst::new(def_id, args);
let const_ = Const::Unevaluated(uneval, ty);
Expand Down
Loading
Loading