Skip to content

Commit

Permalink
feat: set + validate intentional MSRV (1.72.0) (#86)
Browse files Browse the repository at this point in the history
Picking 1.72.0 for now; this required removing usage of a few
convenience functions that haven't been around too long, fixing a few
minor compilation errors, and downgrading `clap`. When we're ready to
move the MSRV higher, we can revert these changes.
  • Loading branch information
reubeno authored Jun 18, 2024
2 parents c3257be + a8ba798 commit 7d0a93a
Show file tree
Hide file tree
Showing 10 changed files with 69 additions and 40 deletions.
12 changes: 10 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,21 @@ jobs:
check:
name: "Source code checks"
runs-on: ubuntu-latest

strategy:
matrix:
# Test latest stable as well as MSRV.
rust-version: ["stable", "1.72.0"]

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up rust toolchain
- name: Set up rust toolchain (${{ matrix.rust-version }})
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
toolchain: ${{ matrix.rust-version }}
components: clippy, rustfmt

- name: Enable cargo cache
uses: Swatinem/rust-cache@v2
Expand All @@ -200,6 +207,7 @@ jobs:
cargo deny check
- name: Clippy check
if: matrix.rust-version == 'stable'
run: cargo clippy --all-targets

benchmark:
Expand Down
34 changes: 20 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ keywords = ["cli", "shell", "sh", "bash", "script"]
license = "MIT"
readme = "README.md"
repository = "https://github.com/reubeno/brush"
rust-version = "1.72.0"

[workspace.lints.clippy]
all = { level = "deny", priority = -1 }
Expand Down
4 changes: 3 additions & 1 deletion brush-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ keywords.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
rust-version.workspace = true

[lib]
bench = false
Expand All @@ -20,7 +21,8 @@ async-recursion = "1.1.0"
async-trait = "0.1.80"
brush-parser = { version = "0.1.0", path = "../brush-parser" }
cached = "0.51.3"
clap = { version = "4.5.4", features = ["derive", "wrap_help"] }
# N.B. Pin to 4.4.18 for now to keep to 1.72.0 as MSRV; 4.5.x requires a later version.
clap = { version = "=4.4.18", features = ["derive", "wrap_help"] }
fancy-regex = "0.13.0"
futures = "0.3.30"
hostname = "0.4.0"
Expand Down
18 changes: 9 additions & 9 deletions brush-core/src/builtins/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ mod unimp;
mod unset;
mod wait;

fn builtin<B: builtin::Command + Send>() -> builtin::Registration {
fn builtin<B: builtin::Command + Send + Sync>() -> builtin::Registration {
builtin::Registration {
execute_func: exec_builtin::<B>,
content_func: get_builtin_content::<B>,
Expand All @@ -62,7 +62,7 @@ fn builtin<B: builtin::Command + Send>() -> builtin::Registration {
}
}

fn special_builtin<B: builtin::Command + Send>() -> builtin::Registration {
fn special_builtin<B: builtin::Command + Send + Sync>() -> builtin::Registration {
builtin::Registration {
execute_func: exec_builtin::<B>,
content_func: get_builtin_content::<B>,
Expand All @@ -72,7 +72,7 @@ fn special_builtin<B: builtin::Command + Send>() -> builtin::Registration {
}
}

fn decl_builtin<B: builtin::DeclarationCommand + Send>() -> builtin::Registration {
fn decl_builtin<B: builtin::DeclarationCommand + Send + Sync>() -> builtin::Registration {
builtin::Registration {
execute_func: exec_declaration_builtin::<B>,
content_func: get_builtin_content::<B>,
Expand All @@ -82,7 +82,7 @@ fn decl_builtin<B: builtin::DeclarationCommand + Send>() -> builtin::Registratio
}
}

fn special_decl_builtin<B: builtin::DeclarationCommand + Send>() -> builtin::Registration {
fn special_decl_builtin<B: builtin::DeclarationCommand + Send + Sync>() -> builtin::Registration {
builtin::Registration {
execute_func: exec_declaration_builtin::<B>,
content_func: get_builtin_content::<B>,
Expand All @@ -92,21 +92,21 @@ fn special_decl_builtin<B: builtin::DeclarationCommand + Send>() -> builtin::Reg
}
}

fn get_builtin_content<T: builtin::Command + Send>(
fn get_builtin_content<T: builtin::Command + Send + Sync>(
name: &str,
content_type: builtin::ContentType,
) -> Result<String, error::Error> {
T::get_content(name, content_type)
}

fn exec_builtin<T: builtin::Command + Send>(
fn exec_builtin<T: builtin::Command + Send + Sync>(
context: commands::ExecutionContext<'_>,
args: Vec<CommandArg>,
) -> BoxFuture<'_, Result<builtin::BuiltinResult, error::Error>> {
Box::pin(async move { exec_builtin_impl::<T>(context, args).await })
}

async fn exec_builtin_impl<T: builtin::Command + Send>(
async fn exec_builtin_impl<T: builtin::Command + Send + Sync>(
context: commands::ExecutionContext<'_>,
args: Vec<CommandArg>,
) -> Result<builtin::BuiltinResult, error::Error> {
Expand All @@ -131,14 +131,14 @@ async fn exec_builtin_impl<T: builtin::Command + Send>(
})
}

fn exec_declaration_builtin<T: builtin::DeclarationCommand + Send>(
fn exec_declaration_builtin<T: builtin::DeclarationCommand + Send + Sync>(
context: commands::ExecutionContext<'_>,
args: Vec<CommandArg>,
) -> BoxFuture<'_, Result<builtin::BuiltinResult, error::Error>> {
Box::pin(async move { exec_declaration_builtin_impl::<T>(context, args).await })
}

async fn exec_declaration_builtin_impl<T: builtin::DeclarationCommand + Send>(
async fn exec_declaration_builtin_impl<T: builtin::DeclarationCommand + Send + Sync>(
context: commands::ExecutionContext<'_>,
args: Vec<CommandArg>,
) -> Result<builtin::BuiltinResult, error::Error> {
Expand Down
27 changes: 16 additions & 11 deletions brush-core/src/openfiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,16 +138,19 @@ impl std::io::Read for OpenFile {
fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> {
match self {
OpenFile::Stdin => std::io::stdin().read(buf),
OpenFile::Stdout => Err(std::io::Error::other(error::Error::OpenFileNotReadable(
"stdout",
))),
OpenFile::Stderr => Err(std::io::Error::other(error::Error::OpenFileNotReadable(
"stderr",
))),
OpenFile::Stdout => Err(std::io::Error::new(
std::io::ErrorKind::Other,
error::Error::OpenFileNotReadable("stdout"),
)),
OpenFile::Stderr => Err(std::io::Error::new(
std::io::ErrorKind::Other,
error::Error::OpenFileNotReadable("stderr"),
)),
OpenFile::Null => Ok(0),
OpenFile::File(f) => f.read(buf),
OpenFile::PipeReader(reader) => reader.read(buf),
OpenFile::PipeWriter(_) => Err(std::io::Error::other(
OpenFile::PipeWriter(_) => Err(std::io::Error::new(
std::io::ErrorKind::Other,
error::Error::OpenFileNotReadable("pipe writer"),
)),
}
Expand All @@ -157,14 +160,16 @@ impl std::io::Read for OpenFile {
impl std::io::Write for OpenFile {
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
match self {
OpenFile::Stdin => Err(std::io::Error::other(error::Error::OpenFileNotWritable(
"stdin",
))),
OpenFile::Stdin => Err(std::io::Error::new(
std::io::ErrorKind::Other,
error::Error::OpenFileNotWritable("stdin"),
)),
OpenFile::Stdout => std::io::stdout().write(buf),
OpenFile::Stderr => std::io::stderr().write(buf),
OpenFile::Null => Ok(buf.len()),
OpenFile::File(f) => f.write(buf),
OpenFile::PipeReader(_) => Err(std::io::Error::other(
OpenFile::PipeReader(_) => Err(std::io::Error::new(
std::io::ErrorKind::Other,
error::Error::OpenFileNotWritable("pipe reader"),
)),
OpenFile::PipeWriter(writer) => writer.write(buf),
Expand Down
1 change: 1 addition & 0 deletions brush-interactive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ keywords.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
rust-version.workspace = true

[lib]
bench = false
Expand Down
1 change: 1 addition & 0 deletions brush-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ keywords.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
rust-version.workspace = true

[lib]
bench = false
Expand Down
7 changes: 5 additions & 2 deletions brush-shell/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ keywords.workspace = true
license.workspace = true
readme.workspace = true
repository.workspace = true
rust-version.workspace = true

[[bin]]
name = "brush"
Expand All @@ -27,14 +28,16 @@ workspace = true
brush-interactive = { version = "0.1.0", path = "../brush-interactive" }
brush-parser = { version = "0.1.0", path = "../brush-parser" }
brush-core = { version = "0.1.0", path = "../brush-core" }
clap = { version = "4.5.4", features = ["derive", "wrap_help"] }
# N.B. Pin to 4.4.18 for now to keep to 1.72.0 as MSRV; 4.5.x requires a later version.
clap = { version = "=4.4.18", features = ["derive", "wrap_help"] }
tokio = { version = "1.37.0", features = ["rt", "rt-multi-thread"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"

[dev-dependencies]
anyhow = "1.0.86"
assert_cmd = "2.0.14"
# N.B. Pin to 2.0.13 for now to keep to 1.72.0 as MSRV; 2.0.14 requires a later version.
assert_cmd = "=2.0.13"
assert_fs = "1.1.1"
colored = "2.1.0"
descape = "1.1.2"
Expand Down
4 changes: 3 additions & 1 deletion deny.toml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,9 @@ deny = []
#exact = true

# Certain crates/versions that will be skipped when doing duplicate detection.
skip = []
skip = [
{ crate = "strsim", reason = "conflict between old version of clap and cached" }
]
skip-tree = [
{ crate = "windows-sys", reason = "several crates use outdated versions" },
{ crate = "nix", reason = "there are multiple versions floating" },
Expand Down

0 comments on commit 7d0a93a

Please sign in to comment.