Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8fad3a1
tidy: allow stdlib to depend on moto-rt
lasiotus Sep 24, 2025
a828ffc
Add Motor OS std library port
lasiotus Oct 8, 2025
12c0d69
use check_nondet helper in a few more places
RalfJung Oct 13, 2025
42eb21c
Merge pull request #4629 from RalfJung/check-nondet
RalfJung Oct 13, 2025
fe91820
native-lib: support all types with Scalar layout
RalfJung Oct 14, 2025
2feb8bb
better error when native code tries to execute Rust function
RalfJung Oct 14, 2025
0317934
Merge pull request #4628 from RalfJung/native-lib
RalfJung Oct 14, 2025
75b60f1
Prepare for merging from rust-lang/rust
Oct 15, 2025
bcef7d5
Merge ref '235a4c083eb2' from rust-lang/rust
Oct 15, 2025
a9fc0ca
fmt
Oct 15, 2025
1819f5e
don't debug-print an Any
RalfJung Oct 15, 2025
afa2315
Merge pull request #4631 from rust-lang/rustup-2025-10-15
RalfJung Oct 15, 2025
a6705ea
Merge pull request #4632 from RalfJung/supervisor-panic
RalfJung Oct 15, 2025
7c419e8
native-lib: bump libffi
nia-e Oct 15, 2025
51cab7c
avoid some Vector allocations
RalfJung Oct 15, 2025
a084f45
Merge pull request #4634 from nia-e/new-libffi
RalfJung Oct 15, 2025
1de9b49
remove duplicate inline macro
h3nryc0ding Oct 15, 2025
0ecee8c
Prepare for merging from rust-lang/rust
RalfJung Oct 15, 2025
7c28d96
Merge ref '28d0a4a205f9' from rust-lang/rust
RalfJung Oct 15, 2025
984542c
Don't highlight `let` expressions as having type `bool`
pommicket Oct 15, 2025
952be8e
fix genmc build
RalfJung Oct 15, 2025
d458363
Merge pull request #4635 from RalfJung/rustup
RalfJung Oct 15, 2025
2f04473
update lockfile
RalfJung Oct 15, 2025
8787c0b
Use `bit_set::Word` in a couple more places.
nnethercote Oct 16, 2025
74ac3ec
style-guide: fix typo for empty struct advice
fee1-dead Oct 16, 2025
ea08a7d
CFI: Rewrite `FnPtrShim` when generalizing
rcvalle Aug 5, 2025
8cce703
Rollup merge of #144936 - rcvalle:rust-cfi-fix-144641, r=lcnr
matthiaskrgr Oct 16, 2025
67b511a
Rollup merge of #147000 - moturus:motor-os_stdlib_pr, r=tgross35
matthiaskrgr Oct 16, 2025
e954bd6
Rollup merge of #147732 - h3nryc0ding:master, r=chenyukang
matthiaskrgr Oct 16, 2025
28b216e
Rollup merge of #147738 - pommicket:issue-147665, r=madsmtm
matthiaskrgr Oct 16, 2025
838a18c
Rollup merge of #147744 - RalfJung:miri, r=RalfJung
matthiaskrgr Oct 16, 2025
d48b674
Rollup merge of #147751 - nnethercote:bit_set-Word, r=Zalathar
matthiaskrgr Oct 16, 2025
77afaa5
Rollup merge of #147752 - fee1-dead-contrib:sgtypo, r=chenyukang
matthiaskrgr Oct 16, 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
12 changes: 6 additions & 6 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1164,7 +1164,7 @@ dependencies = [
"libc",
"option-ext",
"redox_users 0.5.2",
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]

[[package]]
Expand Down Expand Up @@ -2106,19 +2106,19 @@ dependencies = [

[[package]]
name = "libffi"
version = "4.1.1"
version = "5.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e7681c6fab541f799a829e44a445a0666cf8d8a6cfebf89419e6aed52c604e87"
checksum = "0444124f3ffd67e1b0b0c661a7f81a278a135eb54aaad4078e79fbc8be50c8a5"
dependencies = [
"libc",
"libffi-sys",
]

[[package]]
name = "libffi-sys"
version = "3.3.2"
version = "4.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7b0d828d367b4450ed08e7d510dc46636cd660055f50d67ac943bfe788767c29"
checksum = "3d722da8817ea580d0669da6babe2262d7b86a1af1103da24102b8bb9c101ce7"
dependencies = [
"cc",
]
Expand Down Expand Up @@ -2374,7 +2374,7 @@ version = "0.6.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "536bfad37a309d62069485248eeaba1e8d9853aaf951caaeaed0585a95346f08"
dependencies = [
"windows-sys 0.60.2",
"windows-sys 0.61.2",
]

[[package]]
Expand Down
4 changes: 3 additions & 1 deletion compiler/rustc_hir_typeck/src/demand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -792,7 +792,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Binary(_, lhs, rhs), .. }),
Some(TypeError::Sorts(ExpectedFound { expected, .. })),
) if rhs.hir_id == expr.hir_id
&& self.typeck_results.borrow().expr_ty_adjusted_opt(lhs) == Some(expected) =>
&& self.typeck_results.borrow().expr_ty_adjusted_opt(lhs) == Some(expected)
// let expressions being marked as `bool` is confusing (see issue #147665)
&& !matches!(lhs.kind, hir::ExprKind::Let(..)) =>
{
err.span_label(lhs.span, format!("expected because this is `{expected}`"));
}
Expand Down
4 changes: 2 additions & 2 deletions compiler/rustc_index/src/bit_set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -873,7 +873,7 @@ impl<T: Idx> BitRelations<ChunkedBitSet<T>> for ChunkedBitSet<T> {
let mut self_chunk_words = **other_chunk_words;
for word in self_chunk_words[0..num_words].iter_mut().rev() {
*word = !*word & tail_mask;
tail_mask = u64::MAX;
tail_mask = Word::MAX;
}
let self_chunk_count = chunk_domain_size - *other_chunk_count;
debug_assert_eq!(
Expand All @@ -888,7 +888,7 @@ impl<T: Idx> BitRelations<ChunkedBitSet<T>> for ChunkedBitSet<T> {
) => {
// See `ChunkedBitSet::union` for details on what is happening here.
let num_words = num_words(chunk_domain_size as usize);
let op = |a: u64, b: u64| a & !b;
let op = |a: Word, b: Word| a & !b;
if !bitwise_changes(
&self_chunk_words[0..num_words],
&other_chunk_words[0..num_words],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use rustc_hir as hir;
use rustc_hir::LangItem;
use rustc_middle::bug;
use rustc_middle::ty::{
self, ExistentialPredicateStableCmpExt as _, Instance, InstanceKind, IntTy, List, TraitRef, Ty,
TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, UintTy,
self, ExistentialPredicateStableCmpExt as _, Instance, IntTy, List, TraitRef, Ty, TyCtxt,
TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, UintTy,
};
use rustc_span::def_id::DefId;
use rustc_span::{DUMMY_SP, sym};
Expand Down Expand Up @@ -458,6 +458,30 @@ pub(crate) fn transform_instance<'tcx>(
instance
}

fn default_or_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Option<DefId> {
match instance.def {
ty::InstanceKind::Item(def_id) | ty::InstanceKind::FnPtrShim(def_id, _) => {
tcx.opt_associated_item(def_id).map(|item| item.def_id)
}
_ => None,
}
}

/// Determines if an instance represents a trait method implementation and returns the necessary
/// information for type erasure.
///
/// This function handles two main cases:
///
/// * **Implementation in an `impl` block**: When the instance represents a concrete implementation
/// of a trait method in an `impl` block, it extracts the trait reference, method ID, and trait
/// ID from the implementation. The method ID is obtained from the `trait_item_def_id` field of
/// the associated item, which points to the original trait method definition.
///
/// * **Provided method in a `trait` block or synthetic `shim`**: When the instance represents a
/// default implementation provided in the trait definition itself or a synthetic shim, it uses
/// the instance's own `def_id` as the method ID and determines the trait ID from the associated
/// item.
///
fn implemented_method<'tcx>(
tcx: TyCtxt<'tcx>,
instance: Instance<'tcx>,
Expand All @@ -473,11 +497,9 @@ fn implemented_method<'tcx>(
trait_method = tcx.associated_item(method_id);
trait_id = trait_ref.skip_binder().def_id;
impl_id
} else if let InstanceKind::Item(def_id) = instance.def
&& let Some(trait_method_bound) = tcx.opt_associated_item(def_id)
{
// Provided method in a `trait` block
trait_method = trait_method_bound;
} else if let Some(trait_method_def_id) = default_or_shim(tcx, instance) {
// Provided method in a `trait` block or a synthetic `shim`
trait_method = tcx.associated_item(trait_method_def_id);
method_id = instance.def_id();
trait_id = tcx.trait_of_assoc(method_id)?;
trait_ref = ty::EarlyBinder::bind(TraitRef::from_assoc(tcx, trait_id, instance.args));
Expand Down
11 changes: 11 additions & 0 deletions library/Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,16 @@ dependencies = [
"rustc-std-workspace-core",
]

[[package]]
name = "moto-rt"
version = "0.15.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "058a2807a30527bee4c30df7ababe971cdde94372d4dbd1ff145bb403381436c"
dependencies = [
"rustc-std-workspace-alloc",
"rustc-std-workspace-core",
]

[[package]]
name = "object"
version = "0.37.3"
Expand Down Expand Up @@ -316,6 +326,7 @@ dependencies = [
"hermit-abi",
"libc",
"miniz_oxide",
"moto-rt",
"object",
"panic_abort",
"panic_unwind",
Expand Down
1 change: 0 additions & 1 deletion library/alloc/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,6 @@ impl<T, A: Allocator> Arc<T, A> {
/// let five = Arc::try_new_in(5, System)?;
/// # Ok::<(), std::alloc::AllocError>(())
/// ```
#[inline]
#[unstable(feature = "allocator_api", issue = "32838")]
#[inline]
pub fn try_new_in(data: T, alloc: A) -> Result<Arc<T, A>, AllocError> {
Expand Down
3 changes: 3 additions & 0 deletions library/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ fortanix-sgx-abi = { version = "0.6.1", features = [
'rustc-dep-of-std',
], public = true }

[target.'cfg(target_os = "motor")'.dependencies]
moto-rt = { version = "0.15", features = ['rustc-dep-of-std'], public = true }

[target.'cfg(target_os = "hermit")'.dependencies]
hermit-abi = { version = "0.5.0", features = [
'rustc-dep-of-std',
Expand Down
1 change: 1 addition & 0 deletions library/std/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fn main() {
|| target_os == "windows"
|| target_os == "fuchsia"
|| (target_vendor == "fortanix" && target_env == "sgx")
|| target_os == "motor"
|| target_os == "hermit"
|| target_os == "trusty"
|| target_os == "l4re"
Expand Down
22 changes: 20 additions & 2 deletions library/std/src/os/fd/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
#![stable(feature = "io_safety", since = "1.63.0")]
#![deny(unsafe_op_in_unsafe_fn)]

#[cfg(target_os = "motor")]
use moto_rt::libc;

use super::raw::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
#[cfg(not(target_os = "trusty"))]
use crate::fs;
Expand All @@ -12,7 +15,8 @@ use crate::mem::ManuallyDrop;
target_arch = "wasm32",
target_env = "sgx",
target_os = "hermit",
target_os = "trusty"
target_os = "trusty",
target_os = "motor"
)))]
use crate::sys::cvt;
#[cfg(not(target_os = "trusty"))]
Expand Down Expand Up @@ -95,7 +99,12 @@ impl OwnedFd {
impl BorrowedFd<'_> {
/// Creates a new `OwnedFd` instance that shares the same underlying file
/// description as the existing `BorrowedFd` instance.
#[cfg(not(any(target_arch = "wasm32", target_os = "hermit", target_os = "trusty")))]
#[cfg(not(any(
target_arch = "wasm32",
target_os = "hermit",
target_os = "trusty",
target_os = "motor"
)))]
#[stable(feature = "io_safety", since = "1.63.0")]
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
// We want to atomically duplicate this file descriptor and set the
Expand Down Expand Up @@ -123,6 +132,15 @@ impl BorrowedFd<'_> {
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
Err(crate::io::Error::UNSUPPORTED_PLATFORM)
}

/// Creates a new `OwnedFd` instance that shares the same underlying file
/// description as the existing `BorrowedFd` instance.
#[cfg(target_os = "motor")]
#[stable(feature = "io_safety", since = "1.63.0")]
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
let fd = moto_rt::fs::duplicate(self.as_raw_fd()).map_err(crate::sys::map_motor_error)?;
Ok(unsafe { OwnedFd::from_raw_fd(fd) })
}
}

#[stable(feature = "io_safety", since = "1.63.0")]
Expand Down
10 changes: 7 additions & 3 deletions library/std/src/os/fd/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@

#[cfg(target_os = "hermit")]
use hermit_abi as libc;
#[cfg(target_os = "motor")]
use moto_rt::libc;

#[cfg(target_os = "motor")]
use super::owned::OwnedFd;
#[cfg(not(target_os = "trusty"))]
use crate::fs;
use crate::io;
#[cfg(target_os = "hermit")]
use crate::os::hermit::io::OwnedFd;
#[cfg(not(target_os = "hermit"))]
#[cfg(all(not(target_os = "hermit"), not(target_os = "motor")))]
use crate::os::raw;
#[cfg(all(doc, not(target_arch = "wasm32")))]
use crate::os::unix::io::AsFd;
Expand All @@ -23,10 +27,10 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};

/// Raw file descriptors.
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg(not(target_os = "hermit"))]
#[cfg(all(not(target_os = "hermit"), not(target_os = "motor")))]
pub type RawFd = raw::c_int;
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg(target_os = "hermit")]
#[cfg(any(target_os = "hermit", target_os = "motor"))]
pub type RawFd = i32;

/// A trait to extract the raw file descriptor from an underlying object.
Expand Down
11 changes: 10 additions & 1 deletion library/std/src/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ pub mod ios;
pub mod l4re;
#[cfg(target_os = "macos")]
pub mod macos;
#[cfg(target_os = "motor")]
pub mod motor;
#[cfg(target_os = "netbsd")]
pub mod netbsd;
#[cfg(target_os = "nto")]
Expand Down Expand Up @@ -182,7 +184,14 @@ pub mod vxworks;
#[cfg(target_os = "xous")]
pub mod xous;

#[cfg(any(unix, target_os = "hermit", target_os = "trusty", target_os = "wasi", doc))]
#[cfg(any(
unix,
target_os = "hermit",
target_os = "trusty",
target_os = "wasi",
target_os = "motor",
doc
))]
pub mod fd;

#[cfg(any(target_os = "linux", target_os = "android", target_os = "cygwin", doc))]
Expand Down
37 changes: 37 additions & 0 deletions library/std/src/os/motor/ffi.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
//! Motor OS-specific extensions to primitives in the [`std::ffi`] module.
#![unstable(feature = "motor_ext", issue = "147456")]

use crate::ffi::{OsStr, OsString};
use crate::sealed::Sealed;

/// Motor OS-specific extensions to [`OsString`].
///
/// This trait is sealed: it cannot be implemented outside the standard library.
/// This is so that future additional methods are not breaking changes.
pub trait OsStringExt: Sealed {
/// Motor OS strings are utf-8, and thus just strings.
fn as_str(&self) -> &str;
}

impl OsStringExt for OsString {
#[inline]
fn as_str(&self) -> &str {
self.to_str().unwrap()
}
}

/// Motor OS-specific extensions to [`OsString`].
///
/// This trait is sealed: it cannot be implemented outside the standard library.
/// This is so that future additional methods are not breaking changes.
pub trait OsStrExt: Sealed {
/// Motor OS strings are utf-8, and thus just strings.
fn as_str(&self) -> &str;
}

impl OsStrExt for OsStr {
#[inline]
fn as_str(&self) -> &str {
self.to_str().unwrap()
}
}
4 changes: 4 additions & 0 deletions library/std/src/os/motor/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#![unstable(feature = "motor_ext", issue = "147456")]

pub mod ffi;
pub mod process;
15 changes: 15 additions & 0 deletions library/std/src/os/motor/process.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#![unstable(feature = "motor_ext", issue = "147456")]

use crate::sealed::Sealed;
use crate::sys_common::AsInner;

pub trait ChildExt: Sealed {
/// Extracts the main thread raw handle, without taking ownership
fn sys_handle(&self) -> u64;
}

impl ChildExt for crate::process::Child {
fn sys_handle(&self) -> u64 {
self.as_inner().handle()
}
}
3 changes: 3 additions & 0 deletions library/std/src/sys/alloc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ cfg_select! {
target_os = "hermit" => {
mod hermit;
}
target_os = "motor" => {
mod motor;
}
all(target_vendor = "fortanix", target_env = "sgx") => {
mod sgx;
}
Expand Down
28 changes: 28 additions & 0 deletions library/std/src/sys/alloc/motor.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use crate::alloc::{GlobalAlloc, Layout, System};

#[stable(feature = "alloc_system_type", since = "1.28.0")]
unsafe impl GlobalAlloc for System {
#[inline]
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
// SAFETY: same requirements as in GlobalAlloc::alloc.
moto_rt::alloc::alloc(layout)
}

#[inline]
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
// SAFETY: same requirements as in GlobalAlloc::alloc_zeroed.
moto_rt::alloc::alloc_zeroed(layout)
}

#[inline]
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
// SAFETY: same requirements as in GlobalAlloc::dealloc.
unsafe { moto_rt::alloc::dealloc(ptr, layout) }
}

#[inline]
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
// SAFETY: same requirements as in GlobalAlloc::realloc.
unsafe { moto_rt::alloc::realloc(ptr, layout, new_size) }
}
}
4 changes: 4 additions & 0 deletions library/std/src/sys/anonymous_pipe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ cfg_select! {
mod windows;
pub use windows::{AnonPipe, pipe};
}
target_os = "motor" => {
mod motor;
pub use motor::{AnonPipe, pipe};
}
_ => {
mod unsupported;
pub use unsupported::{AnonPipe, pipe};
Expand Down
Loading
Loading