rust/tests/rustdoc-js-std
Alex Crichton ba462864f1 std: Use more unix.rs code on WASI targets
This commit is a large change to the implementation of filesystem and
other system-related operations on WASI targets. Previously the standard
library explicitly used the `wasi` crate at the 0.11.x version track
which means that it used WASIp1 APIs directly. This meant that `std` was
hard-coded to use WASIp1 syscalls and there was no separate
implementation for the WASIp{2,3} targets, for example. The high-level
goal of this commit is to decouple this interaction and avoid the use of
the `wasi` crate on the WASIp2 target.

Historically when WASIp1 was originally added to Rust the wasi-libc
library was in a much different position than it is today. Nowadays Rust
already depends on wasi-libc on WASI targets for things like memory
allocation and environment variable management. As a libc library it
also has all the functions necessary to implement all filesystem
operations Rust wants. Recently wasi-libc additionally was updated to
use WASIp2 APIs directly on the `wasm32-wasip2` target instead of using
`wasm32-wasip1` APIs. This commit is leveraging this work by enabling
Rust to completely sever the dependence on WASIp1 APIs when compiling
for `wasm32-wasip2`. This is also intended to make it easier to migrate
to `wasm32-wasip3` internally in the future where now only libc need be
updated and Rust doesn't need to explicitly change as well.

The overall premise of this commit is that there's no need for
WASI-specific implementation modules throughout the standard library.
Instead the libc-style bindings already implemented for Unix-like
targets are sufficient. This means that Rust will now be using
libc-style interfaces to interact with the filesystem, for example, and
wasi-libc is the one responsible for translating these POSIX-ish
functions into WASIp{1,2} calls.

Concrete changes here are:

* `std` for `wasm32-wasip2` no longer depends on `wasi 0.11.x`
* The implementation of `std::os::wasi::fs`, which was previously
  unstable and still is, now has portions gated to only work on the
  WASIp1 target which use the `wasi` crate directly. Traits have been
  trimmed down in some cases, updated in others, or now present a
  different API on WASIp1 and WASIp2. It's expected this'll get further
  cleanup in the future.
* The `std::sys::fd::wasi` module is deleted and `unix` is used instead.
* The `std::sys::fs::wasi` module is deleted and `unix` is used instead.
* The `std::sys::io::io_slice::wasi` module is deleted and `unix` is used
  instead.
* The `std::sys::pal::{wasip1,wasip2}` modules are now merged together
  as their difference is much smaller than before.
* The `std::sys::pal::wasi::time` is deleted and the `unix` variant is
  used directly instead.
* The `std::sys::stdio::wasip{1,2}` modules are deleted and the `unix`
  variant is used instead.
* The `std::sys:🧵:wasip{1,2}` modules are deleted and the `unix`
  variant is used instead.

Overall Rust's libstd is effectively more tightly bound to libc when
compiled to WASI targets. This is intended to mirror how it's expected
all other languages will also bind to WASI. This additionally has the
nice goal of drastically reducing the WASI-specific maintenance burden
in libstd (in theory) and the only real changes required here are extra
definitions being added to `libc` (done in separate PRs). This might be
required for more symbols in the future but for now everything should be
mostly complete.
2025-12-08 06:46:28 -08:00
..
alias-1.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
alias-2.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
alias-3.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
alias-4.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
alias-lev.js Add test for aliases partial match 2025-07-16 14:27:22 +02:00
alias.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
asrawfd.js fix rustdoc tests broke by trait item filtering 2025-10-02 15:28:00 -05:00
basic.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
const-is-nullary-func.js Treat other items as functions for the purpose of type-based search 2025-01-16 11:52:00 -06:00
core-transmute.js Revert "rustdoc search: prefer stable items in search results" 2025-08-14 13:06:05 +02:00
deduplication.js rustdoc: use a trie for name-based search 2024-11-13 12:04:46 -07:00
doc-alias-use.js add doc(alias("AsciiChar")) to core::ascii::Char 2025-06-20 11:11:51 -05:00
enum-option.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
exact-case.js rustdoc: show exact case-sensitive matches first 2024-08-23 13:05:24 -04:00
field-is-unary-func.js Treat other items as functions for the purpose of type-based search 2025-01-16 11:52:00 -06:00
filter-crate.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
filter-macro-attr-derive.js Add regression test for including derive macros in macro filtering 2025-10-27 16:00:32 +01:00
fn-forget.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
from_u.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
full-path-function.js Add tests for type-based search 2023-09-01 15:16:11 +02:00
iterator-type-signatures.js rustdoc-search: add support for associated types 2023-11-19 18:54:36 -07:00
keyword.js rustdoc-search: make primitives and keywords less special 2023-11-21 13:59:26 -07:00
macro-check.js rustdoc-search: make primitives and keywords less special 2023-11-21 13:59:26 -07:00
macro-print.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
never.js rustdoc-search: search never type with ! 2023-06-12 17:30:23 -07:00
option-type-signatures.js rustdoc-search: simplify rules for generics and type params 2024-10-30 12:27:48 -07:00
osstring-to-string.js rustdoc-search: update test with now-shorter function path 2024-12-13 09:08:44 -07:00
parser-bindings.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-errors.js rustdoc search: relax rules for identifiers 2025-10-20 12:58:55 -05:00
parser-filter.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-generics.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-hof.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-ident.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-literal.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-paths.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-quote.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-reference.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-returned.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-separators.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-slice-array.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-tuple.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
parser-weird-queries.js rustdoc-search: pass original names through AST 2024-10-30 10:35:38 -07:00
path-end-empty.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
path-maxeditdistance.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
path-ordering.js Adjust test for slightly changed inlining behavior 2024-12-26 18:31:55 -07:00
primitive.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
println-typo.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
quoted.js fix rustdoc tests broke by trait item filtering 2025-10-02 15:28:00 -05:00
reference-shrink.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
regex.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
return-based-sort.js for purely return-type based searches, deprioritize clone-like functions 2025-01-13 12:22:34 -06:00
return-specific-literal.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
return-specific.js rustdoc-search: search backend with partitioned suffix tree 2025-08-15 10:26:03 -07:00
search-by-number.js rustdoc search: relax rules for identifiers 2025-10-20 12:58:55 -05:00
should-fail.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
simd-type-signatures.js Adjust test for slightly changed inlining behavior 2024-12-26 18:31:55 -07:00
string-from_ut.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
struct-vec.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
trait-unbox.js fix rustdoc tests broke by trait item filtering 2025-10-02 15:28:00 -05:00
transmute-fail.js Revert "rustdoc search: prefer stable items in search results" 2025-08-14 13:06:05 +02:00
transmute.js Revert "rustdoc search: prefer stable items in search results" 2025-08-14 13:06:05 +02:00
typed-query.js Update rustdoc-js* format 2023-06-09 17:00:47 +02:00
unbox-type-result.js std: Use more unix.rs code on WASI targets 2025-12-08 06:46:28 -08:00
vec-new.js Remove the common prelude module 2025-02-11 13:04:27 -08:00
vec-type-signatures.js rustdoc-search: simplify rules for generics and type params 2024-10-30 12:27:48 -07:00
write.js rustdoc-search: case-sensitive only when capitals are used 2024-11-14 11:10:14 -07:00