Skip to content

Commit 7b46301

Browse files
committed
Auto merge of #147765 - matthiaskrgr:rollup-kkwiczz, r=matthiaskrgr
Rollup of 7 pull requests Successful merges: - #144936 (CFI: Fix types that implement Fn, FnMut, or FnOnce) - #147000 (std: Add Motor OS std library port) - #147732 (remove duplicate inline macro) - #147738 (Don't highlight `let` expressions as having type `bool` in let-chain error messages) - #147744 (miri subtree update) - #147751 (Use `bit_set::Word` in a couple more places.) - #147752 (style-guide: fix typo for empty struct advice) r? `@ghost` `@rustbot` modify labels: rollup
2 parents f524236 + 77afaa5 commit 7b46301

File tree

79 files changed

+2600
-97
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+2600
-97
lines changed

Cargo.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ dependencies = [
11641164
"libc",
11651165
"option-ext",
11661166
"redox_users 0.5.2",
1167-
"windows-sys 0.60.2",
1167+
"windows-sys 0.61.2",
11681168
]
11691169

11701170
[[package]]
@@ -2106,19 +2106,19 @@ dependencies = [
21062106

21072107
[[package]]
21082108
name = "libffi"
2109-
version = "4.1.1"
2109+
version = "5.0.0"
21102110
source = "registry+https://github.com/rust-lang/crates.io-index"
2111-
checksum = "e7681c6fab541f799a829e44a445a0666cf8d8a6cfebf89419e6aed52c604e87"
2111+
checksum = "0444124f3ffd67e1b0b0c661a7f81a278a135eb54aaad4078e79fbc8be50c8a5"
21122112
dependencies = [
21132113
"libc",
21142114
"libffi-sys",
21152115
]
21162116

21172117
[[package]]
21182118
name = "libffi-sys"
2119-
version = "3.3.2"
2119+
version = "4.0.0"
21202120
source = "registry+https://github.com/rust-lang/crates.io-index"
2121-
checksum = "7b0d828d367b4450ed08e7d510dc46636cd660055f50d67ac943bfe788767c29"
2121+
checksum = "3d722da8817ea580d0669da6babe2262d7b86a1af1103da24102b8bb9c101ce7"
21222122
dependencies = [
21232123
"cc",
21242124
]
@@ -2374,7 +2374,7 @@ version = "0.6.1"
23742374
source = "registry+https://github.com/rust-lang/crates.io-index"
23752375
checksum = "536bfad37a309d62069485248eeaba1e8d9853aaf951caaeaed0585a95346f08"
23762376
dependencies = [
2377-
"windows-sys 0.60.2",
2377+
"windows-sys 0.61.2",
23782378
]
23792379

23802380
[[package]]

compiler/rustc_hir_typeck/src/demand.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
792792
hir::Node::Expr(hir::Expr { kind: hir::ExprKind::Binary(_, lhs, rhs), .. }),
793793
Some(TypeError::Sorts(ExpectedFound { expected, .. })),
794794
) if rhs.hir_id == expr.hir_id
795-
&& self.typeck_results.borrow().expr_ty_adjusted_opt(lhs) == Some(expected) =>
795+
&& self.typeck_results.borrow().expr_ty_adjusted_opt(lhs) == Some(expected)
796+
// let expressions being marked as `bool` is confusing (see issue #147665)
797+
&& !matches!(lhs.kind, hir::ExprKind::Let(..)) =>
796798
{
797799
err.span_label(lhs.span, format!("expected because this is `{expected}`"));
798800
}

compiler/rustc_index/src/bit_set.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -873,7 +873,7 @@ impl<T: Idx> BitRelations<ChunkedBitSet<T>> for ChunkedBitSet<T> {
873873
let mut self_chunk_words = **other_chunk_words;
874874
for word in self_chunk_words[0..num_words].iter_mut().rev() {
875875
*word = !*word & tail_mask;
876-
tail_mask = u64::MAX;
876+
tail_mask = Word::MAX;
877877
}
878878
let self_chunk_count = chunk_domain_size - *other_chunk_count;
879879
debug_assert_eq!(
@@ -888,7 +888,7 @@ impl<T: Idx> BitRelations<ChunkedBitSet<T>> for ChunkedBitSet<T> {
888888
) => {
889889
// See `ChunkedBitSet::union` for details on what is happening here.
890890
let num_words = num_words(chunk_domain_size as usize);
891-
let op = |a: u64, b: u64| a & !b;
891+
let op = |a: Word, b: Word| a & !b;
892892
if !bitwise_changes(
893893
&self_chunk_words[0..num_words],
894894
&other_chunk_words[0..num_words],

compiler/rustc_sanitizers/src/cfi/typeid/itanium_cxx_abi/transform.rs

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use rustc_hir as hir;
1010
use rustc_hir::LangItem;
1111
use rustc_middle::bug;
1212
use rustc_middle::ty::{
13-
self, ExistentialPredicateStableCmpExt as _, Instance, InstanceKind, IntTy, List, TraitRef, Ty,
14-
TyCtxt, TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, UintTy,
13+
self, ExistentialPredicateStableCmpExt as _, Instance, IntTy, List, TraitRef, Ty, TyCtxt,
14+
TypeFoldable, TypeFolder, TypeSuperFoldable, TypeVisitableExt, UintTy,
1515
};
1616
use rustc_span::def_id::DefId;
1717
use rustc_span::{DUMMY_SP, sym};
@@ -458,6 +458,30 @@ pub(crate) fn transform_instance<'tcx>(
458458
instance
459459
}
460460

461+
fn default_or_shim<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Option<DefId> {
462+
match instance.def {
463+
ty::InstanceKind::Item(def_id) | ty::InstanceKind::FnPtrShim(def_id, _) => {
464+
tcx.opt_associated_item(def_id).map(|item| item.def_id)
465+
}
466+
_ => None,
467+
}
468+
}
469+
470+
/// Determines if an instance represents a trait method implementation and returns the necessary
471+
/// information for type erasure.
472+
///
473+
/// This function handles two main cases:
474+
///
475+
/// * **Implementation in an `impl` block**: When the instance represents a concrete implementation
476+
/// of a trait method in an `impl` block, it extracts the trait reference, method ID, and trait
477+
/// ID from the implementation. The method ID is obtained from the `trait_item_def_id` field of
478+
/// the associated item, which points to the original trait method definition.
479+
///
480+
/// * **Provided method in a `trait` block or synthetic `shim`**: When the instance represents a
481+
/// default implementation provided in the trait definition itself or a synthetic shim, it uses
482+
/// the instance's own `def_id` as the method ID and determines the trait ID from the associated
483+
/// item.
484+
///
461485
fn implemented_method<'tcx>(
462486
tcx: TyCtxt<'tcx>,
463487
instance: Instance<'tcx>,
@@ -473,11 +497,9 @@ fn implemented_method<'tcx>(
473497
trait_method = tcx.associated_item(method_id);
474498
trait_id = trait_ref.skip_binder().def_id;
475499
impl_id
476-
} else if let InstanceKind::Item(def_id) = instance.def
477-
&& let Some(trait_method_bound) = tcx.opt_associated_item(def_id)
478-
{
479-
// Provided method in a `trait` block
480-
trait_method = trait_method_bound;
500+
} else if let Some(trait_method_def_id) = default_or_shim(tcx, instance) {
501+
// Provided method in a `trait` block or a synthetic `shim`
502+
trait_method = tcx.associated_item(trait_method_def_id);
481503
method_id = instance.def_id();
482504
trait_id = tcx.trait_of_assoc(method_id)?;
483505
trait_ref = ty::EarlyBinder::bind(TraitRef::from_assoc(tcx, trait_id, instance.args));

library/Cargo.lock

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,16 @@ dependencies = [
166166
"rustc-std-workspace-core",
167167
]
168168

169+
[[package]]
170+
name = "moto-rt"
171+
version = "0.15.0"
172+
source = "registry+https://github.com/rust-lang/crates.io-index"
173+
checksum = "058a2807a30527bee4c30df7ababe971cdde94372d4dbd1ff145bb403381436c"
174+
dependencies = [
175+
"rustc-std-workspace-alloc",
176+
"rustc-std-workspace-core",
177+
]
178+
169179
[[package]]
170180
name = "object"
171181
version = "0.37.3"
@@ -316,6 +326,7 @@ dependencies = [
316326
"hermit-abi",
317327
"libc",
318328
"miniz_oxide",
329+
"moto-rt",
319330
"object",
320331
"panic_abort",
321332
"panic_unwind",

library/alloc/src/sync.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -886,7 +886,6 @@ impl<T, A: Allocator> Arc<T, A> {
886886
/// let five = Arc::try_new_in(5, System)?;
887887
/// # Ok::<(), std::alloc::AllocError>(())
888888
/// ```
889-
#[inline]
890889
#[unstable(feature = "allocator_api", issue = "32838")]
891890
#[inline]
892891
pub fn try_new_in(data: T, alloc: A) -> Result<Arc<T, A>, AllocError> {

library/std/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ fortanix-sgx-abi = { version = "0.6.1", features = [
7070
'rustc-dep-of-std',
7171
], public = true }
7272

73+
[target.'cfg(target_os = "motor")'.dependencies]
74+
moto-rt = { version = "0.15", features = ['rustc-dep-of-std'], public = true }
75+
7376
[target.'cfg(target_os = "hermit")'.dependencies]
7477
hermit-abi = { version = "0.5.0", features = [
7578
'rustc-dep-of-std',

library/std/build.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ fn main() {
3030
|| target_os == "windows"
3131
|| target_os == "fuchsia"
3232
|| (target_vendor == "fortanix" && target_env == "sgx")
33+
|| target_os == "motor"
3334
|| target_os == "hermit"
3435
|| target_os == "trusty"
3536
|| target_os == "l4re"

library/std/src/os/fd/owned.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
#![stable(feature = "io_safety", since = "1.63.0")]
44
#![deny(unsafe_op_in_unsafe_fn)]
55

6+
#[cfg(target_os = "motor")]
7+
use moto_rt::libc;
8+
69
use super::raw::{AsRawFd, FromRawFd, IntoRawFd, RawFd};
710
#[cfg(not(target_os = "trusty"))]
811
use crate::fs;
@@ -12,7 +15,8 @@ use crate::mem::ManuallyDrop;
1215
target_arch = "wasm32",
1316
target_env = "sgx",
1417
target_os = "hermit",
15-
target_os = "trusty"
18+
target_os = "trusty",
19+
target_os = "motor"
1620
)))]
1721
use crate::sys::cvt;
1822
#[cfg(not(target_os = "trusty"))]
@@ -95,7 +99,12 @@ impl OwnedFd {
9599
impl BorrowedFd<'_> {
96100
/// Creates a new `OwnedFd` instance that shares the same underlying file
97101
/// description as the existing `BorrowedFd` instance.
98-
#[cfg(not(any(target_arch = "wasm32", target_os = "hermit", target_os = "trusty")))]
102+
#[cfg(not(any(
103+
target_arch = "wasm32",
104+
target_os = "hermit",
105+
target_os = "trusty",
106+
target_os = "motor"
107+
)))]
99108
#[stable(feature = "io_safety", since = "1.63.0")]
100109
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
101110
// We want to atomically duplicate this file descriptor and set the
@@ -123,6 +132,15 @@ impl BorrowedFd<'_> {
123132
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
124133
Err(crate::io::Error::UNSUPPORTED_PLATFORM)
125134
}
135+
136+
/// Creates a new `OwnedFd` instance that shares the same underlying file
137+
/// description as the existing `BorrowedFd` instance.
138+
#[cfg(target_os = "motor")]
139+
#[stable(feature = "io_safety", since = "1.63.0")]
140+
pub fn try_clone_to_owned(&self) -> crate::io::Result<OwnedFd> {
141+
let fd = moto_rt::fs::duplicate(self.as_raw_fd()).map_err(crate::sys::map_motor_error)?;
142+
Ok(unsafe { OwnedFd::from_raw_fd(fd) })
143+
}
126144
}
127145

128146
#[stable(feature = "io_safety", since = "1.63.0")]

library/std/src/os/fd/raw.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44

55
#[cfg(target_os = "hermit")]
66
use hermit_abi as libc;
7+
#[cfg(target_os = "motor")]
8+
use moto_rt::libc;
79

10+
#[cfg(target_os = "motor")]
11+
use super::owned::OwnedFd;
812
#[cfg(not(target_os = "trusty"))]
913
use crate::fs;
1014
use crate::io;
1115
#[cfg(target_os = "hermit")]
1216
use crate::os::hermit::io::OwnedFd;
13-
#[cfg(not(target_os = "hermit"))]
17+
#[cfg(all(not(target_os = "hermit"), not(target_os = "motor")))]
1418
use crate::os::raw;
1519
#[cfg(all(doc, not(target_arch = "wasm32")))]
1620
use crate::os::unix::io::AsFd;
@@ -23,10 +27,10 @@ use crate::sys_common::{AsInner, FromInner, IntoInner};
2327

2428
/// Raw file descriptors.
2529
#[stable(feature = "rust1", since = "1.0.0")]
26-
#[cfg(not(target_os = "hermit"))]
30+
#[cfg(all(not(target_os = "hermit"), not(target_os = "motor")))]
2731
pub type RawFd = raw::c_int;
2832
#[stable(feature = "rust1", since = "1.0.0")]
29-
#[cfg(target_os = "hermit")]
33+
#[cfg(any(target_os = "hermit", target_os = "motor"))]
3034
pub type RawFd = i32;
3135

3236
/// A trait to extract the raw file descriptor from an underlying object.

0 commit comments

Comments
 (0)