Skip to content

Commit 0222469

Browse files
bors[bot]Marwes
andauthored
Merge #852
852: feat: Remove or make dependencies optional r=Marwes a=Marwes Co-authored-by: Markus Westerlind <[email protected]>
2 parents dbd8310 + 33a3aa4 commit 0222469

File tree

15 files changed

+195
-153
lines changed

15 files changed

+195
-153
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,17 @@ quick-error = "1.0.0"
3939
collect-mac = "0.1.0"
4040
either = "1.0.0"
4141
itertools = "0.9"
42-
futures = { version = "0.3.1", features = ["thread-pool"] }
42+
futures = { version = "0.3.1", default-features = false }
4343
codespan = "0.9"
4444
codespan-reporting = "0.9"
45-
pin-project = "0.4"
45+
pin-project-lite = { version = "0.1", optional = true }
4646
salsa = { version = "0.14.0", package = "gluon-salsa" }
4747

4848
serde = { version = "1.0.0", optional = true }
4949
serde_state = { version = "0.4", optional = true }
5050
serde_derive_state = { version = "0.4.7", optional = true }
5151

52-
tokio = { version = "0.2", features = ["stream", "sync", "rt-core"] }
52+
tokio = { version = "0.2", features = ["stream", "sync", "rt-core"], optional = true }
5353

5454
# Binding crates
5555
regex = { version = "1", optional = true }
@@ -58,7 +58,7 @@ tower-service = { version = "0.3", optional = true }
5858
http = { version = "0.2", optional = true }
5959
hyper = { version = "0.13", optional = true, features = ["stream"] }
6060
native-tls = { version = "0.2", optional = true }
61-
tokio-tls = { version = "0.3", optional = true }
61+
tokio-native-tls = { version = "0.1", optional = true }
6262

6363
# Crates used in testing
6464
compiletest_rs = { version = "0.5", optional = true }
@@ -78,8 +78,8 @@ walkdir = "2"
7878
criterion = "0.3"
7979
collect-mac = "0.1.0"
8080
env_logger = "0.7"
81-
failure = "0.1"
82-
failure_derive = "0.1"
81+
anyhow = "1"
82+
thiserror = "1"
8383
insta = "0.16"
8484
pretty_assertions = "0.6"
8585
structopt = "0.3"
@@ -100,10 +100,11 @@ gluon_completion = { path = "completion", version = "0.15.1" } # GLUON
100100
gluon_codegen = { path = "codegen", version = "0.15.1" } # GLUON
101101

102102
[features]
103-
default = ["regex", "random"]
103+
default = ["async", "regex", "random"]
104+
async = ["tokio"]
104105
random = ["rand", "rand_xorshift"]
105106
serialization = ["serde", "serde_state", "serde_derive_state", "gluon_vm/serialization"]
106-
web = ["hyper", "http", "tower-service", "native-tls", "tokio/net", "tokio-tls"]
107+
web = ["async", "hyper", "http", "tower-service", "native-tls", "tokio/net", "tokio-native-tls", "pin-project-lite"]
107108

108109
docs_rs = ["serialization"]
109110

base/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fnv = "1.0.3"
2424
pretty = "0.10"
2525
smallvec = "0.6"
2626
collect-mac = "0.1.0"
27-
anymap = "0.12.0"
27+
anymap = { version = "0.12.0", optional = true }
2828
itertools = "0.9"
2929
ordered-float = "1"
3030
codespan = "0.9"
@@ -48,5 +48,5 @@ env_logger = "0.7"
4848
pretty_assertions = "0.6"
4949

5050
[features]
51-
serialization = ["serde", "serde_state", "serde_derive", "serde_derive_state"]
51+
serialization = ["serde", "serde_state", "serde_derive", "serde_derive_state", "anymap"]
5252
nightly = ["compiletest_rs"]

base/src/serialization.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
extern crate anymap;
2-
31
use std::any::Any;
42
use std::cell::RefCell;
53
use std::collections::HashMap;

doc/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ documentation = "https://docs.rs/gluon"
1414
[dependencies]
1515
clap = "2.22.0"
1616
env_logger = "0.7"
17-
failure = "0.1"
17+
anyhow = "1"
1818
futures = "0.3"
1919
handlebars = "2"
2020
itertools = "0.9"

doc/src/lib.rs

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use std::{
1717
};
1818

1919
use {
20-
failure::ResultExt,
20+
anyhow::{anyhow, Context as _},
2121
handlebars::{Context, Handlebars, Helper, Output, RenderContext, RenderError},
2222
itertools::Itertools,
2323
pretty::{Arena, DocAllocator},
@@ -39,7 +39,7 @@ use gluon::{
3939
Thread, ThreadExt,
4040
};
4141

42-
pub type Error = failure::Error;
42+
pub type Error = anyhow::Error;
4343
pub type Result<T> = ::std::result::Result<T, Error>;
4444

4545
#[derive(Serialize, PartialEq, Debug, Default)]
@@ -482,7 +482,7 @@ where
482482
trace!("DOC: {:?}", module);
483483

484484
reg.render_to_write(MODULE_TEMPLATE, &module, out)
485-
.with_context(|err| format!("Unable to render {}: {}", module.name, err))?;
485+
.with_context(|| format!("Unable to render {}", module.name))?;
486486
Ok(())
487487
}
488488

@@ -532,9 +532,8 @@ impl DocCollector<'_> {
532532

533533
debug!("Indexing module: {}", path.display());
534534

535-
let mut input = File::open(&*path).with_context(|err| {
536-
format!("Unable to open gluon file `{}`: {}", path.display(), err)
537-
})?;
535+
let mut input = File::open(&*path)
536+
.with_context(|| format!("Unable to open gluon file `{}`", path.display()))?;
538537

539538
content.clear();
540539
input.read_to_string(content)?;
@@ -545,7 +544,7 @@ impl DocCollector<'_> {
545544
let name = filename_to_module(
546545
module_path
547546
.to_str()
548-
.ok_or_else(|| failure::err_msg("Non-UTF-8 filename"))?,
547+
.ok_or_else(|| anyhow!("Non-UTF-8 filename"))?,
549548
);
550549

551550
let (expr, typ) = thread.typecheck_str(&name, &content, None)?;
@@ -652,13 +651,8 @@ pub fn generate(options: &Options, thread: &Thread) -> Result<()> {
652651
.try_for_each(|(modules, module)| -> Result<()> {
653652
let module_path = PathBuf::from(module.name.replace(".", "/"));
654653
let out_path = out_path.join(&module_path).with_extension("html");
655-
let mut doc_file = File::create(&*out_path).with_context(|err| {
656-
format!(
657-
"Unable to open output file `{}`: {}",
658-
out_path.display(),
659-
err
660-
)
661-
})?;
654+
let mut doc_file = File::create(&*out_path)
655+
.with_context(|| format!("Unable to open output file `{}`", out_path.display()))?;
662656

663657
generate_module(
664658
&reg,

doc/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
extern crate env_logger;
2-
extern crate failure;
32
extern crate opener;
43
extern crate rayon;
54
extern crate structopt;
@@ -17,7 +16,7 @@ fn main() {
1716
}
1817
}
1918

20-
fn main_() -> Result<(), failure::Error> {
19+
fn main_() -> Result<(), anyhow::Error> {
2120
env_logger::init();
2221

2322
let opt = gluon_doc::Opt::from_args();

examples/http/main.rs

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async fn main() {
2828
}
2929
}
3030

31-
async fn start(thread: &Thread, port: u16) -> Result<(), failure::Error> {
31+
async fn start(thread: &Thread, port: u16) -> Result<(), anyhow::Error> {
3232
let thread = thread.root_thread();
3333
// Last we run our `http_server.glu` module which returns a function which starts listening
3434
// on the port we passed from the command line
@@ -50,7 +50,7 @@ mod tests {
5050
use hyper::Client;
5151
use tokio::runtime::Runtime;
5252

53-
async fn wait_for_server(port: u16) -> Result<(), failure::Error> {
53+
async fn wait_for_server(port: u16) -> Result<(), anyhow::Error> {
5454
let mut err = None;
5555
for _ in 0..40 {
5656
match Client::new()
@@ -60,16 +60,14 @@ mod tests {
6060
Ok(response) => {
6161
return response
6262
.into_body()
63-
.try_fold(Vec::new(), |mut acc, buf| {
64-
async move {
65-
acc.extend_from_slice(&buf);
66-
Ok(acc)
67-
}
63+
.try_fold(Vec::new(), |mut acc, buf| async move {
64+
acc.extend_from_slice(&buf);
65+
Ok(acc)
6866
})
6967
.map_ok(|body| {
7068
assert_eq!(str::from_utf8(&body).unwrap(), "Hello World");
7169
})
72-
.err_into::<failure::Error>()
70+
.err_into::<anyhow::Error>()
7371
.await;
7472
}
7573
Err(e) => err = Some(e),
@@ -120,23 +118,21 @@ mod tests {
120118

121119
Client::new()
122120
.request(request)
123-
.err_into::<failure::Error>()
121+
.err_into::<anyhow::Error>()
124122
.and_then(|response| {
125123
response
126124
.into_body()
127-
.try_fold(Vec::new(), |mut acc, buf| {
128-
async move {
129-
acc.extend_from_slice(&buf);
130-
Ok(acc)
131-
}
125+
.try_fold(Vec::new(), |mut acc, buf| async move {
126+
acc.extend_from_slice(&buf);
127+
Ok(acc)
132128
})
133129
.map_ok(|body| {
134130
assert_eq!(str::from_utf8(&body).unwrap(), "test");
135131
})
136-
.err_into::<failure::Error>()
132+
.err_into::<anyhow::Error>()
137133
})
138134
.await
139135
})
140-
.unwrap_or_else(|err: failure::Error| panic!("{}", err));
136+
.unwrap_or_else(|err: anyhow::Error| panic!("{}", err));
141137
}
142138
}

repl/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ gluon_format = { version = "0.15.1", path = "../format" } # GLUON
2828
gluon_doc = { version = "0.15.1", path = "../doc" } # GLUON
2929

3030
app_dirs = "1.0.0"
31-
failure = "0.1"
31+
anyhow = "1"
3232
futures = "0.3"
3333
tokio = { version = "0.2", features = ["rt-threaded", "rt-core", "macros", "signal"] }
3434
clap = "2.22.0"

repl/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ quick_error! {
4242
#[derive(Debug)]
4343
#[allow(deprecated)]
4444
enum Error {
45-
Failure(err: failure::Error) {
45+
Failure(err: anyhow::Error) {
4646
display("{}", err)
4747
from()
4848
}

0 commit comments

Comments
 (0)