Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 6 pull requests #102413

Closed
wants to merge 21 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
c846a2a
Make `std::os::fd` public.
sunfishcode Jun 14, 2022
09bbc42
Update asrawfd.js.
sunfishcode Jun 22, 2022
bda1262
Clarify that the `fd` module is supported on Unix and WASI.
sunfishcode Jun 30, 2022
7d80510
Re-introduce `unstable` attributes.
sunfishcode Aug 23, 2022
a7f3ba9
Fix compilation of the doc tests on Windows.
sunfishcode Sep 2, 2022
f9ef7e2
code refactoring smart_resolve_report_errors
chenyukang Sep 20, 2022
7adfb44
add trivial comments
chenyukang Sep 21, 2022
fdda7e0
more code refactor on smart_resolve_report_errors
chenyukang Sep 25, 2022
db0877f
trivial fix on fallback
chenyukang Sep 25, 2022
cca4828
Format type_of
compiler-errors Sep 26, 2022
05267b5
Make type_of work correctly for const arg bindings
compiler-errors Sep 26, 2022
92561f4
Support bindings with anon consts in generics
compiler-errors Sep 26, 2022
7f06d51
Don't export `__heap_base` and `__data_end` on wasm32-wasi.
sunfishcode Sep 28, 2022
356a52c
add regression test
Rageking8 Sep 28, 2022
715d61d
errors: rename `typeck.ftl` to `hir_analysis.ftl`
davidtwco Sep 28, 2022
c76cda9
Rollup merge of #98368 - sunfishcode:sunfishcode/std-os-fd, r=joshtri…
Dylan-DPC Sep 28, 2022
528956c
Rollup merge of #102085 - chenyukang:code-refactor, r=cjgillot
Dylan-DPC Sep 28, 2022
d049c3e
Rollup merge of #102336 - compiler-errors:issue-102333, r=jackh726
Dylan-DPC Sep 28, 2022
9c4b247
Rollup merge of #102385 - sunfishcode:sunfishcode/wasm-no-export-heap…
Dylan-DPC Sep 28, 2022
d72a105
Rollup merge of #102393 - Rageking8:add-regression-test-for-issue-949…
Dylan-DPC Sep 28, 2022
51743a2
Rollup merge of #102395 - davidtwco:translation-rename-typeck, r=este…
Dylan-DPC Sep 28, 2022
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
Next Next commit
Make std::os::fd public.
`std::os::fd` defines types like `OwnedFd` and `RawFd` and is common
between Unix and non-Unix platforms that share a basic file-descriptor
concept. Rust currently uses this internally to simplify its own code,
but it would be useful for external users in the same way, so make it
public.

This means that `OwnedFd` etc. will all appear in three places, for
example on unix platforms:
 - `std::os::fd::OwnedFd`
 - `std::os::unix::io::OwnedFd`
 - `std::os::unix::prelude::OwnedFd`
  • Loading branch information
sunfishcode committed Aug 29, 2022
commit c846a2af8ddaa14ff2c2da25bc97bbd8d4284df2
14 changes: 12 additions & 2 deletions library/std/src/os/fd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,26 @@
//! Owned and borrowed Unix-like file descriptors.
//!
//! This module is supported on Unix platforms, and also some non-Unix
//! platforms which use a similar file descriptor system for referencing OS
//! resources.

#![stable(feature = "io_safety", since = "1.63.0")]
#![deny(unsafe_op_in_unsafe_fn)]

// `RawFd`, `AsRawFd`, etc.
pub mod raw;
mod raw;

// `OwnedFd`, `AsFd`, etc.
pub mod owned;
mod owned;

// Implementations for `AsRawFd` etc. for network types.
mod net;

#[cfg(test)]
mod tests;

// Export the types and traits for the public API.
#[stable(feature = "io_safety", since = "1.63.0")]
pub use owned::*;
#[stable(feature = "rust1", since = "1.0.0")]
pub use raw::*;
5 changes: 1 addition & 4 deletions library/std/src/os/fd/owned.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,7 @@ pub trait AsFd {
/// ```rust,no_run
/// use std::fs::File;
/// # use std::io;
/// # #[cfg(target_os = "wasi")]
/// # use std::os::wasi::io::{AsFd, BorrowedFd};
/// # #[cfg(unix)]
/// # use std::os::unix::io::{AsFd, BorrowedFd};
/// # use std::os::fd::{AsFd, BorrowedFd};
///
/// let mut f = File::open("foo.txt")?;
/// # #[cfg(any(unix, target_os = "wasi"))]
Expand Down
15 changes: 3 additions & 12 deletions library/std/src/os/fd/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,7 @@ pub trait AsRawFd {
/// ```no_run
/// use std::fs::File;
/// # use std::io;
/// #[cfg(unix)]
/// use std::os::unix::io::{AsRawFd, RawFd};
/// #[cfg(target_os = "wasi")]
/// use std::os::wasi::io::{AsRawFd, RawFd};
/// use std::os::fd::{AsRawFd, RawFd};
///
/// let mut f = File::open("foo.txt")?;
/// // Note that `raw_fd` is only valid as long as `f` exists.
Expand Down Expand Up @@ -83,10 +80,7 @@ pub trait FromRawFd {
/// ```no_run
/// use std::fs::File;
/// # use std::io;
/// #[cfg(unix)]
/// use std::os::unix::io::{FromRawFd, IntoRawFd, RawFd};
/// #[cfg(target_os = "wasi")]
/// use std::os::wasi::io::{FromRawFd, IntoRawFd, RawFd};
/// use std::os::fd::{FromRawFd, IntoRawFd, RawFd};
///
/// let f = File::open("foo.txt")?;
/// # #[cfg(any(unix, target_os = "wasi"))]
Expand Down Expand Up @@ -121,10 +115,7 @@ pub trait IntoRawFd {
/// ```no_run
/// use std::fs::File;
/// # use std::io;
/// #[cfg(unix)]
/// use std::os::unix::io::{IntoRawFd, RawFd};
/// #[cfg(target_os = "wasi")]
/// use std::os::wasi::io::{IntoRawFd, RawFd};
/// use std::os::fd::{IntoRawFd, RawFd};
///
/// let f = File::open("foo.txt")?;
/// #[cfg(any(unix, target_os = "wasi"))]
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/os/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ pub mod solid;
pub mod vxworks;

#[cfg(any(unix, target_os = "wasi", doc))]
mod fd;
pub mod fd;

#[cfg(any(target_os = "linux", target_os = "android", doc))]
mod net;
8 changes: 0 additions & 8 deletions library/std/src/os/unix/io/fd.rs

This file was deleted.

11 changes: 5 additions & 6 deletions library/std/src/os/unix/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,9 @@

#![stable(feature = "rust1", since = "1.0.0")]

mod fd;
mod raw;

#[stable(feature = "io_safety", since = "1.63.0")]
pub use fd::*;
#[stable(feature = "rust1", since = "1.0.0")]
pub use raw::*;
pub use crate::os::fd::*;

// Tests for this module
#[cfg(test)]
mod tests;
6 changes: 0 additions & 6 deletions library/std/src/os/unix/io/raw.rs

This file was deleted.

8 changes: 1 addition & 7 deletions library/std/src/os/wasi/io/mod.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
//! WASI-specific extensions to general I/O primitives.

#![deny(unsafe_op_in_unsafe_fn)]
#![unstable(feature = "wasi_ext", issue = "71213")]

mod fd;
mod raw;

#[unstable(feature = "wasi_ext", issue = "71213")]
pub use fd::*;
#[unstable(feature = "wasi_ext", issue = "71213")]
pub use raw::*;
pub use crate::os::fd::*;