From b3a19c7737a62d495197d9e572fd0f2ce5b1073f Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 26 Feb 2023 12:58:48 +0100 Subject: [PATCH 01/10] Use actions/checkout@v3 Instead of the unstable master branch. --- .github/workflows/main.yml | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ea5feb82..96475f66 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,6 @@ on: env: CARGO_TERM_COLOR: always RUST_BACKTRACE: full - jobs: Test: name: Test @@ -36,7 +35,7 @@ jobs: os: windows-latest rust: stable steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Install Rust (rustup) run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} shell: bash @@ -44,17 +43,15 @@ jobs: uses: taiki-e/install-action@cargo-hack - name: Run tests run: cargo hack test --feature-powerset && cargo hack test --feature-powerset --release - Rustfmt: name: Rustfmt runs-on: ubuntu-latest steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Install Rust run: rustup update stable && rustup default stable && rustup component add rustfmt - name: Check formatting run: cargo fmt --all -- --check - Check: name: Check runs-on: ubuntu-latest @@ -63,7 +60,7 @@ jobs: matrix: target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-netbsd", "x86_64-unknown-redox"] steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Install Rust run: rustup update stable && rustup default stable - name: Install Target @@ -72,12 +69,11 @@ jobs: uses: taiki-e/install-action@cargo-hack - name: Run check run: cargo hack check --feature-powerset --all-targets --examples --bins --tests --target ${{ matrix.target }} - Clippy: name: Clippy runs-on: ubuntu-latest steps: - - uses: actions/checkout@master + - uses: actions/checkout@v3 - name: Install Rust run: rustup update stable && rustup default stable && rustup component add clippy - name: Run Clippy From 119f7cf96b8894f4a0541804711003d5352c920a Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 26 Feb 2023 13:04:13 +0100 Subject: [PATCH 02/10] Fix various doc links --- src/sys/unix.rs | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/sys/unix.rs b/src/sys/unix.rs index b022b939..b748158b 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -1461,7 +1461,7 @@ impl crate::Socket { /// /// For more information about this option, see [`set_cork`]. /// - /// [`set_cork`]: Socket::set_cork + /// [`set_cork`]: crate::Socket::set_cork #[cfg(all( feature = "all", any(target_os = "android", target_os = "fuchsia", target_os = "linux") @@ -1512,7 +1512,7 @@ impl crate::Socket { /// /// For more information about this option, see [`set_quickack`]. /// - /// [`set_quickack`]: Socket::set_quickack + /// [`set_quickack`]: crate::Socket::set_quickack #[cfg(all( feature = "all", any(target_os = "android", target_os = "fuchsia", target_os = "linux") @@ -1563,7 +1563,7 @@ impl crate::Socket { /// /// For more information about this option, see [`set_thin_linear_timeouts`]. /// - /// [`set_thin_linear_timeouts`]: Socket::set_thin_linear_timeouts + /// [`set_thin_linear_timeouts`]: crate::Socket::set_thin_linear_timeouts #[cfg(all( feature = "all", any(target_os = "android", target_os = "fuchsia", target_os = "linux") @@ -2225,7 +2225,7 @@ impl crate::Socket { /// /// For more information about this option, see [`set_tcp_user_timeout`]. /// - /// [`set_tcp_user_timeout`]: Socket::set_tcp_user_timeout + /// [`set_tcp_user_timeout`]: crate::Socket::set_tcp_user_timeout #[cfg(all( feature = "all", any(target_os = "android", target_os = "fuchsia", target_os = "linux") @@ -2276,6 +2276,8 @@ impl crate::Socket { /// Detach Berkeley Packet Filter(BPF) from this socket. /// /// For more information about this option, see [`attach_filter`] + /// + /// [`attach_filter`]: crate::Socket::attach_filter #[cfg(all(feature = "all", any(target_os = "linux", target_os = "android")))] pub fn detach_filter(&self) -> io::Result<()> { unsafe { setsockopt(self.as_raw(), libc::SOL_SOCKET, libc::SO_DETACH_FILTER, 0) } @@ -2285,7 +2287,7 @@ impl crate::Socket { /// /// For more information about this option, see [`set_tclass_v6`]. /// - /// [`set_tclass_v6`]: Socket::set_tclass_v6 + /// [`set_tclass_v6`]: crate::Socket::set_tclass_v6 #[cfg(all( feature = "all", any( @@ -2370,7 +2372,7 @@ impl crate::Socket { /// /// For more information about this option, see [`set_tcp_congestion`]. /// - /// [`set_tcp_congestion`]: Socket::set_tcp_congestion + /// [`set_tcp_congestion`]: crate::Socket::set_tcp_congestion #[cfg(all(feature = "all", any(target_os = "freebsd", target_os = "linux")))] #[cfg_attr( docsrs, From fcf67dde0e6f76fbc3e2816066c2b30833a069bb Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 26 Feb 2023 13:12:00 +0100 Subject: [PATCH 03/10] Document all targets on docs.rs --- Cargo.toml | 1 + Makefile | 1 + 2 files changed, 2 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index c908aa89..16ed96df 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,7 @@ include = [ [package.metadata.docs.rs] all-features = true rustdoc-args = ["--cfg", "docsrs"] +targets = ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-netbsd", "x86_64-unknown-redox"] [package.metadata.playground] features = ["all"] diff --git a/Makefile b/Makefile index e92a0cab..1a15561e 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,5 @@ # Targets available via Rustup that are supported. +# NOTE: keep in sync with the CI and docs.rs targets. TARGETS ?= "aarch64-apple-ios" "aarch64-linux-android" "x86_64-apple-darwin" "x86_64-fuchsia" "x86_64-pc-windows-msvc" "x86_64-pc-solaris" "x86_64-unknown-freebsd" "x86_64-unknown-illumos" "x86_64-unknown-linux-gnu" "x86_64-unknown-netbsd" "x86_64-unknown-redox" test: From 467cbbf76911f7200b31f23990b2e749e59d8465 Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 26 Feb 2023 13:12:49 +0100 Subject: [PATCH 04/10] Check docs in Check job --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 96475f66..ed708f9e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -58,7 +58,7 @@ jobs: strategy: fail-fast: false matrix: - target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-netbsd", "x86_64-unknown-redox"] + target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-netbsd", "x86_64-unknown-redox"] steps: - uses: actions/checkout@v3 - name: Install Rust @@ -69,6 +69,8 @@ jobs: uses: taiki-e/install-action@cargo-hack - name: Run check run: cargo hack check --feature-powerset --all-targets --examples --bins --tests --target ${{ matrix.target }} + - name: Check docs for docs.rs + run: RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo doc --no-deps --all-features --target ${{ matrix.target }} Clippy: name: Clippy runs-on: ubuntu-latest From 23156eebf1b60bdb3165b29ec960ec2a487701b6 Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 26 Feb 2023 13:21:41 +0100 Subject: [PATCH 05/10] Fix various doc attributes --- src/lib.rs | 4 ++-- src/socket.rs | 6 +++--- src/sys/unix.rs | 34 +++++++++++++++++----------------- 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index e85124d5..80d1bd72 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -261,7 +261,7 @@ impl Type { /// /// Used for the DCCP protocol. #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub const DCCP: Type = Type(sys::SOCK_DCCP); /// Type corresponding to `SOCK_SEQPACKET`. @@ -316,7 +316,7 @@ impl Protocol { /// Protocol corresponding to `DCCP`. #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub const DCCP: Protocol = Protocol(sys::IPPROTO_DCCP); #[cfg(all(feature = "all", any(target_os = "freebsd", target_os = "linux")))] diff --git a/src/socket.rs b/src/socket.rs index 85344b7a..e65552de 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -367,7 +367,7 @@ impl Socket { /// /// On Windows it is not possible retrieve the nonblocking mode status. #[cfg(all(feature = "all", unix))] - #[cfg_attr(docsrs, doc(all(feature = "all", unix)))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix))))] pub fn nonblocking(&self) -> io::Result { sys::nonblocking(self.as_raw()) } @@ -1084,7 +1084,7 @@ impl Socket { /// /// [`set_header_included`]: Socket::set_header_included #[cfg(all(feature = "all", not(target_os = "redox")))] - #[cfg_attr(docsrs, doc(all(feature = "all", not(target_os = "redox"))))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", not(target_os = "redox")))))] pub fn header_included(&self) -> io::Result { unsafe { getsockopt::(self.as_raw(), sys::IPPROTO_IP, sys::IP_HDRINCL) @@ -1104,7 +1104,7 @@ impl Socket { /// [`IP_TTL`]: Socket::set_ttl /// [`IP_TOS`]: Socket::set_tos #[cfg(all(feature = "all", not(target_os = "redox")))] - #[cfg_attr(docsrs, doc(all(feature = "all", not(target_os = "redox"))))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", not(target_os = "redox")))))] pub fn set_header_included(&self, included: bool) -> io::Result<()> { unsafe { setsockopt( diff --git a/src/sys/unix.rs b/src/sys/unix.rs index b748158b..a284c720 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -2428,7 +2428,7 @@ impl crate::Socket { /// [`connect`]: crate::Socket::connect /// [`bind`]: crate::Socket::bind #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn set_dccp_service(&self, code: u32) -> io::Result<()> { unsafe { setsockopt( @@ -2446,7 +2446,7 @@ impl crate::Socket { /// /// [`set_dccp_service`]: crate::Socket::set_dccp_service #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn dccp_service(&self) -> io::Result { unsafe { getsockopt(self.as_raw(), libc::SOL_DCCP, libc::DCCP_SOCKOPT_SERVICE) } } @@ -2455,7 +2455,7 @@ impl crate::Socket { /// /// This option sets both the TX and RX CCIDs at the same time. #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn set_dccp_ccid(&self, ccid: u8) -> io::Result<()> { unsafe { setsockopt(self.as_raw(), libc::SOL_DCCP, libc::DCCP_SOCKOPT_CCID, ccid) } } @@ -2466,7 +2466,7 @@ impl crate::Socket { /// /// [`set_dccp_ccid`]: crate::Socket::set_dccp_ccid #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn dccp_tx_ccid(&self) -> io::Result { unsafe { getsockopt(self.as_raw(), libc::SOL_DCCP, libc::DCCP_SOCKOPT_TX_CCID) } } @@ -2477,7 +2477,7 @@ impl crate::Socket { /// /// [`set_dccp_ccid`]: crate::Socket::set_dccp_ccid #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn dccp_xx_ccid(&self) -> io::Result { unsafe { getsockopt(self.as_raw(), libc::SOL_DCCP, libc::DCCP_SOCKOPT_RX_CCID) } } @@ -2487,7 +2487,7 @@ impl crate::Socket { /// Enables a listening socket to hold timewait state when closing the /// connection. This option must be set after `accept` returns. #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn set_dccp_server_timewait(&self, hold_timewait: bool) -> io::Result<()> { unsafe { setsockopt( @@ -2505,7 +2505,7 @@ impl crate::Socket { /// /// [`set_dccp_server_timewait`]: crate::Socket::set_dccp_server_timewait #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn dccp_server_timewait(&self) -> io::Result { unsafe { getsockopt( @@ -2524,7 +2524,7 @@ impl crate::Socket { /// accepted by the receiver. Hence, when using this feature on the sender, /// it must be enabled at the receiver too, with suitable choice of CsCov. #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn set_dccp_send_cscov(&self, level: u32) -> io::Result<()> { unsafe { setsockopt( @@ -2542,7 +2542,7 @@ impl crate::Socket { /// /// [`set_dccp_send_cscov`]: crate::Socket::set_dccp_send_cscov #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn dccp_send_cscov(&self) -> io::Result { unsafe { getsockopt(self.as_raw(), libc::SOL_DCCP, libc::DCCP_SOCKOPT_SEND_CSCOV) } } @@ -2553,7 +2553,7 @@ impl crate::Socket { /// /// [`set_dccp_send_cscov`]: crate::Socket::set_dccp_send_cscov #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn set_dccp_recv_cscov(&self, level: u32) -> io::Result<()> { unsafe { setsockopt( @@ -2571,7 +2571,7 @@ impl crate::Socket { /// /// [`set_dccp_recv_cscov`]: crate::Socket::set_dccp_recv_cscov #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn dccp_recv_cscov(&self) -> io::Result { unsafe { getsockopt(self.as_raw(), libc::SOL_DCCP, libc::DCCP_SOCKOPT_RECV_CSCOV) } } @@ -2581,7 +2581,7 @@ impl crate::Socket { /// This option sets the maximum length of the output queue. A zero value is /// interpreted as unbounded queue length. #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn set_dccp_qpolicy_txqlen(&self, length: u32) -> io::Result<()> { unsafe { setsockopt( @@ -2599,7 +2599,7 @@ impl crate::Socket { /// /// [`set_dccp_qpolicy_txqlen`]: crate::Socket::set_dccp_qpolicy_txqlen #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn dccp_qpolicy_txqlen(&self) -> io::Result { unsafe { getsockopt( @@ -2620,7 +2620,7 @@ impl crate::Socket { /// /// [documentation]: https://www.kernel.org/doc/html/latest/networking/dccp.html #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn dccp_available_ccids(&self) -> io::Result> { let mut endpoints = [0; N]; let mut length = endpoints.len() as libc::socklen_t; @@ -2639,7 +2639,7 @@ impl crate::Socket { /// This option retrieves the current maximum packet size (application /// payload size) in bytes. #[cfg(all(feature = "all", target_os = "linux"))] - #[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] + #[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] pub fn dccp_cur_mps(&self) -> io::Result { unsafe { getsockopt( @@ -2653,7 +2653,7 @@ impl crate::Socket { /// See [`Socket::dccp_available_ccids`]. #[cfg(all(feature = "all", target_os = "linux"))] -#[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] +#[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] #[derive(Debug)] pub struct CcidEndpoints { endpoints: [u8; N], @@ -2661,7 +2661,7 @@ pub struct CcidEndpoints { } #[cfg(all(feature = "all", target_os = "linux"))] -#[cfg_attr(docsrs, doc(cfg(feature = "all", target_os = "linux")))] +#[cfg_attr(docsrs, doc(cfg(all(feature = "all", target_os = "linux"))))] impl std::ops::Deref for CcidEndpoints { type Target = [u8]; From a4044e1bcb35a318662f8477b3ee6f5043ba31fc Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 26 Feb 2023 13:28:18 +0100 Subject: [PATCH 06/10] Use dtolnay/rust-toolchain to install toolchain in CI --- .github/workflows/main.yml | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ed708f9e..05fdcc18 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -36,11 +36,10 @@ jobs: rust: stable steps: - uses: actions/checkout@v3 - - name: Install Rust (rustup) - run: rustup update ${{ matrix.rust }} --no-self-update && rustup default ${{ matrix.rust }} - shell: bash - - name: Install cargo-hack - uses: taiki-e/install-action@cargo-hack + - uses: dtolnay/rust-toolchain@master + with: + toolchain: ${{ matrix.rust }} + - uses: taiki-e/install-action@cargo-hack - name: Run tests run: cargo hack test --feature-powerset && cargo hack test --feature-powerset --release Rustfmt: @@ -48,8 +47,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Install Rust - run: rustup update stable && rustup default stable && rustup component add rustfmt + - uses: dtolnay/rust-toolchain@stable - name: Check formatting run: cargo fmt --all -- --check Check: @@ -61,12 +59,10 @@ jobs: target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-netbsd", "x86_64-unknown-redox"] steps: - uses: actions/checkout@v3 - - name: Install Rust - run: rustup update stable && rustup default stable - - name: Install Target - run: rustup target add ${{ matrix.target }} - - name: Install cargo-hack - uses: taiki-e/install-action@cargo-hack + - uses: dtolnay/rust-toolchain@nightly # NOTE: need nightly for `doc_cfg` feature. + with: + targets: ${{ matrix.target }} + - uses: taiki-e/install-action@cargo-hack - name: Run check run: cargo hack check --feature-powerset --all-targets --examples --bins --tests --target ${{ matrix.target }} - name: Check docs for docs.rs @@ -76,7 +72,6 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Install Rust - run: rustup update stable && rustup default stable && rustup component add clippy + - uses: dtolnay/rust-toolchain@stable - name: Run Clippy run: cargo clippy --all-targets --all-features -- -D warnings From 0f7bf8c9d9f93f38a710e059344e6b94d668f217 Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 26 Feb 2023 13:42:39 +0100 Subject: [PATCH 07/10] Add Type::cloexec for Solaris --- src/sys/unix.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/sys/unix.rs b/src/sys/unix.rs index a284c720..c4a210c9 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -408,7 +408,8 @@ impl Type { target_os = "illumos", target_os = "linux", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", + target_os = "solaris", ) ))] #[cfg_attr( @@ -423,7 +424,8 @@ impl Type { target_os = "illumos", target_os = "linux", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", + target_os = "solaris", ) ))) )] @@ -439,7 +441,8 @@ impl Type { target_os = "illumos", target_os = "linux", target_os = "netbsd", - target_os = "openbsd" + target_os = "openbsd", + target_os = "solaris", ))] pub(crate) const fn _cloexec(self) -> Type { Type(self.0 | libc::SOCK_CLOEXEC) From d4353771566258fe6d62ff8e9e5b1a343f884b45 Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 26 Feb 2023 13:49:15 +0100 Subject: [PATCH 08/10] Add Type::cloexec for Redox --- src/sys/unix.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sys/unix.rs b/src/sys/unix.rs index c4a210c9..7d7223f1 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -409,6 +409,7 @@ impl Type { target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "redox", target_os = "solaris", ) ))] @@ -425,6 +426,7 @@ impl Type { target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "redox", target_os = "solaris", ) ))) @@ -442,6 +444,7 @@ impl Type { target_os = "linux", target_os = "netbsd", target_os = "openbsd", + target_os = "redox", target_os = "solaris", ))] pub(crate) const fn _cloexec(self) -> Type { From ef9633c98e69210490d8ab881a2396ba4482550e Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 26 Feb 2023 13:55:11 +0100 Subject: [PATCH 09/10] Allow some broken links It's too much of a hassle to fix these on all platforms, so they can simply be displayed as text, without a link. --- src/socket.rs | 12 +++++++++--- src/sys/unix.rs | 9 +++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/socket.rs b/src/socket.rs index e65552de..1898e8a7 100644 --- a/src/socket.rs +++ b/src/socket.rs @@ -425,6 +425,7 @@ impl Socket { /// /// [`recv`]: Socket::recv /// [`out_of_band_inline`]: Socket::out_of_band_inline + #[cfg_attr(target_os = "redox", allow(rustdoc::broken_intra_doc_links))] pub fn recv_out_of_band(&self, buf: &mut [MaybeUninit]) -> io::Result { self.recv_with_flags(buf, sys::MSG_OOB) } @@ -640,7 +641,7 @@ impl Socket { /// Identical to [`send`] but allows for specification of arbitrary flags to the underlying /// `send` call. /// - /// [`send`]: #method.send + /// [`send`]: Socket::send pub fn send_with_flags(&self, buf: &[u8], flags: c_int) -> io::Result { sys::send(self.as_raw(), buf, flags) } @@ -672,8 +673,9 @@ impl Socket { /// /// For more information, see [`send`], [`out_of_band_inline`]. /// - /// [`send`]: #method.send - /// [`out_of_band_inline`]: #method.out_of_band_inline + /// [`send`]: Socket::send + /// [`out_of_band_inline`]: Socket::out_of_band_inline + #[cfg_attr(target_os = "redox", allow(rustdoc::broken_intra_doc_links))] pub fn send_out_of_band(&self, buf: &[u8]) -> io::Result { self.send_with_flags(buf, sys::MSG_OOB) } @@ -1103,6 +1105,10 @@ impl Socket { /// [raw(7)]: https://man7.org/linux/man-pages/man7/raw.7.html /// [`IP_TTL`]: Socket::set_ttl /// [`IP_TOS`]: Socket::set_tos + #[cfg_attr( + any(target_os = "illumos", target_os = "solaris"), + allow(rustdoc::broken_intra_doc_links) + )] #[cfg(all(feature = "all", not(target_os = "redox")))] #[cfg_attr(docsrs, doc(cfg(all(feature = "all", not(target_os = "redox")))))] pub fn set_header_included(&self, included: bool) -> io::Result<()> { diff --git a/src/sys/unix.rs b/src/sys/unix.rs index 7d7223f1..6c4dd363 100644 --- a/src/sys/unix.rs +++ b/src/sys/unix.rs @@ -1221,6 +1221,15 @@ impl crate::Socket { /// # Notes /// /// On supported platforms you can use [`Type::cloexec`]. + #[cfg_attr( + any( + target_os = "ios", + target_os = "macos", + target_os = "tvos", + target_os = "watchos" + ), + allow(rustdoc::broken_intra_doc_links) + )] #[cfg(feature = "all")] #[cfg_attr(docsrs, doc(cfg(all(feature = "all", unix))))] pub fn set_cloexec(&self, close_on_exec: bool) -> io::Result<()> { From c203df08fad34ceb2551c19aa8b28da0eb9b9bd4 Mon Sep 17 00:00:00 2001 From: Thomas de Zeeuw Date: Sun, 26 Feb 2023 13:58:49 +0100 Subject: [PATCH 10/10] Split checking of docs in CI And use stable Rust again for the Check jobs. --- .github/workflows/main.yml | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 05fdcc18..2eba4dc7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -59,14 +59,12 @@ jobs: target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-fuchsia", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-netbsd", "x86_64-unknown-redox"] steps: - uses: actions/checkout@v3 - - uses: dtolnay/rust-toolchain@nightly # NOTE: need nightly for `doc_cfg` feature. + - uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - uses: taiki-e/install-action@cargo-hack - name: Run check run: cargo hack check --feature-powerset --all-targets --examples --bins --tests --target ${{ matrix.target }} - - name: Check docs for docs.rs - run: RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo doc --no-deps --all-features --target ${{ matrix.target }} Clippy: name: Clippy runs-on: ubuntu-latest @@ -75,3 +73,19 @@ jobs: - uses: dtolnay/rust-toolchain@stable - name: Run Clippy run: cargo clippy --all-targets --all-features -- -D warnings + Docs: + name: Docs + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + # NOTE: missing "x86_64-fuchsia", nightly unavailable at the time of + # writing. + target: ["aarch64-apple-ios", "aarch64-linux-android", "x86_64-apple-darwin", "x86_64-pc-windows-msvc", "x86_64-pc-solaris", "x86_64-unknown-freebsd", "x86_64-unknown-illumos", "x86_64-unknown-linux-gnu", "x86_64-unknown-netbsd", "x86_64-unknown-redox"] + steps: + - uses: actions/checkout@v3 + - uses: dtolnay/rust-toolchain@nightly # NOTE: need nightly for `doc_cfg` feature. + with: + targets: ${{ matrix.target }} + - name: Check docs for docs.rs + run: RUSTDOCFLAGS="-D warnings --cfg docsrs" cargo doc --no-deps --all-features --target ${{ matrix.target }}