Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
1cd8752
Unix implementation for stdio set/take/replace
the8472 Jan 4, 2026
3c136cc
Fix broken documentation links to SipHash
eggyal Jan 9, 2026
45e0fbf
Implement partial_sort_unstable for slice
tisonkun Jan 9, 2026
484ea76
adding minicore to test file to avoid duplicating lang error
paradoxicalguy Dec 31, 2025
c29178d
Introduce hir::ConstArgKind::Array
reddevilmidzy Jan 7, 2026
bac0a18
Lower hir::ConstArgKind::Array to a ValTree
reddevilmidzy Jan 8, 2026
21e092f
Fix clippy
reddevilmidzy Jan 8, 2026
49b8c2b
Add mGCA array expression tests
reddevilmidzy Jan 9, 2026
7e433eb
[miri] make closing stdio file descriptions noops
the8472 Jan 9, 2026
b9ae4f7
rustdoc_json: Remove one call to `std::mem::take` in `after_krate`.
Hywan Jan 9, 2026
6063ac1
Emit error instead of delayed bug when meeting mismatch type for cons…
mu001999 Jan 9, 2026
01e8f14
Mention that `rustc_codegen_gcc` is a subtree in `rustc-dev-guide`
GuillaumeGomez Jan 9, 2026
2cde8d9
Fix std::fs::copy on WASI by setting proper OpenOptions flags
cdmurph32 Jan 9, 2026
2f35424
Rename tests for const tuple properly
mu001999 Jan 9, 2026
43c1db7
Run clippy
cdmurph32 Jan 9, 2026
c1d3005
Rollup merge of #149318 - slice_partial_sort_unstable, r=tgross35
tgross35 Jan 9, 2026
946ae71
Rollup merge of #150368 - minicore-ordering, r=workingjubilee
tgross35 Jan 9, 2026
cafda8d
Rollup merge of #150668 - stdio-swap, r=Mark-Simulacrum,RalfJung
tgross35 Jan 9, 2026
45c921e
Rollup merge of #150786 - mgca-array, r=BoxyUwU
tgross35 Jan 9, 2026
f01e8d9
Rollup merge of #150847 - siphash-doc-link, r=joboet
tgross35 Jan 9, 2026
776517c
Rollup merge of #150867 - chore-librustdoc-json-mem-take, r=Guillaume…
tgross35 Jan 9, 2026
417f15b
Rollup merge of #150869 - fix/150841, r=BoxyUwU
tgross35 Jan 9, 2026
d5ec0d3
Rollup merge of #150876 - gcc-dev-guide, r=Kobzol
tgross35 Jan 9, 2026
a255817
Rollup merge of #150881 - fix-wasi-fs-copy, r=alexcrichton
tgross35 Jan 9, 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
8 changes: 8 additions & 0 deletions compiler/rustc_hir/src/hir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,8 @@ pub enum ConstArgKind<'hir, Unambig = ()> {
Struct(QPath<'hir>, &'hir [&'hir ConstArgExprField<'hir>]),
/// Tuple constructor variant
TupleCall(QPath<'hir>, &'hir [&'hir ConstArg<'hir>]),
/// Array literal argument
Array(&'hir ConstArgArrayExpr<'hir>),
/// Error const
Error(ErrorGuaranteed),
/// This variant is not always used to represent inference consts, sometimes
Expand All @@ -529,6 +531,12 @@ pub struct ConstArgExprField<'hir> {
pub expr: &'hir ConstArg<'hir>,
}

#[derive(Clone, Copy, Debug, HashStable_Generic)]
pub struct ConstArgArrayExpr<'hir> {
pub span: Span,
pub elems: &'hir [&'hir ConstArg<'hir>],
}

#[derive(Clone, Copy, Debug, HashStable_Generic)]
pub struct InferArg {
#[stable_hasher(ignore)]
Expand Down
6 changes: 6 additions & 0 deletions compiler/rustc_hir/src/intravisit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1101,6 +1101,12 @@ pub fn walk_const_arg<'v, V: Visitor<'v>>(
}
V::Result::output()
}
ConstArgKind::Array(array_expr) => {
for arg in array_expr.elems {
try_visit!(visitor.visit_const_arg_unambig(*arg));
}
V::Result::output()
}
ConstArgKind::Path(qpath) => visitor.visit_qpath(qpath, *hir_id, qpath.span()),
ConstArgKind::Anon(anon) => visitor.visit_anon_const(*anon),
ConstArgKind::Error(_) => V::Result::output(), // errors and spans are not important
Expand Down
36 changes: 34 additions & 2 deletions compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2389,6 +2389,7 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
hir::ConstArgKind::TupleCall(qpath, args) => {
self.lower_const_arg_tuple_call(hir_id, qpath, args, const_arg.span)
}
hir::ConstArgKind::Array(array_expr) => self.lower_const_arg_array(array_expr, feed),
hir::ConstArgKind::Anon(anon) => self.lower_const_arg_anon(anon),
hir::ConstArgKind::Infer(()) => self.ct_infer(None, const_arg.span),
hir::ConstArgKind::Error(e) => ty::Const::new_error(tcx, e),
Expand All @@ -2402,6 +2403,36 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
}
}

fn lower_const_arg_array(
&self,
array_expr: &'tcx hir::ConstArgArrayExpr<'tcx>,
feed: FeedConstTy<'tcx>,
) -> Const<'tcx> {
let tcx = self.tcx();

let FeedConstTy::WithTy(ty) = feed else {
return Const::new_error_with_message(tcx, array_expr.span, "unsupported const array");
};

let ty::Array(elem_ty, _) = ty.kind() else {
return Const::new_error_with_message(
tcx,
array_expr.span,
"const array must have an array type",
);
};

let elems = array_expr
.elems
.iter()
.map(|elem| self.lower_const_arg(elem, FeedConstTy::WithTy(*elem_ty)))
.collect::<Vec<_>>();

let valtree = ty::ValTree::from_branches(tcx, elems);

ty::Const::new_value(tcx, valtree, ty)
}

fn lower_const_arg_tuple_call(
&self,
hir_id: HirId,
Expand Down Expand Up @@ -2502,11 +2533,12 @@ impl<'tcx> dyn HirTyLowerer<'tcx> + '_ {
let tcx = self.tcx();

let FeedConstTy::WithTy(ty) = feed else {
return Const::new_error_with_message(tcx, span, "unsupported const tuple");
return Const::new_error_with_message(tcx, span, "const tuple lack type information");
};

let ty::Tuple(tys) = ty.kind() else {
return Const::new_error_with_message(tcx, span, "const tuple must have a tuple type");
let e = tcx.dcx().span_err(span, format!("expected `{}`, found const tuple", ty));
return Const::new_error(tcx, e);
};

let exprs = exprs
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_hir_pretty/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1153,6 +1153,7 @@ impl<'a> State<'a> {
}
ConstArgKind::Struct(qpath, fields) => self.print_const_struct(qpath, fields),
ConstArgKind::TupleCall(qpath, args) => self.print_const_ctor(qpath, args),
ConstArgKind::Array(..) => self.word("/* ARRAY EXPR */"),
ConstArgKind::Path(qpath) => self.print_qpath(qpath, true),
ConstArgKind::Anon(anon) => self.print_anon_const(anon),
ConstArgKind::Error(_) => self.word("/*ERROR*/"),
Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_metadata/src/rmeta/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@ impl<'a, 'tcx> EncodeContext<'a, 'tcx> {
// Skip encoding defs for these as they should not have had a `DefId` created
hir::ConstArgKind::Error(..)
| hir::ConstArgKind::Struct(..)
| hir::ConstArgKind::Array(..)
| hir::ConstArgKind::TupleCall(..)
| hir::ConstArgKind::Tup(..)
| hir::ConstArgKind::Path(..)
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/def_collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl<'a, 'ra, 'tcx> visit::Visitor<'a> for DefCollector<'a, 'ra, 'tcx> {

// Avoid overwriting `const_arg_context` as we may want to treat const blocks
// as being anon consts if we are inside a const argument.
ExprKind::Struct(_) | ExprKind::Call(..) | ExprKind::Tup(..) => {
ExprKind::Struct(_) | ExprKind::Call(..) | ExprKind::Tup(..) | ExprKind::Array(..) => {
return visit::walk_expr(self, expr);
}
// FIXME(mgca): we may want to handle block labels in some manner
Expand Down
2 changes: 2 additions & 0 deletions library/alloctests/tests/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#![feature(binary_heap_into_iter_sorted)]
#![feature(binary_heap_drain_sorted)]
#![feature(slice_ptr_get)]
#![feature(slice_range)]
#![feature(slice_partial_sort_unstable)]
#![feature(inplace_iteration)]
#![feature(iter_advance_by)]
#![feature(iter_next_chunk)]
Expand Down
1 change: 1 addition & 0 deletions library/alloctests/tests/sort/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub trait Sort {

mod ffi_types;
mod known_good_stable_sort;
mod partial;
mod patterns;
mod tests;
mod zipf;
84 changes: 84 additions & 0 deletions library/alloctests/tests/sort/partial.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
use std::fmt::Debug;
use std::ops::{Range, RangeBounds};
use std::slice;

use super::patterns;

fn check_is_partial_sorted<T: Ord + Clone + Debug, R: RangeBounds<usize>>(v: &mut [T], range: R) {
let Range { start, end } = slice::range(range, ..v.len());
v.partial_sort_unstable(start..end);

let max_before = v[..start].iter().max().into_iter();
let sorted_range = v[start..end].into_iter();
let min_after = v[end..].iter().min().into_iter();
let seq = max_before.chain(sorted_range).chain(min_after);
assert!(seq.is_sorted());
}

fn check_is_partial_sorted_ranges<T: Ord + Clone + Debug>(v: &[T]) {
let len = v.len();

check_is_partial_sorted::<T, _>(&mut v.to_vec(), ..);
check_is_partial_sorted::<T, _>(&mut v.to_vec(), 0..0);
check_is_partial_sorted::<T, _>(&mut v.to_vec(), len..len);

if len > 0 {
check_is_partial_sorted::<T, _>(&mut v.to_vec(), len - 1..len - 1);
check_is_partial_sorted::<T, _>(&mut v.to_vec(), 0..1);
check_is_partial_sorted::<T, _>(&mut v.to_vec(), len - 1..len);

for mid in 1..len {
check_is_partial_sorted::<T, _>(&mut v.to_vec(), 0..mid);
check_is_partial_sorted::<T, _>(&mut v.to_vec(), mid..len);
check_is_partial_sorted::<T, _>(&mut v.to_vec(), mid..mid);
check_is_partial_sorted::<T, _>(&mut v.to_vec(), mid - 1..mid + 1);
check_is_partial_sorted::<T, _>(&mut v.to_vec(), mid - 1..mid);
check_is_partial_sorted::<T, _>(&mut v.to_vec(), mid..mid + 1);
}

let quarters = [0, len / 4, len / 2, (3 * len) / 4, len];
for &start in &quarters {
for &end in &quarters {
if start < end {
check_is_partial_sorted::<T, _>(&mut v.to_vec(), start..end);
}
}
}
}
}

#[test]
fn basic_impl() {
check_is_partial_sorted::<i32, _>(&mut [], ..);
check_is_partial_sorted::<(), _>(&mut [], ..);
check_is_partial_sorted::<(), _>(&mut [()], ..);
check_is_partial_sorted::<(), _>(&mut [(), ()], ..);
check_is_partial_sorted::<(), _>(&mut [(), (), ()], ..);
check_is_partial_sorted::<i32, _>(&mut [], ..);

check_is_partial_sorted::<i32, _>(&mut [77], ..);
check_is_partial_sorted::<i32, _>(&mut [2, 3], ..);
check_is_partial_sorted::<i32, _>(&mut [2, 3, 6], ..);
check_is_partial_sorted::<i32, _>(&mut [2, 3, 99, 6], ..);
check_is_partial_sorted::<i32, _>(&mut [2, 7709, 400, 90932], ..);
check_is_partial_sorted::<i32, _>(&mut [15, -1, 3, -1, -3, -1, 7], ..);

check_is_partial_sorted::<i32, _>(&mut [15, -1, 3, -1, -3, -1, 7], 0..0);
check_is_partial_sorted::<i32, _>(&mut [15, -1, 3, -1, -3, -1, 7], 0..1);
check_is_partial_sorted::<i32, _>(&mut [15, -1, 3, -1, -3, -1, 7], 0..5);
check_is_partial_sorted::<i32, _>(&mut [15, -1, 3, -1, -3, -1, 7], 0..7);
check_is_partial_sorted::<i32, _>(&mut [15, -1, 3, -1, -3, -1, 7], 7..7);
check_is_partial_sorted::<i32, _>(&mut [15, -1, 3, -1, -3, -1, 7], 6..7);
check_is_partial_sorted::<i32, _>(&mut [15, -1, 3, -1, -3, -1, 7], 5..7);
check_is_partial_sorted::<i32, _>(&mut [15, -1, 3, -1, -3, -1, 7], 5..5);
check_is_partial_sorted::<i32, _>(&mut [15, -1, 3, -1, -3, -1, 7], 4..5);
check_is_partial_sorted::<i32, _>(&mut [15, -1, 3, -1, -3, -1, 7], 4..6);
}

#[test]
fn random_patterns() {
check_is_partial_sorted_ranges(&patterns::random(10));
check_is_partial_sorted_ranges(&patterns::random(50));
check_is_partial_sorted_ranges(&patterns::random(100));
check_is_partial_sorted_ranges(&patterns::random(1000));
}
6 changes: 3 additions & 3 deletions library/core/src/hash/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{cmp, ptr};
/// This is currently the default hashing function used by standard library
/// (e.g., `collections::HashMap` uses it by default).
///
/// See: <https://131002.net/siphash>
/// See: <https://github.com/veorq/SipHash>
#[unstable(feature = "hashmap_internals", issue = "none")]
#[deprecated(since = "1.13.0", note = "use `std::hash::DefaultHasher` instead")]
#[derive(Debug, Clone, Default)]
Expand All @@ -21,7 +21,7 @@ pub struct SipHasher13 {

/// An implementation of SipHash 2-4.
///
/// See: <https://131002.net/siphash/>
/// See: <https://github.com/veorq/SipHash>
#[unstable(feature = "hashmap_internals", issue = "none")]
#[deprecated(since = "1.13.0", note = "use `std::hash::DefaultHasher` instead")]
#[derive(Debug, Clone, Default)]
Expand All @@ -31,7 +31,7 @@ struct SipHasher24 {

/// An implementation of SipHash 2-4.
///
/// See: <https://131002.net/siphash/>
/// See: <https://github.com/veorq/SipHash>
///
/// SipHash is a general-purpose hashing function: it runs at a good
/// speed (competitive with Spooky and City) and permits strong _keyed_
Expand Down
Loading
Loading