Skip to content

Update subtree/library to 2025-03-18 - #19

Merged
tautschnig merged 34 commits into
subtree/libraryfrom
update-subtree/library
Apr 15, 2025
Merged

tautschnig merged 34 commits into
subtree/libraryfrom
update-subtree/library

Conversation

@github-actions

Copy link
Copy Markdown

This is an automated PR to update the subtree/library branch to the changes from 2025-03-17 (rust-lang/rust@227690a) to 2025-03-18 (rust-lang/rust@43a2e9d), inclusive.
Review this PR as usual, but do not merge this PR using the GitHub web interface. Instead, once it is approved, use git push to literally push the changes to subtree/library without any rebase or merge.

hkBst and others added 30 commits January 31, 2025 17:29
It's bitflags in practice, so an enum is unsound, as an enum must only
have the described values. The x86_64 psABI declares it as a `typedef
int _Unwind_Action`, which seems reasonable. I made a newtype first but
that was more annoying than just a typedef. We don't really use this
value for much other than a short check.
…=Amanieu

Add `From<{integer}>` for `f16`/`f128` impls

This PR adds `impl From<{bool,i8,u8}> for f16` and `impl From<{bool,i8,u8,i16,u16,i32,u32}> for f128`.

The `From<{i64,u64}> for f128` impls are left commented out as adding them would allow using `f128` on stable before it is stabilised like in the following example:
```rust
fn f<T: From<u64>>(x: T) -> T { x }

fn main() {
    let x = f(1.0); // the type of the literal is inferred to be `f128`
}
```
None of the impls added in this PR have this issue as they are all, at minimum, also implemented by `f64`.

This PR will need a crater run for the `From<{i32,u32}>` impls, as `f64` is no longer the only float type to implement them (similar to the cause of rust-lang#125198).

cc `@bjoernager`
r? `@tgross35`

Tracking issue: rust-lang#116909
document capacity for ZST as example

The main text already covers this, although it provides weaker guarantees, but I think an example in the right spot does not hurt. Fixes rust-lang#80747
doc all differences of ptr:copy(_nonoverlapping) with memcpy and memmove

Fixes rust-lang#79430
…, r=workingjubilee

Make `_Unwind_Action` a type alias, not enum

It's bitflags in practice, so an enum is unsound, as an enum must only have the described values. The x86_64 psABI declares it as a `typedef int _Unwind_Action`, which seems reasonable. I made a newtype first but that was more annoying than just a typedef. We don't really use this value for much other than a short check.

I ran `x check library --target aarch64-unknown-linux-gnu,x86_64-pc-windows-gnu,x86_64-fortanix-unknown-sgx,x86_64-unknown-haiku,x86_64-unknown-fuchsi
a,x86_64-unknown-freebsd,x86_64-unknown-dragonfly,x86_64-unknown-netbsd,x86_64-unknown-openbsd,x86_64-unknown-redox,riscv64-linux-android,armv7-unknown-freebsd` (and some more but they failed to build for other reasons :D)

fixes rust-lang#138558

r? workingjubilee have fun
Rollup of 5 pull requests

Successful merges:

 - rust-lang#136293 (document capacity for ZST as example)
 - rust-lang#136359 (doc all differences of ptr:copy(_nonoverlapping) with memcpy and memmove)
 - rust-lang#136816 (refactor `notable_traits_button` to use iterator combinators  instead of for loop)
 - rust-lang#138552 (Misc print request handling cleanups + a centralized test for print request stability gating)
 - rust-lang#138573 (Make `_Unwind_Action` a type alias, not enum)

r? `@ghost`
`@rustbot` modify labels: rollup
…e_retrieval_methods, r=Amanieu

Add `*_value` methods to proc_macro lib

This is the implementation of rust-lang/libs-team#459.

It allows to get the actual value (unescaped) of the different string literals.

Part of rust-lang#136652.

r? libs-api
jhpratt and others added 4 commits March 17, 2025 05:47
…r=joshtriplett

Stablize anonymous pipe

Since rust-lang#135822 is staled, I create this PR to stablise anonymous pipe

Closes rust-lang#127154

try-job: test-various
std: Mention clone-on-write mutation in Arc<T>

Fixes rust-lang#138322

r? libs
…anieu,lnicola

Denote `ControlFlow` as `#[must_use]`

I've repeatedly hit bugs in the compiler due to `ControlFlow` not being marked `#[must_use]`. There seems to be an accepted ACP to make the type `#[must_use]` (rust-lang/libs-team#444), so this PR implements that part of it.

Most of the usages in the compiler that trigger this new warning are "root" usages (calling into an API that uses control-flow internally, but for which the callee doesn't really care) and have been suppressed by `let _ = ...`, but I did legitimately find one instance of a missing `?` and one for a never-used `ControlFlow` value in rust-lang#137448.

Presumably this needs an FCP too, so I'm opening this and nominating it for T-libs-api.

This PR also touches the tools (incl. rust-analyzer), but if this went into FCP, I'd split those out into separate PRs which can land before this one does.

r? libs-api
`@rustbot` label: T-libs-api I-libs-api-nominated
@tautschnig
tautschnig merged commit d2d682f into subtree/library Apr 15, 2025
@tautschnig
tautschnig deleted the update-subtree/library branch April 15, 2025 12:24
tautschnig added a commit that referenced this pull request Jun 2, 2025
…g#264)

Toward solving #19 

This pr adds some additional harnesses for transmute_unchecked and
transmute.

With this, we suspect that the main harnesses for part 1 of challenge 1
(verifying the transmute intrinsics directly) are there (besides adding
more of the same kinds of harnesses, like the 2-way harnesses for more
types). We go into more detail about what needs to be done for part 1,
as well as what has been done and what can't be done here:
https://docs.google.com/document/d/1zFGANNMx8mZ8fucKrN--ELwKASUPeP20THH6M_fQ7jg/edit?usp=sharing

Just one note: transmute has far fewer harnesses than
transmute_unchecked here -- this is because it is not currently possible
to write a wrapper for transmute, and it is thus not possible to write a
function contract. A lot of the harnesses for transmute_unchecked test
the function contract's validity clause, rather than the function
itself, explaining this disparity.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

---------

Co-authored-by: AlexLB99 <[email protected]>
Co-authored-by: Michael Tautschnig <[email protected]>
tautschnig pushed a commit that referenced this pull request Aug 12, 2025
Towards solving #19 

This PR adds harnesses and contracts for align_to() and align_to_mut().
For the contract for align_to_mut(), we're using a wrapper and writing a
contract for that instead, due to
model-checking/kani#3764.

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.
tautschnig pushed a commit that referenced this pull request Sep 9, 2025
Resolves #19 

## Status of verification of Challenge 1 functions

| Function | Location | Completion |
| :--- | :--- | :--- |
| `transmute_unchecked` | `core::intrinsics` | ✔* |
| `transmute` | `core::intrinsics` | ✔* |
| `MaybeUninit<T>::array_assume_init` | `core::mem` | X |
| `MaybeUninit<[T; N]>::transpose` | `core::mem` | ✔ |
| `<[MaybeUninit<T>; N]>::transpose` | `core::mem` | ✔ |
| `<[T; N] as IntoIterator>::into_iter` | `core::array::iter` | ✔ |
| `BorrowedBuf::unfilled` | `core::io::borrowed_buf` | ✔ |
| `BorrowedCursor::reborrow` | `core::io::borrowed_buf` | ✔ |
| `str::as_bytes` | `core::str` | ✔ |
| `from_u32_unchecked` | `core::char::convert` | ✔ |
| `char_try_from_u32` | `core::char::convert` | ✔ |
| `Ipv6Addr::new` | `core::net::ip_addr` | ✔ |
| `Ipv6Addr::segments` | `core::net::ip_addr` | ✔ |
| `align_offset` | `core::ptr` | ✔ |
| `Alignment::new_unchecked` | `core::ptr::alignment` | ✔ |
| `MaybeUninit<T>::copy_from_slice` | `core::mem` | ✔ |
| `str::as_bytes_mut` | `core::str` | ✔ |
| `<Filter<I,P> as Iterator>::next_chunk` | `core::iter::adapters` | X |
| `<FilterMap<I,F> as Iterator>::next_chunk` | `core::iter::adapters` |
X |
| `try_from_fn` | `core::array` | X |
| `iter_next_chunk` | `core::array` | X |
| `from_u32_unchecked` | `core::char` | ✔ |
| `AsciiChar::from_u8_unchecked` | `core::ascii_char` | ✔ |
| `memchr_aligned` | `core::slice::memchr` | ✔ |
| `<[T]>::align_to_mut` | `core::slice` | ✔ |
| `run_utf8_validation` | `core::str::validations` | ✔ |
| `<[T]>::align_to` | `core::slice` | ✔ |
| `is_aligned_to` | `core::const_ptr` | ✔ |
| `is_aligned_to` | `core::mut_ptr` | ✔ |
| `Alignment::new` | `core::ptr::alignment` | ✔ |
| `Layout::from_size_align` | `core::alloc::layout` | ✔ |
| `Layout::from_size_align_unchecked` | `core::alloc::layout` | ✔ |
| `make_ascii_lowercase` | `core::str` | ✔ |
| `make_ascii_uppercase` | `core::str` | ✔ |
| `<char as Step>::forward_checked` | `core::iter::range` | ✔ |
| `<Chars as Iterator>::next` | `core::str::iter` | ✔ |
| `<Chars as DoubleEndedIterator>::next_back` | `core::str::iter` | ✔ |
| `char::encode_utf16_raw` | `core::char` | N/A ** |
| `<char as Step>::backward_unchecked` | `core::iter::range` | ✔ |
| `<char as Step>::forward_unchecked` | `core::iter::range` | ✔ |
| `AsciiChar::from_u8` | `core::ascii_char` | ✔ |
| `<[T]>::as_simd_mut` | `core::slice` | ✔ |
| `<[T]>::as_simd` | `core::slice` | ✔ |
| `memrchr` | `core::slice::memchr` | ✔ |
| `do_count_chars` | `core::str::count` | ✔ |

\* Partial contract/harnesses (extent of what is currently expressible
by Kani)
** Does not transitively depend on transmute

## Some caveats

1. Not all functions with checkmarks have contracts & harnesses -- for
those that were trivially safe, nothing was done (a function is
"trivially safe" if there are no SAFETY comments, and upon visual
inspection, it is immediately clear that there is no way UB could be
triggered, such as for `as_bytes`).
2. As shown above, the transmute intrinsics don't have complete
contracts -- they've only been verified to what we understand to be the
extent of what is currently expressible by Kani (so we don't have a
precondition that checks, for instance, that it doesn't transmute an
immut ref into a mut ref)
3. As the challenge stipulates, the above functions were only checked
for safety, rather than functional correctness

## Question

Given that the completion condition for the challenge is 75% of
functions being verified, would it be considered as complete?

Please let us know if we're missing anything, or if any of the caveats
would need to be addressed for completion of the challenge.

Thanks!

By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache 2.0 and MIT licenses.

---------

Co-authored-by: thanhnguyen-aws <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.