Skip to content

Commit e7e620b

Browse files
authored
Merge pull request #138 from CertainLach/stable-async-traits
build: use now-stable async traits
2 parents fd582d4 + 69bb25d commit e7e620b

File tree

7 files changed

+35
-46
lines changed

7 files changed

+35
-46
lines changed

.github/workflows/clippy_check.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
- uses: actions/checkout@v2
88
- uses: actions-rs/toolchain@v1
99
with:
10-
toolchain: nightly
10+
toolchain: nightly-2023-10-28
1111
components: clippy
1212
override: true
1313
- uses: actions-rs/clippy-check@v1

Cargo.lock

Lines changed: 6 additions & 27 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ static_assertions = "1.1"
3535
rustc-hash = "1.1"
3636
bincode = "1.3"
3737
annotate-snippets = "0.9.1"
38-
async-trait = "0.1.60"
3938
num-bigint = "0.4.3"
4039
derivative = "2.2.0"
4140
strsim = "0.10.0"
@@ -45,7 +44,7 @@ quote = "1.0"
4544
syn = "2.0"
4645
peg = "0.8.2"
4746
drop_bomb = "0.1.5"
48-
logos = "0.13.0"
47+
logos = "0.12.0"
4948
miette = "5.5.0"
5049
rowan = "0.15"
5150
text-size = "1.1"

crates/jrsonnet-evaluator/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ explaining-traces = ["annotate-snippets"]
1414
# Allows library authors to throw custom errors
1515
anyhow-error = ["anyhow"]
1616
# Adds ability to build import closure in async
17-
async-import = ["async-trait"]
17+
async-import = []
1818

1919
# Allows to preserve field order in objects
2020
exp-preserve-order = []
@@ -54,8 +54,6 @@ anyhow = { workspace = true, optional = true }
5454
bincode = { workspace = true, optional = true }
5555
# Explaining traces
5656
annotate-snippets = { workspace = true, features = ["color"], optional = true }
57-
# Async imports
58-
async-trait = { workspace = true, optional = true }
5957
# Bigint
6058
num-bigint = { workspace = true, features = ["serde"], optional = true }
6159
derivative.workspace = true

crates/jrsonnet-evaluator/src/async_import.rs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
use std::{cell::RefCell, path::Path};
1+
use std::{cell::RefCell, future::Future, path::Path};
22

3-
use async_trait::async_trait;
43
use jrsonnet_gcmodule::Trace;
54
use jrsonnet_interner::IStr;
65
use jrsonnet_parser::{
@@ -218,26 +217,37 @@ pub fn find_imports(expr: &LocExpr, out: &mut FoundImports) {
218217
}
219218
}
220219

221-
#[async_trait(?Send)]
222220
pub trait AsyncImportResolver {
223221
type Error;
224222
/// Resolves file path, e.g. `(/home/user/manifests, b.libjsonnet)` can correspond
225223
/// both to `/home/user/manifests/b.libjsonnet` and to `/home/user/${vendor}/b.libjsonnet`
226224
/// where `${vendor}` is a library path.
227225
///
228-
/// `from` should only be returned from [`ImportResolver::resolve`], or from other defined file, any other value
229-
/// may result in panic
230-
async fn resolve_from(&self, from: &SourcePath, path: &str) -> Result<SourcePath, Self::Error>;
231-
async fn resolve_from_default(&self, path: &str) -> Result<SourcePath, Self::Error> {
232-
self.resolve_from(&SourcePath::default(), path).await
226+
/// `from` should only be returned from [`ImportResolver::resolve`],
227+
/// or from other defined file, any other value may result in panic
228+
fn resolve_from(
229+
&self,
230+
from: &SourcePath,
231+
path: &str,
232+
) -> impl Future<Output = Result<SourcePath, Self::Error>>;
233+
fn resolve_from_default(
234+
&self,
235+
path: &str,
236+
) -> impl Future<Output = Result<SourcePath, Self::Error>> {
237+
async { self.resolve_from(&SourcePath::default(), path).await }
233238
}
234239
/// Resolves absolute path, doesn't supports jpath and other fancy things
235-
async fn resolve(&self, path: &Path) -> Result<SourcePath, Self::Error>;
240+
fn resolve(&self, path: &Path) -> impl Future<Output = Result<SourcePath, Self::Error>>;
236241

237242
/// Load resolved file
238-
/// This should only be called with value returned from [`ImportResolver::resolve_file`]/[`ImportResolver::resolve`],
239-
/// this cannot be resolved using associated type, as evaluator uses object instead of generic for [`ImportResolver`]
240-
async fn load_file_contents(&self, resolved: &SourcePath) -> Result<Vec<u8>, Self::Error>;
243+
/// This should only be called with value returned
244+
/// from [`ImportResolver::resolve_file`]/[`ImportResolver::resolve`],
245+
/// this cannot be resolved using associated type,
246+
/// as the evaluator uses object instead of generic for [`ImportResolver`]
247+
fn load_file_contents(
248+
&self,
249+
resolved: &SourcePath,
250+
) -> impl Future<Output = Result<Vec<u8>, Self::Error>>;
241251
}
242252

243253
#[derive(Trace)]

flake.nix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
lib = pkgs.lib;
2626
rust =
2727
(pkgs.rustChannelOf {
28-
date = "2023-08-02";
28+
date = "2023-10-28";
2929
channel = "nightly";
3030
})
3131
.default

rust-toolchain.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[toolchain]
2+
channel = "nightly-2023-10-28"
3+
components = ["rustfmt", "clippy"]

0 commit comments

Comments
 (0)