Skip to content

Conversation

@AlexCharlton
Copy link
Contributor

The native and platform modules assume that either windows or unix is a target. There are preexisting guards against exposing these modules when compiling with a wasm target, but there are other possible targets that are not either windows or unix (e.g. embedded targets). Currently, typed-path will not compile on these other targets.

This PR requires that either windows or unix be a target when exposing the native and platform modules.

@chipsenkbeil chipsenkbeil merged commit 59e364a into chipsenkbeil:main Jul 7, 2025
17 checks passed
cdmurph32 added a commit to cdmurph32/typed-path that referenced this pull request Jan 21, 2026
After PR chipsenkbeil#51 added the requirement `any(windows, unix)` to expose native
and platform modules, and Rust changed WASI targets to set the `unix` cfg
(rust-lang/rust#147572), typed-path now attempts to compile code using
`std::os::wasi` for WASI targets. However, this is an unstable feature
requiring `#![feature(wasip2)]` when targeting wasm32-wasip2.

This commit adds the wasip2 feature flag conditionally only for wasip2
targets (target_env = "p2"), allowing the crate to compile with nightly
Rust for wasm32-wasip2 while maintaining compatibility with wasm32-wasip1
which does not have or need this feature.

Also fixes an unused import warning for `std::io` on wasm targets where
the `absolutize` function (which uses `io`) is not available.

Tested on both wasm32-wasip1 and wasm32-wasip2 targets - all 160 tests
pass on both platforms.
cdmurph32 added a commit to cdmurph32/typed-path that referenced this pull request Jan 21, 2026
After PR chipsenkbeil#51 added the requirement `any(windows, unix)` to expose native
and platform modules, and Rust changed WASI targets to set the `unix` cfg
(rust-lang/rust#147572), typed-path now attempts to compile code using
`std::os::wasi` for WASI targets. However, this is an unstable feature
requiring `#![feature(wasip2)]` when targeting wasm32-wasip2.

This commit adds the wasip2 feature flag conditionally only for wasip2
targets (target_env = "p2"), allowing the crate to compile with nightly
Rust for wasm32-wasip2 while maintaining compatibility with wasm32-wasip1
which does not have or need this feature.

Also fixes an unused import warning for `std::io` on wasm targets where
the `absolutize` function (which uses `io`) is not available.

Successfully tested on both wasm32-wasip1 and wasm32-wasip2 targets.
chipsenkbeil pushed a commit that referenced this pull request Jan 22, 2026
After PR #51 added the requirement `any(windows, unix)` to expose native
and platform modules, and Rust changed WASI targets to set the `unix` cfg
(rust-lang/rust#147572), typed-path now attempts to compile code using
`std::os::wasi` for WASI targets. However, this is an unstable feature
requiring `#![feature(wasip2)]` when targeting wasm32-wasip2.

This commit adds the wasip2 feature flag conditionally only for wasip2
targets (target_env = "p2"), allowing the crate to compile with nightly
Rust for wasm32-wasip2 while maintaining compatibility with wasm32-wasip1
which does not have or need this feature.

Also fixes an unused import warning for `std::io` on wasm targets where
the `absolutize` function (which uses `io`) is not available.

Successfully tested on both wasm32-wasip1 and wasm32-wasip2 targets.
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.

2 participants