Skip to content

Commit 079e2f8

Browse files
committed
Merge branch '⬆️-nightly-2023-03-18' into 🦆
2 parents bad3292 + 1d49486 commit 079e2f8

File tree

10 files changed

+19
-97
lines changed

10 files changed

+19
-97
lines changed

Cargo.toml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
cargo-features = ["profile-rustflags"]
2+
13
[workspace]
24
members = [
35
"examples/basic",
@@ -117,3 +119,8 @@ rev = "2a74b62c26724ff9c67e4e3ad05378a1af53f195"
117119

118120
[profile.release]
119121
debug = true
122+
123+
# FIXME: Work-around for undefined symbol errors that occur with the
124+
# combination of `-Zbuild-std`, `opt-level = "s"`, and `lto = true`
125+
# <https://github.com/rust-lang/rust/issues/108853>
126+
rustflags = ["-Zshare-generics=off"]

doc/toolchain_limitations.md

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ type Alias<T> = Struct<{<T as Trait>::N}>;
106106

107107
### `[tag:const_for]` `for` loops are unusable in `const fn`
108108

109-
Technically it's available under the compiler feature `const_for`, but the lack of essential trait implementations (e.g., `[ref:range_const_iterator]`, `[ref:const_slice_iter]`) and above all the inability of implementing `const Iterator` (`[ref:iterator_const_default]`) make it unusable.
109+
Technically it's available under the compiler feature `const_for`, but the lack of essential trait implementations (e.g., `[ref:range_const_iterator]`, `[ref:const_slice_iter]`) makes it unusable in many cases.
110110

111111

112112
### `[tag:const_static_item_ref]` `const`s and `const fn`s can't refer to `static`s
@@ -430,23 +430,6 @@ const _: () = assert!(PartialEq::eq(&(A..A), &(A..A)));
430430
```
431431

432432

433-
### `[tag:type_id_partial_eq]` `TypeId: !const PartialEq`
434-
435-
The standard library doesn't provide a `const` trait implementation of `PartialEq` for `core::any::TypeId`.
436-
437-
```rust
438-
use core::any::TypeId;
439-
assert!(TypeId::of::<()>() == TypeId::of::<()>());
440-
```
441-
442-
```rust,compile_fail,E0277
443-
#![feature(const_type_id)]
444-
use core::any::TypeId;
445-
// error[E0277]: can't compare `TypeId` with `_` in const contexts
446-
const _: () = assert!(TypeId::of::<()>() == TypeId::of::<()>());
447-
```
448-
449-
450433
### `[tag:range_const_iterator]` `Range<T>: !~const Iterator`
451434

452435
The standard library doesn't provide a `const` trait implementation of `Range<T>: Iterator`.
@@ -466,25 +449,6 @@ const _: () = assert!(matches!((2..4).next(), Some(2)));
466449
```
467450

468451

469-
### `[tag:iterator_const_default]` `Iterator` lack `#[const_trait]`
470-
471-
```rust,compile_fail
472-
#![feature(const_trait_impl)]
473-
#![feature(const_mut_refs)]
474-
475-
struct MyIterator;
476-
477-
// error: const `impl` for trait `Iterator` which is not marked with `#[const_trait]`
478-
impl const Iterator for MyIterator {
479-
type Item = u32;
480-
481-
fn next(&mut self) -> Option<Self::Item> {
482-
Some(42)
483-
}
484-
}
485-
```
486-
487-
488452
### `[tag:const_assert_eq]` `assert_eq!` and similar macros are unusable in `const fn`
489453

490454
```rust,compile_fail,E0015

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2023-01-10"
2+
channel = "nightly-2023-03-18"
33
components = ["rustfmt", "rust-src", "clippy"]

src/r3_core/src/bag.rs

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//! A heterogeneous collection to store property values.
2-
use core::mem::transmute;
2+
use core::{any::TypeId, mem::transmute};
33

44
/// A heterogeneous collection to store property values.
55
#[const_trait]
@@ -88,40 +88,3 @@ mod private {
8888
impl<Head: 'static, Tail: ~const Bag> const Sealed for super::List<Head, Tail> {}
8989
impl<Left: ~const Bag, Right: ~const Bag> const Sealed for super::Either<Left, Right> {}
9090
}
91-
92-
// `TypeId` doesn't implement `const PartialEq` [ref:type_id_partial_eq]
93-
/// A wrapper of [`core::any::TypeId`] that is usable in a constant context.
94-
struct TypeId {
95-
inner: core::any::TypeId,
96-
}
97-
98-
impl TypeId {
99-
#[inline]
100-
const fn of<T: 'static>() -> Self {
101-
Self {
102-
inner: core::any::TypeId::of::<T>(),
103-
}
104-
}
105-
106-
#[inline]
107-
const fn eq(&self, other: &Self) -> bool {
108-
// This relies on the implementation details of `TypeId`, but I think
109-
// we're are okay judging by the fact that WebRender is doing the same
110-
// <https://github.com/rust-lang/rust/pull/75923#issuecomment-683090745>
111-
unsafe {
112-
type TypeIdBytes = [u8; core::mem::size_of::<core::any::TypeId>()];
113-
let x: TypeIdBytes = transmute(self.inner);
114-
let y: TypeIdBytes = transmute(other.inner);
115-
// Can't just do `x == y` due to [ref:array_const_partial_eq].
116-
// A non-idiomatic loop must be used due to [ref:const_for].
117-
let mut i = 0;
118-
while i < x.len() {
119-
if x[i] != y[i] {
120-
return false;
121-
}
122-
i += 1;
123-
}
124-
true
125-
}
126-
}
127-
}

src/r3_core/src/bind/sorter.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ pub(super) const fn sort_bindings<Callback, SorterUseInfoList, VertexList>(
318318
End,
319319
}
320320

321-
impl const MyIterator for VertexIter<'_> {
321+
impl const Iterator for VertexIter<'_> {
322322
type Item = Vertex;
323323

324324
fn next(&mut self) -> Option<Self::Item> {
@@ -369,7 +369,7 @@ pub(super) const fn sort_bindings<Callback, SorterUseInfoList, VertexList>(
369369
End,
370370
}
371371

372-
impl<Callback> const MyIterator for SuccessorIter<'_, Callback>
372+
impl<Callback> const Iterator for SuccessorIter<'_, Callback>
373373
where
374374
Callback: ~const SorterCallback,
375375
{
@@ -533,23 +533,14 @@ pub(super) const fn sort_bindings<Callback, SorterUseInfoList, VertexList>(
533533
// Helper traits
534534
// --------------------------------------------------------------------------
535535

536-
// `const Iterator` is currently very hard to implement
537-
// [ref:iterator_const_default]
538-
/// An [`Iterator`][] usable in `const fn`.
539-
#[const_trait]
540-
trait MyIterator {
541-
type Item;
542-
fn next(&mut self) -> Option<Self::Item>;
543-
}
544-
545536
#[const_trait]
546537
trait GraphAccess<VertexRef> {
547-
type VertexIter<'a>: ~const MyIterator<Item = VertexRef> + ~const Destruct + 'a
538+
type VertexIter<'a>: ~const Iterator<Item = VertexRef> + ~const Destruct + 'a
548539
where
549540
Self: 'a;
550541
fn vertices(&self) -> Self::VertexIter<'_>;
551542

552-
type SuccessorIter<'a>: ~const MyIterator<Item = VertexRef> + ~const Destruct + 'a
543+
type SuccessorIter<'a>: ~const Iterator<Item = VertexRef> + ~const Destruct + 'a
553544
where
554545
Self: 'a;
555546
fn successors(&self, v: &VertexRef) -> Self::SuccessorIter<'_>;

src/r3_kernel/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#![feature(const_swap)]
2828
#![feature(never_type)] // `!`
2929
#![feature(decl_macro)]
30-
#![feature(pin_macro)]
3130
#![feature(doc_cfg)] // `#[doc(cfg(...))]`
3231
#![deny(unsafe_op_in_unsafe_fn)]
3332
#![cfg_attr(

src/r3_kernel/src/utils/ctz.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ mod tests {
314314
} else {
315315
let low = i & 31;
316316
let high = i >> 5;
317-
low | (high << (bits - 5))
317+
low | high.checked_shl((bits - 5) as u32).unwrap()
318318
} as usize;
319319

320320
let got = $func(in_value);

src/r3_port_std/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#![feature(cfg_target_has_atomic)] // `#[cfg(target_has_atomic_load_store)]`
2-
#![feature(atomic_mut_ptr)]
32
#![feature(thread_local)]
43
#![feature(deadline_api)]
54
#![feature(once_cell)]

src/r3_port_std/src/threading_windows.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ pub fn park() {
9191
while token_count < 0 {
9292
unsafe {
9393
synchapi::WaitOnAddress(
94-
token_count_cell.as_mut_ptr().cast(), // location to watch
94+
token_count_cell.as_ptr().cast(), // location to watch
9595
addr_of!(token_count).cast_mut().cast(), // undesired value
9696
std::mem::size_of::<isize>(), // value size
9797
INFINITE, // timeout
@@ -116,7 +116,7 @@ impl Thread {
116116
let _guard = self.data.remote_op_mutex.lock().unwrap();
117117
let token_count_cell = &self.data.token_count;
118118
if token_count_cell.fetch_add(1, Ordering::Relaxed) == -1 {
119-
unsafe { synchapi::WakeByAddressAll(token_count_cell.as_mut_ptr().cast()) };
119+
unsafe { synchapi::WakeByAddressAll(token_count_cell.as_ptr().cast()) };
120120
unsafe { processthreadsapi::ResumeThread(self.data.hthread) };
121121
}
122122
}
@@ -256,7 +256,7 @@ mod mutex {
256256
{
257257
unsafe {
258258
synchapi::WaitOnAddress(
259-
self.locked.as_mut_ptr().cast(), // location to watch
259+
self.locked.as_ptr().cast(), // location to watch
260260
[true].as_ptr().cast_mut().cast(), // undesired value
261261
std::mem::size_of::<bool>(), // value size
262262
INFINITE, // timeout
@@ -283,7 +283,7 @@ mod mutex {
283283
#[inline]
284284
fn drop(&mut self) {
285285
self.locked.store(false, Ordering::Release);
286-
unsafe { synchapi::WakeByAddressSingle(self.locked.as_mut_ptr().cast()) };
286+
unsafe { synchapi::WakeByAddressSingle(self.locked.as_ptr().cast()) };
287287
}
288288
}
289289

src/r3_test_runner/src/main.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#![feature(lint_reasons)]
55
#![feature(decl_macro)] // `macro`
66
#![feature(once_cell)]
7-
#![feature(pin_macro)] // `core::pin::pin!`
87
#![warn(must_not_suspend)]
98
use anyhow::{bail, Context};
109
use clap::Parser;

0 commit comments

Comments
 (0)