Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
109 changes: 109 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,115 @@ jobs:
toolchain: stable
- run: cargo fmt --all -- --check

check:
name: Check
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [stable, nightly]
include:
- build: stable
os: ubuntu-latest
rust: stable
- build: nightly
os: ubuntu-latest
rust: nightly

env:
# -D warnings is commented out in our install-rust action; re-add it here.
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}

- run: rustup target add x86_64-apple-darwin
- run: cargo check --workspace --release -vv
- run: cargo check --workspace --release -vv --all-features
- run: cargo check --workspace --release -vv --target=x86_64-apple-darwin
- run: cargo check --workspace --release -vv --target=x86_64-apple-darwin --all-features

check-1_48:
name: Check
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [1.48]
include:
- build: 1.48
os: ubuntu-latest
rust: 1.48

env:
# -D warnings is commented out in our install-rust action; re-add it here.
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}

- run: rustup target add x86_64-apple-darwin
- run: cargo check --workspace --release -vv
- run: cargo check --workspace --release -vv --target=x86_64-apple-darwin

check-windows:
name: Check Windows
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [stable, nightly]
include:
- build: stable
os: windows-latest
rust: stable
- build: nightly
os: windows-latest
rust: nightly

env:
# -D warnings is commented out in our install-rust action; re-add it here.
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}

- run: cargo check --workspace --release -vv
- run: cargo check --workspace --release -vv --all-features

check-windows-1_48:
name: Check Windows
runs-on: ${{ matrix.os }}
strategy:
matrix:
build: [1.48]
include:
- build: 1.48
os: windows-latest
rust: 1.48

env:
# -D warnings is commented out in our install-rust action; re-add it here.
RUSTFLAGS: -D warnings
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: ./.github/actions/install-rust
with:
toolchain: ${{ matrix.rust }}

- run: cargo check --workspace --release -vv

test:
name: Test
runs-on: ${{ matrix.os }}
Expand Down
27 changes: 19 additions & 8 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,21 +17,32 @@ include = ["src", "build.rs", "Cargo.toml", "COPYRIGHT", "LICENSE*", "/*.md"]
# we'll prefer to have crates provide their own impls; this is just a
# temporary measure.

# Optionally depend on async-std just to provide impls for its types for now.
async-std = { version = "1.12.0", default-features = false, optional = true }
# Optionally depend on tokio to implement traits for its types for now.
tokio = { version = "1.6.0", features = ["io-std", "fs", "net", "process"], optional = true }
# Optionally depend on socket2 to implement traits for its types for now.
socket2 = { version = "0.4.0", optional = true }
# Optionally depend on mio to implement traits for its types for now.
mio = { version = "0.8.0", features = ["net", "os-ext"], optional = true }
# Optionally depend on fs_err to implement traits for its types for now.
fs-err = { version = "2.6.0", optional = true }

[target.'cfg(not(target_os = "wasi"))'.dependencies]
# Optionally depend on os_pipe to implement traits for its types for now.
os_pipe = { version = "1.0.0", optional = true }

# The following dependencies allow io-lifetimes to define impls for various
# third-party traits. This is only done in not(io_lifetimes_use_std) mode,
# because when we're using the std types and traits, we can't define impls
# on third-party traits, due to the orphan rule. Work is ongoing to add
# the needs impls upstream.
#
# These dependencies are currently disabled on WASI, because we need to
# enable some features which don't work on WASI yet. So for now, WASI users
# will need to wait until the impls are added upstream.

# Optionally depend on async-std just to provide impls for its types.
async-std = { version = "1.12.0", optional = true }
# Optionally depend on tokio to implement traits for its types.
tokio = { version = "1.6.0", features = ["io-std", "fs", "net", "process"], optional = true }
# Optionally depend on socket2 to implement traits for its types.
socket2 = { version = "0.4.0", optional = true }
# Optionally depend on mio to implement traits for its types.
mio = { version = "0.8.0", features = ["net", "os-ext"], optional = true }

[target.'cfg(not(windows))'.dependencies]
libc = { version = "0.2.96", optional = true }

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ they're simpler and safer to use. io-lifetimes doesn't include unsafe-io's
`*ReadWrite*` or `*HandleOrSocket*` abstractions, and leaves these as features
to be provided by separate layers on top.

## Minimum Supported Rust Version (MSRV)

This crate currently works on the version of [Rust on Debian stable], which is
currently Rust 1.48. This policy may change in the future, in minor version
releases, so users using a fixed version of Rust should pin to a specific
version of this crate.

[`OwnedFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/struct.OwnedFd.html
[`BorrowedFd`]: https://doc.rust-lang.org/stable/std/os/unix/io/struct.BorrowedFd.html
[RFC 3128]: https://github.com/rust-lang/rfcs/blob/master/text/3128-io-safety.md
10 changes: 10 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ fn main() {
// which, outside of `std`, are only available on nightly.
use_feature_or_nothing("rustc_attrs");

// Work around
// https://github.com/rust-lang/rust/issues/103306.
use_feature_or_nothing("wasi_ext");

// Rust 1.56 and earlier don't support panic in const fn.
if has_panic_in_const_fn() {
use_feature("panic_in_const_fn")
Expand All @@ -30,10 +34,13 @@ fn use_feature(feature: &str) {
fn has_feature(feature: &str) -> bool {
let out_dir = var("OUT_DIR").unwrap();
let rustc = var("RUSTC").unwrap();
let target = var("TARGET").unwrap();

let mut child = std::process::Command::new(rustc)
.arg("--crate-type=rlib") // Don't require `main`.
.arg("--emit=metadata") // Do as little as possible but still parse.
.arg("--target")
.arg(target)
.arg("--out-dir")
.arg(out_dir) // Put the output somewhere inconsequential.
.arg("-") // Read from stdin.
Expand All @@ -50,10 +57,13 @@ fn has_feature(feature: &str) -> bool {
fn has_panic_in_const_fn() -> bool {
let out_dir = var("OUT_DIR").unwrap();
let rustc = var("RUSTC").unwrap();
let target = var("TARGET").unwrap();

let mut child = std::process::Command::new(rustc)
.arg("--crate-type=rlib") // Don't require `main`.
.arg("--emit=metadata") // Do as little as possible but still parse.
.arg("--target")
.arg(target)
.arg("--out-dir")
.arg(out_dir) // Put the output somewhere inconsequential.
.arg("-") // Read from stdin.
Expand Down
2 changes: 2 additions & 0 deletions src/impls_std.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![allow(deprecated)] // Don't warn on `IntoFd` and `FromFd` impls.

#[cfg(any(unix, target_os = "wasi"))]
use crate::{AsFd, FromFd, IntoFd};
#[cfg(windows)]
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@

#![deny(missing_docs)]
#![cfg_attr(rustc_attrs, feature(rustc_attrs))]
#![cfg_attr(all(io_lifetimes_use_std, target_os = "wasi"), feature(wasi_ext))]
#![cfg_attr(
all(wasi_ext, io_lifetimes_use_std, target_os = "wasi"),
feature(wasi_ext)
)]
#![cfg_attr(io_lifetimes_use_std, feature(io_safety))]

mod portability;
Expand Down