Skip to content

Commit 68f89ee

Browse files
committed
style: Update for new lints
1 parent 5dec389 commit 68f89ee

File tree

8 files changed

+28
-18
lines changed

8 files changed

+28
-18
lines changed

build.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fn main() {
1111
let out = path::PathBuf::from(env::var_os("OUT_DIR").expect("run within cargo"))
1212
.join("current_target.txt");
1313
let default_target = env::var("TARGET").expect("run as cargo build script");
14-
let mut file = fs::File::create(out).unwrap();
15-
file.write_all(default_target.as_bytes()).unwrap();
14+
let mut file = fs::File::create(out).expect("can write to OUT_DIR");
15+
file.write_all(default_target.as_bytes())
16+
.expect("can write to OUT_DIR");
1617
}

examples/example_fixture.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::exit)]
2+
13
use std::env;
24
use std::error::Error;
35
use std::io;

examples/failure.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[allow(clippy::wildcard_imports)] // false positive
12
use assert_cmd::prelude::*;
23

34
use std::process::Command;

src/assert.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ where
547547
}
548548

549549
/// Keep `predicates` concrete Predicates out of our public API.
550-
/// [predicates_core::Predicate] used by [`IntoCodePredicate`] for code.
550+
/// [`predicates_core::Predicate`] used by [`IntoCodePredicate`] for code.
551551
///
552552
/// # Example
553553
///
@@ -616,7 +616,7 @@ impl IntoCodePredicate<EqCodePredicate> for i32 {
616616
}
617617

618618
/// Keep `predicates` concrete Predicates out of our public API.
619-
/// [predicates_core::Predicate] used by [`IntoCodePredicate`] for iterables of codes.
619+
/// [`predicates_core::Predicate`] used by [`IntoCodePredicate`] for iterables of codes.
620620
///
621621
/// # Example
622622
///
@@ -741,7 +741,7 @@ where
741741
}
742742

743743
/// Keep `predicates` concrete Predicates out of our public API.
744-
/// [predicates_core::Predicate] used by [`IntoOutputPredicate`] for bytes.
744+
/// [`predicates_core::Predicate`] used by [`IntoOutputPredicate`] for bytes.
745745
///
746746
/// # Example
747747
///
@@ -781,7 +781,7 @@ impl predicates_core::Predicate<[u8]> for BytesContentOutputPredicate {
781781
&self,
782782
expected: bool,
783783
variable: &[u8],
784-
) -> Option<predicates_core::reflection::Case> {
784+
) -> Option<predicates_core::reflection::Case<'_>> {
785785
let actual = self.eval(variable);
786786
if expected == actual {
787787
Some(predicates_core::reflection::Case::new(Some(self), actual))
@@ -814,7 +814,7 @@ impl IntoOutputPredicate<BytesContentOutputPredicate> for &'static [u8] {
814814
}
815815

816816
/// Keep `predicates` concrete Predicates out of our public API.
817-
/// [predicates_core::Predicate] used by [`IntoOutputPredicate`] for [`str`].
817+
/// [`predicates_core::Predicate`] used by [`IntoOutputPredicate`] for [`str`].
818818
///
819819
/// # Example
820820
///
@@ -901,7 +901,7 @@ impl IntoOutputPredicate<StrContentOutputPredicate> for &'static str {
901901
}
902902

903903
// Keep `predicates` concrete Predicates out of our public API.
904-
/// [predicates_core::Predicate] used by [`IntoOutputPredicate`] for
904+
/// [`predicates_core::Predicate`] used by [`IntoOutputPredicate`] for
905905
/// [`Predicate<str>`][predicates_core::Predicate].
906906
///
907907
/// # Example
@@ -1123,7 +1123,7 @@ mod test {
11231123
fn convert_code<I, P>(pred: I) -> P
11241124
where
11251125
I: IntoCodePredicate<P>,
1126-
P: predicates_core::Predicate<i32>,
1126+
P: Predicate<i32>,
11271127
{
11281128
pred.into_code()
11291129
}
@@ -1157,7 +1157,7 @@ mod test {
11571157
fn convert_output<I, P>(pred: I) -> P
11581158
where
11591159
I: IntoOutputPredicate<P>,
1160-
P: predicates_core::Predicate<[u8]>,
1160+
P: Predicate<[u8]>,
11611161
{
11621162
pred.into_output()
11631163
}

src/bin/bin_fixture.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::exit)]
2+
13
use std::env;
24
use std::error::Error;
35
use std::io;

src/cargo.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ fn target_dir() -> path::PathBuf {
213213
}
214214
path
215215
})
216-
.unwrap()
216+
.expect("this should only be used where a `current_exe` can be set")
217217
}
218218

219219
/// Look up the path to a cargo-built binary within an integration test.

src/cmd.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -444,12 +444,8 @@ impl Command {
444444
input: Option<Vec<u8>>,
445445
timeout: Option<std::time::Duration>,
446446
) -> io::Result<process::Output> {
447-
let stdin = input.and_then(|i| {
448-
child
449-
.stdin
450-
.take()
451-
.map(|mut stdin| std::thread::spawn(move || stdin.write_all(&i)))
452-
});
447+
#![allow(clippy::unwrap_used)] // changes behavior in some tests
448+
453449
fn read<R>(mut input: R) -> std::thread::JoinHandle<io::Result<Vec<u8>>>
454450
where
455451
R: Read + Send + 'static,
@@ -459,6 +455,13 @@ impl Command {
459455
input.read_to_end(&mut ret).map(|_| ret)
460456
})
461457
}
458+
459+
let stdin = input.and_then(|i| {
460+
child
461+
.stdin
462+
.take()
463+
.map(|mut stdin| std::thread::spawn(move || stdin.write_all(&i)))
464+
});
462465
let stdout = child.stdout.take().map(read);
463466
let stderr = child.stderr.take().map(read);
464467

src/output.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,13 @@ fn format_bytes(data: &[u8], f: &mut impl fmt::Write) -> fmt::Result {
350350
const LINES_MAX_START: usize = 20;
351351
const LINES_MAX_END: usize = 40;
352352
const LINES_MAX_PRINTED: usize = LINES_MAX_START + LINES_MAX_END;
353-
assert!(LINES_MAX_PRINTED < LINES_MIN_OVERFLOW);
354353

355354
const BYTES_MIN_OVERFLOW: usize = 8192;
356355
const BYTES_MAX_START: usize = 2048;
357356
const BYTES_MAX_END: usize = 2048;
358357
const BYTES_MAX_PRINTED: usize = BYTES_MAX_START + BYTES_MAX_END;
358+
359+
assert!(LINES_MAX_PRINTED < LINES_MIN_OVERFLOW);
359360
assert!(BYTES_MAX_PRINTED < BYTES_MIN_OVERFLOW);
360361

361362
let lines_total = data.as_bstr().lines_with_terminator().count();

0 commit comments

Comments
 (0)