Skip to content

Commit 3824515

Browse files
authored
chore: address warnings on windows targets (#663)
1 parent 3656519 commit 3824515

8 files changed

Lines changed: 28 additions & 9 deletions

File tree

.vscode/settings.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,8 @@
1313
"rewrap.wrappingColumn": 90,
1414
"rust-analyzer.debug.openDebugPane": true,
1515
"rust-analyzer.testExplorer": true,
16-
"rust-analyzer.check.features": "all"
16+
"rust-analyzer.check.features": "all",
17+
"rust-analyzer.check.allTargets": true,
18+
"rust-analyzer.check.workspace": true,
19+
"sarif-viewer.connectToGithubCodeScanning": "on",
1720
}

brush-core/benches/shell.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,4 @@ criterion::criterion_group! {
160160
criterion::criterion_main!(benches);
161161

162162
#[cfg(not(unix))]
163-
fn main() -> () {}
163+
fn main() {}

brush-core/src/processes.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ impl ChildProcess {
3434
#[allow(unused_mut, reason = "only mutated on some platforms")]
3535
let mut sigchld = sys::signal::chld_signal_listener()?;
3636

37+
#[allow(clippy::ignored_unit_patterns)]
3738
loop {
3839
tokio::select! {
3940
output = &mut self.exec_future => {

brush-core/src/sys/stubs.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
#![allow(dead_code)]
2+
#![allow(clippy::missing_const_for_fn)]
3+
#![allow(clippy::needless_pass_by_ref_mut)]
24
#![allow(clippy::needless_pass_by_value)]
5+
#![allow(clippy::unnecessary_wraps)]
36
#![allow(clippy::unused_async)]
47
#![allow(clippy::unused_self)]
5-
#![allow(clippy::unnecessary_wraps)]
68

79
pub(crate) mod fs;
810
pub(crate) mod input;

brush-core/src/sys/stubs/pipes.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ pub(crate) struct PipeReader {}
44

55
impl PipeReader {
66
/// Tries to clone the reader.
7-
pub fn try_clone(&self) -> std::io::Result<PipeReader> {
7+
pub fn try_clone(&self) -> std::io::Result<Self> {
88
Ok((*self).clone())
99
}
1010
}
1111

1212
impl From<PipeReader> for std::process::Stdio {
1313
fn from(_reader: PipeReader) -> Self {
14-
std::process::Stdio::null()
14+
Self::null()
1515
}
1616
}
1717

@@ -28,14 +28,14 @@ pub(crate) struct PipeWriter {}
2828

2929
impl PipeWriter {
3030
/// Tries to clone the writer.
31-
pub fn try_clone(&self) -> std::io::Result<PipeWriter> {
31+
pub fn try_clone(&self) -> std::io::Result<Self> {
3232
Ok((*self).clone())
3333
}
3434
}
3535

3636
impl From<PipeWriter> for std::process::Stdio {
3737
fn from(_writer: PipeWriter) -> Self {
38-
std::process::Stdio::null()
38+
Self::null()
3939
}
4040
}
4141

brush-core/src/sys/windows/users.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![allow(clippy::missing_const_for_fn)]
2+
13
use crate::error;
24
use std::path::PathBuf;
35

@@ -31,6 +33,7 @@ pub(crate) fn get_current_username() -> Result<String, error::Error> {
3133
Ok(username)
3234
}
3335

36+
#[allow(clippy::unnecessary_wraps)]
3437
pub(crate) fn get_user_group_ids() -> Result<Vec<u32>, error::Error> {
3538
// TODO: implement some version of this for Windows
3639
Ok(vec![])

brush-parser/benches/parser.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,4 +76,4 @@ criterion::criterion_group! {
7676
criterion::criterion_main!(benches);
7777

7878
#[cfg(not(unix))]
79-
fn main() -> () {}
79+
fn main() {}

brush-shell/tests/compat_tests.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
// Only compile this for Unix-like platforms (Linux, macOS) because they have an oracle to compare
44
// against.
5-
#![cfg(unix)]
5+
#![cfg(any(unix, windows))]
66

77
use anyhow::{Context, Result};
88
use assert_fs::fixture::{FileWriteStr, PathChild};
@@ -11,6 +11,7 @@ use colored::Colorize;
1111
use descape::UnescapeExt;
1212
use serde::{Deserialize, Serialize};
1313
use std::fs;
14+
#[cfg(unix)]
1415
use std::os::unix::{fs::PermissionsExt, process::ExitStatusExt};
1516
use std::{
1617
collections::{HashMap, HashSet},
@@ -932,6 +933,7 @@ impl TestCase {
932933
test_file_path.write_str(test_file.contents.as_str())?;
933934
}
934935

936+
#[cfg(unix)]
935937
if test_file.executable {
936938
// chmod u+x
937939
let mut perms = test_file_path.metadata()?.permissions();
@@ -1094,6 +1096,13 @@ impl TestCase {
10941096
}
10951097

10961098
#[expect(clippy::unused_async)]
1099+
#[cfg(not(unix))]
1100+
async fn run_command_with_pty(&self, _cmd: std::process::Command) -> Result<RunResult> {
1101+
Err(anyhow::anyhow!("pty test not supported on this platform"))
1102+
}
1103+
1104+
#[expect(clippy::unused_async)]
1105+
#[cfg(unix)]
10971106
async fn run_command_with_pty(&self, cmd: std::process::Command) -> Result<RunResult> {
10981107
use expectrl::Expect;
10991108

@@ -1553,6 +1562,7 @@ impl TestOptions {
15531562
}
15541563
}
15551564

1565+
#[cfg(unix)]
15561566
fn read_expectrl_log(log: Vec<u8>) -> Result<String> {
15571567
let output_str = String::from_utf8(log)?;
15581568
let output: String = output_str

0 commit comments

Comments
 (0)