Skip to content

Commit 9e56392

Browse files
committed
CI: Use a cargo feature to control 'no_coverage'
1 parent 88ebcca commit 9e56392

File tree

12 files changed

+23
-26
lines changed

12 files changed

+23
-26
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ jobs:
7575
run: cargo fmt --all -- --check
7676

7777
- name: Clippy
78-
run: cargo clippy --workspace --all-features --all-targets -- -D warnings
78+
run: cargo clippy --workspace --all-targets --features "block_on executor" -- -D warnings
7979

8080
ci-linux:
8181
name: CI
@@ -128,7 +128,7 @@ jobs:
128128
uses: actions-rs/cargo@v1
129129
with:
130130
command: test
131-
args: --all-features
131+
args: --features "block_on executor"
132132

133133
- name: Run book tests
134134
uses: actions-rs/cargo@v1
@@ -254,7 +254,7 @@ jobs:
254254
uses: actions-rs/cargo@v1
255255
with:
256256
command: doc
257-
args: --no-deps --all-features
257+
args: --no-deps --features "block_on executor"
258258

259259
- run: rsync -r target/doc/ doc/src/api
260260

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,10 @@ futures = "0.3.5"
3636
[features]
3737
block_on = ["pin-utils"]
3838
executor = ["async-task"]
39+
nightly_coverage = []
3940

4041
[package.metadata.docs.rs]
41-
all-features = true
42+
features = ["block_on", "executor"]
4243
rustdoc-args = ["--cfg", "docsrs"]
4344

4445
[[test]]

clippy.toml

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/error.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub enum Error {
4444
impl From<nix::errno::Errno> for Error {
4545
/// Converts a [`nix::Error`] into a wrapped version of the equivalent
4646
/// [`std::io::Error`].
47-
#[cfg_attr(coverage, no_coverage)]
47+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
4848
fn from(err: nix::errno::Errno) -> Self {
4949
Into::<std::io::Error>::into(err).into()
5050
}
@@ -76,7 +76,7 @@ pub struct InsertError<T> {
7676
}
7777

7878
impl<T> Debug for InsertError<T> {
79-
#[cfg_attr(coverage, no_coverage)]
79+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
8080
fn fmt(&self, formatter: &mut Formatter) -> core::result::Result<(), fmt::Error> {
8181
write!(formatter, "{:?}", self.error)
8282
}
@@ -85,7 +85,7 @@ impl<T> Debug for InsertError<T> {
8585
impl<T> From<InsertError<T>> for crate::Error {
8686
/// Converts the [`InsertError`] into Calloop's error type, throwing away
8787
/// the contained source.
88-
#[cfg_attr(coverage, no_coverage)]
88+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
8989
fn from(e: InsertError<T>) -> crate::Error {
9090
e.error
9191
}

src/io.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct Async<'l, F: AsFd> {
4141
}
4242

4343
impl<'l, F: AsFd + std::fmt::Debug> std::fmt::Debug for Async<'l, F> {
44-
#[cfg_attr(coverage, no_coverage)]
44+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
4545
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
4646
f.debug_struct("Async").field("fd", &self.fd).finish()
4747
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@
143143
#![warn(missing_docs, missing_debug_implementations)]
144144
#![allow(clippy::needless_doctest_main)]
145145
#![cfg_attr(docsrs, feature(doc_cfg))]
146-
#![cfg_attr(coverage, feature(no_coverage))]
146+
#![cfg_attr(feature = "nightly_coverage", feature(no_coverage))]
147147

148148
mod sys;
149149

src/loop_logic.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,14 +70,14 @@ pub struct LoopHandle<'l, Data> {
7070
}
7171

7272
impl<'l, Data> std::fmt::Debug for LoopHandle<'l, Data> {
73-
#[cfg_attr(coverage, no_coverage)]
73+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
7474
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
7575
f.write_str("LoopHandle { ... }")
7676
}
7777
}
7878

7979
impl<'l, Data> Clone for LoopHandle<'l, Data> {
80-
#[cfg_attr(coverage, no_coverage)]
80+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
8181
fn clone(&self) -> Self {
8282
LoopHandle {
8383
inner: self.inner.clone(),
@@ -115,7 +115,7 @@ impl<'l, Data> LoopHandle<'l, Data> {
115115
/// Use this function if you need access to the event source after its insertion in the loop.
116116
///
117117
/// See also `insert_source`.
118-
#[cfg_attr(coverage, no_coverage)] // Contains a branch we can't hit w/o OOM
118+
#[cfg_attr(feature = "nightly_coverage", no_coverage)] // Contains a branch we can't hit w/o OOM
119119
pub fn register_dispatcher<S>(
120120
&self,
121121
dispatcher: Dispatcher<'l, S, Data>,
@@ -241,7 +241,7 @@ pub struct EventLoop<'l, Data> {
241241
}
242242

243243
impl<'l, Data> std::fmt::Debug for EventLoop<'l, Data> {
244-
#[cfg_attr(coverage, no_coverage)]
244+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
245245
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
246246
f.write_str("EventLoop { ... }")
247247
}
@@ -573,7 +573,7 @@ pub struct LoopSignal {
573573
}
574574

575575
impl std::fmt::Debug for LoopSignal {
576-
#[cfg_attr(coverage, no_coverage)]
576+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
577577
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
578578
f.write_str("LoopSignal { ... }")
579579
}

src/sources/channel.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub struct Sender<T> {
3636
}
3737

3838
impl<T> Clone for Sender<T> {
39-
#[cfg_attr(coverage, no_coverage)]
39+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
4040
fn clone(&self) -> Sender<T> {
4141
Sender {
4242
sender: self.sender.clone(),
@@ -72,7 +72,7 @@ pub struct SyncSender<T> {
7272
}
7373

7474
impl<T> Clone for SyncSender<T> {
75-
#[cfg_attr(coverage, no_coverage)]
75+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
7676
fn clone(&self) -> SyncSender<T> {
7777
SyncSender {
7878
sender: self.sender.clone(),

src/sources/futures.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,7 @@ enum Active<T> {
103103

104104
impl<T> Active<T> {
105105
fn is_finished(&self) -> bool {
106-
match self {
107-
Active::Finished(_) => true,
108-
_ => false,
109-
}
106+
matches!(self, Active::Finished(_))
110107
}
111108
}
112109

src/sources/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,7 +412,7 @@ where
412412
pub struct Dispatcher<'a, S, Data>(Rc<dyn ErasedDispatcher<'a, S, Data> + 'a>);
413413

414414
impl<'a, S, Data> std::fmt::Debug for Dispatcher<'a, S, Data> {
415-
#[cfg_attr(coverage, no_coverage)]
415+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
416416
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
417417
f.write_str("Dispatcher { ... }")
418418
}
@@ -485,7 +485,7 @@ pub struct Idle<'i> {
485485
}
486486

487487
impl<'i> std::fmt::Debug for Idle<'i> {
488-
#[cfg_attr(coverage, no_coverage)]
488+
#[cfg_attr(feature = "nightly_coverage", no_coverage)]
489489
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
490490
f.write_str("Idle { ... }")
491491
}

0 commit comments

Comments
 (0)