Skip to content
Closed
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
0dfdb6c
rlib handling
ZuseZ4 Nov 17, 2025
2d1fc63
adding a working rlib autodiff test
ZuseZ4 Nov 19, 2025
9f49ac3
Add missing trailing period to RustDoc for fn create_dir().
ximon18 Nov 19, 2025
8c4e3ff
fs: Update skipped file lock tests to match flock support
tgross35 Nov 19, 2025
4bf24d2
fs: Expect a test failure if file locks aren't supported
tgross35 Nov 19, 2025
cea9dd8
test: Use an ignore message for fs Android skips
tgross35 Nov 19, 2025
ea3fe53
std: sys: fs: uefi: Fix FileAttr size
Ayush1325 Nov 20, 2025
4adcdbb
In `BTreeMap::eq`, do not compare the elements if the sizes are diffe…
zachs18 Nov 20, 2025
907f5c1
Add regression test for collections' PartialEq::eq impls not comparin…
zachs18 Nov 20, 2025
7ad3c5c
sgx: avoid unnecessarily creating a slice
RalfJung Nov 19, 2025
c8ba2a5
remove an unused variable
fluiderson Nov 20, 2025
3f08502
std: sys: net: uefi: Implement read_vectored
Ayush1325 Nov 20, 2025
1e14a5d
Enable host tools for aarch64-unknown-linux-ohos
12101111 Nov 20, 2025
c2fdcdd
Rollup merge of #149033 - ZuseZ4:autodiff-rlib, r=bjorn3
matthiaskrgr Nov 20, 2025
a7cc95e
Rollup merge of #149088 - ximon18:patch-1, r=ChrisDenton
matthiaskrgr Nov 20, 2025
2ebd100
Rollup merge of #149111 - tgross35:fs-test-updates, r=ChrisDenton
matthiaskrgr Nov 20, 2025
459f594
Rollup merge of #149113 - RalfJung:sgx-less-unsafe, r=ChrisDenton
matthiaskrgr Nov 20, 2025
0b2d422
Rollup merge of #149123 - Ayush1325:uefi-fs-size-fix, r=ChrisDenton
matthiaskrgr Nov 20, 2025
4b4c761
Rollup merge of #149125 - zachs18:btreemap-eq-perf, r=workingjubilee
matthiaskrgr Nov 20, 2025
6724884
Rollup merge of #149133 - fluiderson:rustdoc-json-unused, r=chenyukang
matthiaskrgr Nov 20, 2025
45dafb2
Rollup merge of #149134 - Ayush1325:uefi-tcp4-vector, r=joboet
matthiaskrgr Nov 20, 2025
13031d2
Rollup merge of #149139 - 12101111:ohos-host-tools, r=nnethercote
matthiaskrgr Nov 20, 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
14 changes: 12 additions & 2 deletions compiler/rustc_codegen_llvm/src/intrinsic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use rustc_middle::mir::BinOp;
use rustc_middle::ty::layout::{FnAbiOf, HasTyCtxt, HasTypingEnv, LayoutOf};
use rustc_middle::ty::{self, GenericArgsRef, Instance, SimdAlign, Ty, TyCtxt, TypingEnv};
use rustc_middle::{bug, span_bug};
use rustc_session::config::CrateType;
use rustc_span::{Span, Symbol, sym};
use rustc_symbol_mangling::{mangle_internal_symbol, symbol_name_for_instance_in_crate};
use rustc_target::callconv::PassMode;
Expand Down Expand Up @@ -1136,8 +1137,17 @@ fn codegen_autodiff<'ll, 'tcx>(
if !tcx.sess.opts.unstable_opts.autodiff.contains(&rustc_session::config::AutoDiff::Enable) {
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutEnable);
}
if tcx.sess.lto() != rustc_session::config::Lto::Fat {
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto);

let ct = tcx.crate_types();
let lto = tcx.sess.lto();
if ct.len() == 1 && ct.contains(&CrateType::Executable) {
if lto != rustc_session::config::Lto::Fat {
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto);
}
} else {
if lto != rustc_session::config::Lto::Fat && !tcx.sess.opts.cg.linker_plugin_lto.enabled() {
let _ = tcx.dcx().emit_almost_fatal(AutoDiffWithoutLto);
}
}

let fn_args = instance.args;
Expand Down
8 changes: 8 additions & 0 deletions compiler/rustc_mir_transform/src/cross_crate_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ fn cross_crate_inlinable(tcx: TyCtxt<'_>, def_id: LocalDefId) -> bool {
return true;
}

// FIXME(autodiff): replace this as per discussion in https://github.com/rust-lang/rust/pull/149033#discussion_r2535465880
if tcx.has_attr(def_id, sym::autodiff_forward)
|| tcx.has_attr(def_id, sym::autodiff_reverse)
|| tcx.has_attr(def_id, sym::rustc_autodiff)
{
return true;
}

if tcx.has_attr(def_id, sym::rustc_intrinsic) {
// Intrinsic fallback bodies are always cross-crate inlineable.
// To ensure that the MIR inliner doesn't cluelessly try to inline fallback
Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_monomorphize/src/collector/autodiff.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use crate::collector::{MonoItems, create_fn_mono_item};
// mono so this does not interfere in `autodiff` intrinsics
// codegen process. If they are unused, LLVM will remove them when
// compiling with O3.
// FIXME(autodiff): Remove this whole file, as per discussion in
// https://github.com/rust-lang/rust/pull/149033#discussion_r2535465880
pub(crate) fn collect_autodiff_fn<'tcx>(
tcx: TyCtxt<'tcx>,
instance: ty::Instance<'tcx>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub(crate) fn target() -> Target {
metadata: TargetMetadata {
description: Some("ARM64 OpenHarmony".into()),
tier: Some(2),
host_tools: Some(false),
host_tools: Some(true),
std: Some(true),
},
pointer_width: 64,
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/collections/btree/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2416,7 +2416,7 @@ impl<K, V> Default for BTreeMap<K, V> {
#[stable(feature = "rust1", since = "1.0.0")]
impl<K: PartialEq, V: PartialEq, A: Allocator + Clone> PartialEq for BTreeMap<K, V, A> {
fn eq(&self, other: &BTreeMap<K, V, A>) -> bool {
self.iter().eq(other)
self.len() == other.len() && self.iter().zip(other).all(|(a, b)| a == b)
}
}

Expand Down
96 changes: 96 additions & 0 deletions library/alloctests/tests/collections/eq_diff_len.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//! Regression tests which fail if some collections' `PartialEq::eq` impls compare
//! elements when the collections have different sizes.
//! This behavior is not guaranteed either way, so regressing these tests is fine
//! if it is done on purpose.
use std::cmp::Ordering;
use std::collections::{BTreeMap, BTreeSet, HashMap, HashSet, LinkedList};

/// This intentionally has a panicking `PartialEq` impl, to test that various
/// collections' `PartialEq` impls don't actually compare elements if their sizes
/// are unequal.
///
/// This is not advisable in normal code.
#[derive(Debug, Clone, Copy, Hash)]
struct Evil;

impl PartialEq for Evil {
fn eq(&self, _: &Self) -> bool {
panic!("Evil::eq is evil");
}
}
impl Eq for Evil {}

impl PartialOrd for Evil {
fn partial_cmp(&self, _: &Self) -> Option<Ordering> {
Some(Ordering::Equal)
}
}

impl Ord for Evil {
fn cmp(&self, _: &Self) -> Ordering {
// Constructing a `BTreeSet`/`BTreeMap` uses `cmp` on the elements,
// but comparing it with with `==` uses `eq` on the elements,
// so Evil::cmp doesn't need to be evil.
Ordering::Equal
}
}

// check Evil works
#[test]
#[should_panic = "Evil::eq is evil"]
fn evil_eq_works() {
let v1 = vec![Evil];
let v2 = vec![Evil];

_ = v1 == v2;
}

// check various containers don't compare if their sizes are different

#[test]
fn vec_evil_eq() {
let v1 = vec![Evil];
let v2 = vec![Evil; 2];

assert_eq!(false, v1 == v2);
}

#[test]
fn hashset_evil_eq() {
let s1 = HashSet::from([(0, Evil)]);
let s2 = HashSet::from([(0, Evil), (1, Evil)]);

assert_eq!(false, s1 == s2);
}

#[test]
fn hashmap_evil_eq() {
let m1 = HashMap::from([(0, Evil)]);
let m2 = HashMap::from([(0, Evil), (1, Evil)]);

assert_eq!(false, m1 == m2);
}

#[test]
fn btreeset_evil_eq() {
let s1 = BTreeSet::from([(0, Evil)]);
let s2 = BTreeSet::from([(0, Evil), (1, Evil)]);

assert_eq!(false, s1 == s2);
}

#[test]
fn btreemap_evil_eq() {
let m1 = BTreeMap::from([(0, Evil)]);
let m2 = BTreeMap::from([(0, Evil), (1, Evil)]);

assert_eq!(false, m1 == m2);
}

#[test]
fn linkedlist_evil_eq() {
let m1 = LinkedList::from([Evil]);
let m2 = LinkedList::from([Evil; 2]);

assert_eq!(false, m1 == m2);
}
1 change: 1 addition & 0 deletions library/alloctests/tests/collections/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
mod binary_heap;
mod eq_diff_len;
2 changes: 1 addition & 1 deletion library/std/src/fs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2918,7 +2918,7 @@ pub fn canonicalize<P: AsRef<Path>>(path: P) -> io::Result<PathBuf> {
fs_imp::canonicalize(path.as_ref())
}

/// Creates a new, empty directory at the provided path
/// Creates a new, empty directory at the provided path.
///
/// # Platform-specific behavior
///
Expand Down
123 changes: 67 additions & 56 deletions library/std/src/fs/tests.rs
Original file line number Diff line number Diff line change
@@ -1,24 +1,7 @@
use rand::RngCore;

#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "illumos",
target_vendor = "apple",
))]
use crate::assert_matches::assert_matches;
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "illumos",
target_vendor = "apple",
))]
use crate::fs::TryLockError;
use crate::fs::{self, File, FileTimes, OpenOptions};
use crate::fs::{self, File, FileTimes, OpenOptions, TryLockError};
use crate::io::prelude::*;
use crate::io::{BorrowedBuf, ErrorKind, SeekFrom};
use crate::mem::MaybeUninit;
Expand Down Expand Up @@ -222,15 +205,22 @@ fn file_test_io_seek_and_write() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_vendor = "apple",
))]
#[cfg_attr(
not(any(
windows,
target_os = "aix",
target_os = "cygwin",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_vendor = "apple",
)),
should_panic
)]
fn file_lock_multiple_shared() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_multiple_shared_test.txt");
Expand All @@ -247,15 +237,22 @@ fn file_lock_multiple_shared() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_vendor = "apple",
))]
#[cfg_attr(
not(any(
windows,
target_os = "aix",
target_os = "cygwin",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_vendor = "apple",
)),
should_panic
)]
fn file_lock_blocking() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_blocking_test.txt");
Expand All @@ -273,15 +270,22 @@ fn file_lock_blocking() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_vendor = "apple",
))]
#[cfg_attr(
not(any(
windows,
target_os = "aix",
target_os = "cygwin",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_vendor = "apple",
)),
should_panic
)]
fn file_lock_drop() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_dup_test.txt");
Expand All @@ -296,15 +300,22 @@ fn file_lock_drop() {
}

#[test]
#[cfg(any(
windows,
target_os = "freebsd",
target_os = "linux",
target_os = "netbsd",
target_os = "solaris",
target_os = "illumos",
target_vendor = "apple",
))]
#[cfg_attr(
not(any(
windows,
target_os = "aix",
target_os = "cygwin",
target_os = "freebsd",
target_os = "fuchsia",
target_os = "illumos",
target_os = "linux",
target_os = "netbsd",
target_os = "openbsd",
target_os = "solaris",
target_vendor = "apple",
)),
should_panic
)]
fn file_lock_dup() {
let tmpdir = tmpdir();
let filename = &tmpdir.join("file_lock_dup_test.txt");
Expand Down Expand Up @@ -1252,7 +1263,7 @@ fn readlink_not_symlink() {
}

#[test]
#[cfg_attr(target_os = "android", ignore)] // Android SELinux rules prevent creating hardlinks
#[cfg_attr(target_os = "android", ignore = "Android SELinux rules prevent creating hardlinks")]
fn links_work() {
let tmpdir = tmpdir();
let input = tmpdir.join("in.txt");
Expand Down Expand Up @@ -1748,7 +1759,7 @@ fn metadata_access_times() {

/// Test creating hard links to symlinks.
#[test]
#[cfg_attr(target_os = "android", ignore)] // Android SELinux rules prevent creating hardlinks
#[cfg_attr(target_os = "android", ignore = "Android SELinux rules prevent creating hardlinks")]
fn symlink_hard_link() {
let tmpdir = tmpdir();
if !got_symlink_permission(&tmpdir) {
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/fs/uefi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ impl FileAttr {
unsafe {
Self {
attr: (*info.as_ptr()).attribute,
size: (*info.as_ptr()).size,
size: (*info.as_ptr()).file_size,
modified: uefi_fs::uefi_to_systemtime((*info.as_ptr()).modification_time),
accessed: uefi_fs::uefi_to_systemtime((*info.as_ptr()).last_access_time),
created: uefi_fs::uefi_to_systemtime((*info.as_ptr()).create_time),
Expand Down
5 changes: 2 additions & 3 deletions library/std/src/sys/net/connection/uefi/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,11 @@ impl TcpStream {
}

pub fn read_vectored(&self, buf: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
// FIXME: UEFI does support vectored read, so implement that.
crate::io::default_read_vectored(|b| self.read(b), buf)
self.inner.read_vectored(buf, self.read_timeout()?)
}

pub fn is_read_vectored(&self) -> bool {
false
true
}

pub fn write(&self, buf: &[u8]) -> io::Result<usize> {
Expand Down
12 changes: 11 additions & 1 deletion library/std/src/sys/net/connection/uefi/tcp.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::tcp4;
use crate::io::{self, IoSlice};
use crate::io::{self, IoSlice, IoSliceMut};
use crate::net::SocketAddr;
use crate::ptr::NonNull;
use crate::sys::{helpers, unsupported};
Expand Down Expand Up @@ -44,6 +44,16 @@ impl Tcp {
}
}

pub(crate) fn read_vectored(
&self,
buf: &mut [IoSliceMut<'_>],
timeout: Option<Duration>,
) -> io::Result<usize> {
match self {
Self::V4(client) => client.read_vectored(buf, timeout),
}
}

pub(crate) fn ttl(&self) -> io::Result<u32> {
match self {
Self::V4(client) => client.get_mode_data().map(|x| x.time_to_live.into()),
Expand Down
Loading
Loading