summaryrefslogtreecommitdiffstats
path: root/vendor/quick-error
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/quick-error')
-rw-r--r--vendor/quick-error/.cargo-checksum.json2
-rw-r--r--vendor/quick-error/Cargo.lock3
-rw-r--r--vendor/quick-error/Cargo.toml3
-rw-r--r--vendor/quick-error/README.rst6
-rw-r--r--vendor/quick-error/examples/context.rs21
-rw-r--r--vendor/quick-error/src/lib.rs292
-rw-r--r--vendor/quick-error/vagga.yaml6
7 files changed, 132 insertions, 201 deletions
diff --git a/vendor/quick-error/.cargo-checksum.json b/vendor/quick-error/.cargo-checksum.json
index 869218ba2..5f19af61c 100644
--- a/vendor/quick-error/.cargo-checksum.json
+++ b/vendor/quick-error/.cargo-checksum.json
@@ -1 +1 @@
-{"files":{"Cargo.lock":"d586689373f57572b86215aba1457e8486665e3a598e00b8f3f352b129e8aab5","Cargo.toml":"65148316f0d5161bbc86cd08f3feedf44936284c0665603baacf503d933a256e","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"058f01fe181608d027fcde7e528fc03ea3cf90f30903c407644b0a9bbc54f500","README.rst":"97f715a3a68ede33bca81c98ad791375b2bb7ad0d814377b0651f5c4de8f7d4a","bulk.yaml":"17c2548388e0cd3a63473021a2f1e4ddedee082d79d9167cb31ad06a1890d3fc","examples/context.rs":"5045319e03fa5214c7b2f9ef28d6012ffd34f7095d2103b5579a4c8567ddab68","src/lib.rs":"c94106502d7afb9ffb18b57ba9b42075b28017c765529e30db75a0e612152ec0","vagga.yaml":"280ac771f03284bb3f7e1b5b50c0b8046e79cc5c54f40b7c738f7a8ebaa586f2"},"package":"3ac73b1112776fc109b2e61909bc46c7e1bf0d7f690ffb1676553acce16d5cda"} \ No newline at end of file
+{"files":{"Cargo.lock":"b88df71c076815e9922973e1f54af221486c3a83d5be2c1af9ca650a8f8f526f","Cargo.toml":"1f24b567c7f10b4ec44f5baf033d27da39f659c09df0e8a057437d10ecdd551a","LICENSE-APACHE":"c6596eb7be8581c18be736c846fb9173b69eccf6ef94c5135893ec56bd92ba08","LICENSE-MIT":"058f01fe181608d027fcde7e528fc03ea3cf90f30903c407644b0a9bbc54f500","README.rst":"8bd690e0089d4c38eb71f1327f5144741009f4b2f49f0b16f2547f528171e2e6","bulk.yaml":"17c2548388e0cd3a63473021a2f1e4ddedee082d79d9167cb31ad06a1890d3fc","examples/context.rs":"b9be9a4ca021a1f0ba659932bfc0cf891728bfaea49d48a8be183644c492515b","src/lib.rs":"a02c8a3c40fa1dcee8285b9c238d40cb3078cf4dded1c972fa6361a485d1667f","vagga.yaml":"b01ad1fd3aa25de2439c0f7a437c6517808ba3a7eeeb0363eb209f08e326cc8e"},"package":"a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0"} \ No newline at end of file
diff --git a/vendor/quick-error/Cargo.lock b/vendor/quick-error/Cargo.lock
index 4e9e64eb5..da1963ecf 100644
--- a/vendor/quick-error/Cargo.lock
+++ b/vendor/quick-error/Cargo.lock
@@ -2,4 +2,5 @@
# It is not intended for manual editing.
[[package]]
name = "quick-error"
-version = "2.0.0"
+version = "1.2.3"
+
diff --git a/vendor/quick-error/Cargo.toml b/vendor/quick-error/Cargo.toml
index f5f929231..b5d5f60b1 100644
--- a/vendor/quick-error/Cargo.toml
+++ b/vendor/quick-error/Cargo.toml
@@ -11,9 +11,8 @@
# will likely look very different (and much more reasonable)
[package]
-edition = "2018"
name = "quick-error"
-version = "2.0.0"
+version = "1.2.3"
authors = ["Paul Colomiets <paul@colomiets.name>", "Colin Kiegel <kiegel@gmx.de>"]
description = " A macro which makes error types pleasant to write.\n"
homepage = "http://github.com/tailhook/quick-error"
diff --git a/vendor/quick-error/README.rst b/vendor/quick-error/README.rst
index 67773e8ab..e54c055c4 100644
--- a/vendor/quick-error/README.rst
+++ b/vendor/quick-error/README.rst
@@ -3,7 +3,7 @@ Quick Error
===========
:Status: production-ready
-:Documentation: https://docs.rs/quick-error/
+:Documentation: http://tailhook.github.io/quick-error/
A macro which makes error types pleasant to write.
@@ -25,13 +25,13 @@ Here is the comprehensive example:
Io(err: io::Error) {
from()
display("I/O error: {}", err)
- source(err)
+ cause(err)
}
Other(descr: &'static str) {
display("Error {}", descr)
}
IoAt { place: &'static str, err: io::Error } {
- source(err)
+ cause(err)
display(me) -> ("io error at {}: {}", place, err)
from(s: String) -> {
place: "some string",
diff --git a/vendor/quick-error/examples/context.rs b/vendor/quick-error/examples/context.rs
index 1d406613e..334700a03 100644
--- a/vendor/quick-error/examples/context.rs
+++ b/vendor/quick-error/examples/context.rs
@@ -1,14 +1,19 @@
-use quick_error::{quick_error, ResultExt};
-use std::env;
-use std::fs::File;
+#[macro_use(quick_error)] extern crate quick_error;
+
use std::io::{self, stderr, Read, Write};
+use std::fs::File;
+use std::env;
use std::num::ParseIntError;
use std::path::{Path, PathBuf};
+use quick_error::ResultExt;
+
quick_error! {
#[derive(Debug)]
pub enum Error {
- NoFileName {}
+ NoFileName {
+ description("no file name specified")
+ }
Io(err: io::Error, path: PathBuf) {
display("could not read file {:?}: {}", path, err)
context(path: &'a Path, err: io::Error)
@@ -23,12 +28,12 @@ quick_error! {
}
fn parse_file() -> Result<u64, Error> {
- let fname = env::args().skip(1).next().ok_or(Error::NoFileName)?;
+ let fname = try!(env::args().skip(1).next().ok_or(Error::NoFileName));
let fname = Path::new(&fname);
- let mut file = File::open(fname).context(fname)?;
+ let mut file = try!(File::open(fname).context(fname));
let mut buf = String::new();
- file.read_to_string(&mut buf).context(fname)?;
- Ok(buf.parse().context(fname)?)
+ try!(file.read_to_string(&mut buf).context(fname));
+ Ok(try!(buf.parse().context(fname)))
}
fn main() {
diff --git a/vendor/quick-error/src/lib.rs b/vendor/quick-error/src/lib.rs
index e5eb62e44..17fc455d4 100644
--- a/vendor/quick-error/src/lib.rs
+++ b/vendor/quick-error/src/lib.rs
@@ -45,7 +45,7 @@
//! Now you might have noticed trailing braces `{}`. They are used to define
//! implementations. By default:
//!
-//! * `Error::source()` returns None (even if type wraps some value)
+//! * `Error::cause()` returns None (even if type wraps some value)
//! * `Display` outputs debug representation
//! * No `From` implementations are defined
//!
@@ -66,7 +66,7 @@
//! }
//! ```
//!
-//! To change `source` method to return some error, add `source(value)`, for
+//! To change `cause` method to return some error, add `cause(value)`, for
//! example:
//!
//! ```rust
@@ -77,19 +77,19 @@
//! #[derive(Debug)]
//! pub enum SomeError {
//! Io(err: std::io::Error) {
-//! source(err)
+//! cause(err)
//! }
//! Utf8(err: std::str::Utf8Error) {
//! display("utf8 error")
//! }
//! Other(err: Box<std::error::Error>) {
-//! source(&**err)
+//! cause(&**err)
//! }
//! }
//! }
//! ```
//! Note you don't need to wrap value in `Some`, its implicit. In case you want
-//! `None` returned just omit the `source`. You can't return `None`
+//! `None` returned just omit the `cause`. You can't return `None`
//! conditionally.
//!
//! To change how each clause is `Display`ed add `display(pattern,..args)`,
@@ -220,12 +220,12 @@
//! }
//!
//! fn openfile(path: &Path) -> Result<(), Error> {
-//! File::open(path).context(path)?;
+//! try!(File::open(path).context(path));
//!
//! // If we didn't have context, the line above would be written as;
//! //
-//! // File::open(path)
-//! // .map_err(|err| Error::File(path.to_path_buf(), err))?;
+//! // try!(File::open(path)
+//! // .map_err(|err| Error::File(path.to_path_buf(), err)));
//!
//! Ok(())
//! }
@@ -248,7 +248,7 @@
//!
//! More info on context in [this article](http://bit.ly/1PsuxDt).
//!
-//! All forms of `from`, `display`, `source`, and `context`
+//! All forms of `from`, `display`, `cause`, and `context`
//! clauses can be combined and put in arbitrary order. Only `from` and
//! `context` can be used multiple times in single variant of enumeration.
//! Docstrings are also okay. Empty braces can be omitted as of quick_error
@@ -293,6 +293,7 @@
//!
//!
+
/// Main macro that does all the work
#[macro_export]
macro_rules! quick_error {
@@ -370,8 +371,9 @@ macro_rules! quick_error {
}
impl ::std::error::Error for $strname {
- fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
- self.0.source()
+ #[allow(deprecated)]
+ fn cause(&self) -> Option<&::std::error::Error> {
+ self.0.cause()
}
}
};
@@ -452,6 +454,8 @@ macro_rules! quick_error {
queue [ #[$qmeta:meta] $( $tail:tt )*]
) => {
quick_error!(SORT [$( $def )*]
+ enum [$( $(#[$emeta])* => $eitem $(( $($etyp),* ))* )*
+ $(#[$bmeta])* => $bitem: $bmode $(( $($btyp),* ))*]
items [$($( #[$imeta:meta] )*
=> $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*
$bitem: $bmode [$( $bvar:$btyp ),*] {} ]
@@ -468,7 +472,7 @@ macro_rules! quick_error {
) => {
quick_error!(SORT [$( $def )*]
items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*]
- buf [$( #[$bmeta] )* => $bitem: TUPLE [$( $qvar:$qtyp ),+] ]
+ buf [$( #[$bmeta] )* => $bitem: TUPLE [$( $qvar:$qtyp ),*] ]
queue [$( $tail )*]
);
};
@@ -482,7 +486,7 @@ macro_rules! quick_error {
) => {
quick_error!(SORT [$( $def )*]
items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*]
- buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),+] ]
+ buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),*] ]
queue [$( $tail )*]);
};
// Add struct enum-variant, with excess comma - e.g. { descr: &'static str, }
@@ -495,7 +499,7 @@ macro_rules! quick_error {
) => {
quick_error!(SORT [$( $def )*]
items [$( $(#[$imeta])* => $iitem: $imode [$( $ivar:$ityp ),*] {$( $ifuncs )*} )*]
- buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),+] ]
+ buf [$( #[$bmeta] )* => $bitem: STRUCT [$( $qvar:$qtyp ),*] ]
queue [$( $tail )*]);
};
// Add braces and flush always on braces
@@ -557,7 +561,7 @@ macro_rules! quick_error {
pub enum $name {
$(
$(#[$imeta])*
- $iitem $(($( $ttyp ),+))* $({$( $svar: $styp ),*})*,
+ $iitem $(($( $ttyp ),*))* $({$( $svar: $styp ),*})*,
)*
}
};
@@ -575,7 +579,7 @@ macro_rules! quick_error {
enum $name {
$(
$(#[$imeta])*
- $iitem $(($( $ttyp ),+))* $({$( $svar: $styp ),*})*,
+ $iitem $(($( $ttyp ),*))* $({$( $svar: $styp ),*})*,
)*
}
};
@@ -601,7 +605,7 @@ macro_rules! quick_error {
) => {
quick_error!(ENUM_DEFINITION [ $($def)* ]
body [$($( #[$imeta] )* => $iitem ($(($( $ttyp ),+))*) {$({$( $svar: $styp ),*})*} )*
- $( #[$qmeta] )* => $qitem (($( $qtyp ),+)) {} ]
+ $( #[$qmeta] )* => $qitem (($( $qtyp ),*)) {} ]
queue [ $($queue)* ]
);
};
@@ -654,14 +658,14 @@ macro_rules! quick_error {
#[allow(unused_doc_comment)]
#[allow(unused_doc_comments)]
impl ::std::error::Error for $name {
- fn source(&self) -> Option<&(dyn std::error::Error + 'static)> {
+ fn cause(&self) -> Option<&::std::error::Error> {
match *self {
$(
$(#[$imeta])*
quick_error!(ITEM_PATTERN
$name $item: $imode [$( ref $var ),*]
) => {
- quick_error!(FIND_SOURCE_IMPL
+ quick_error!(FIND_CAUSE_IMPL
$item: $imode [$( $var ),*]
{$( $funcs )*})
}
@@ -709,21 +713,33 @@ macro_rules! quick_error {
write!(f, "{:?}", self_)
}
};
- (FIND_SOURCE_IMPL $item:ident: $imode:tt
+ (FIND_DESCRIPTION_IMPL $item:ident: $imode:tt $me:ident $fmt:ident
+ [$( $var:ident ),*]
+ { description($expr:expr) $( $tail:tt )*}
+ ) => {};
+ (FIND_DESCRIPTION_IMPL $item:ident: $imode:tt $me:ident $fmt:ident
+ [$( $var:ident ),*]
+ { $t:tt $( $tail:tt )*}
+ ) => {};
+ (FIND_DESCRIPTION_IMPL $item:ident: $imode:tt $me:ident $fmt:ident
+ [$( $var:ident ),*]
+ { }
+ ) => {};
+ (FIND_CAUSE_IMPL $item:ident: $imode:tt
[$( $var:ident ),*]
- { source($expr:expr) $( $tail:tt )*}
+ { cause($expr:expr) $( $tail:tt )*}
) => {
Some($expr)
};
- (FIND_SOURCE_IMPL $item:ident: $imode:tt
+ (FIND_CAUSE_IMPL $item:ident: $imode:tt
[$( $var:ident ),*]
{ $t:tt $( $tail:tt )*}
) => {
- quick_error!(FIND_SOURCE_IMPL
+ quick_error!(FIND_CAUSE_IMPL
$item: $imode [$( $var ),*]
{ $($tail)* })
};
- (FIND_SOURCE_IMPL $item:ident: $imode:tt
+ (FIND_CAUSE_IMPL $item:ident: $imode:tt
[$( $var:ident ),*]
{ }
) => {
@@ -924,7 +940,9 @@ macro_rules! quick_error {
=> { quick_error!(ERROR_CHECK $imode $($tail)*); };
(ERROR_CHECK $imode:tt display($pattern: expr, $( $exprs:tt )*) $( $tail:tt )*)
=> { quick_error!(ERROR_CHECK $imode $($tail)*); };
- (ERROR_CHECK $imode:tt source($expr:expr) $($tail:tt)*)
+ (ERROR_CHECK $imode:tt description($expr:expr) $( $tail:tt )*)
+ => { quick_error!(ERROR_CHECK $imode $($tail)*); };
+ (ERROR_CHECK $imode:tt cause($expr:expr) $($tail:tt)*)
=> { quick_error!(ERROR_CHECK $imode $($tail)*); };
(ERROR_CHECK $imode:tt from() $($tail:tt)*)
=> { quick_error!(ERROR_CHECK $imode $($tail)*); };
@@ -947,6 +965,7 @@ macro_rules! quick_error {
(IDENT $ident:ident) => { $ident }
}
+
/// Generic context type
///
/// Used mostly as a transport for `ResultExt::context` method
@@ -970,13 +989,16 @@ impl<T, E> ResultExt<T, E> for Result<T, E> {
}
}
+
+
#[cfg(test)]
+#[allow(deprecated)]
mod test {
- use std::error::Error;
use std::num::{ParseFloatError, ParseIntError};
- use std::path::{Path, PathBuf};
use std::str::Utf8Error;
use std::string::FromUtf8Error;
+ use std::error::Error;
+ use std::path::{Path, PathBuf};
use super::ResultExt;
@@ -992,15 +1014,14 @@ mod test {
fn bare_item_direct() {
assert_eq!(format!("{}", Bare::One), "One".to_string());
assert_eq!(format!("{:?}", Bare::One), "One".to_string());
- assert!(Bare::One.source().is_none());
+ assert!(Bare::One.cause().is_none());
}
-
#[test]
fn bare_item_trait() {
- let err: &dyn Error = &Bare::Two;
+ let err: &Error = &Bare::Two;
assert_eq!(format!("{}", err), "Two".to_string());
assert_eq!(format!("{:?}", err), "Two".to_string());
- assert!(err.source().is_none());
+ assert!(err.cause().is_none());
}
quick_error! {
@@ -1016,18 +1037,13 @@ mod test {
#[test]
fn wrapper() {
- assert_eq!(
- format!("{}", Wrapper::from(Wrapped::One)),
- "One".to_string()
- );
- assert_eq!(
- format!("{}", Wrapper::from(Wrapped::from(String::from("hello")))),
- "two: hello".to_string()
- );
- assert_eq!(
- format!("{:?}", Wrapper::from(Wrapped::One)),
- "Wrapper(One)".to_string()
- );
+ assert_eq!(format!("{}", Wrapper::from(Wrapped::One)),
+ "One".to_string());
+ assert_eq!(format!("{}",
+ Wrapper::from(Wrapped::from(String::from("hello")))),
+ "two: hello".to_string());
+ assert_eq!(format!("{:?}", Wrapper::from(Wrapped::One)),
+ "Wrapper(One)".to_string());
}
quick_error! {
@@ -1037,14 +1053,14 @@ mod test {
ParseFloatError(err: ParseFloatError) {
from()
display("parse float error: {err}", err=err)
- source(err)
+ cause(err)
}
Other(descr: &'static str) {
display("Error: {}", descr)
}
/// FromUtf8 Error
FromUtf8Error(err: Utf8Error, source: Vec<u8>) {
- source(err)
+ cause(err)
display(me) -> ("{desc} at index {pos}: {err}", desc="utf8 error", pos=err.valid_up_to(), err=err)
from(err: FromUtf8Error) -> (err.utf8_error().clone(), err.into_bytes())
}
@@ -1059,68 +1075,46 @@ mod test {
#[test]
fn tuple_wrapper_err() {
- let source = "one and a half times pi".parse::<f32>().unwrap_err();
- let err = TupleWrapper::ParseFloatError(source.clone());
- assert_eq!(format!("{}", err), format!("parse float error: {}", source));
- assert_eq!(
- format!("{:?}", err),
- format!("ParseFloatError({:?})", source)
- );
- assert_eq!(
- format!("{:?}", err.source().unwrap()),
- format!("{:?}", source)
- );
+ let cause = "one and a half times pi".parse::<f32>().unwrap_err();
+ let err = TupleWrapper::ParseFloatError(cause.clone());
+ assert_eq!(format!("{}", err), format!("parse float error: {}", cause));
+ assert_eq!(format!("{:?}", err), format!("ParseFloatError({:?})", cause));
+ assert_eq!(format!("{:?}", err.cause().unwrap()), format!("{:?}", cause));
}
#[test]
fn tuple_wrapper_trait_str() {
let desc = "hello";
- let err: &dyn Error = &TupleWrapper::Other(desc);
+ let err: &Error = &TupleWrapper::Other(desc);
assert_eq!(format!("{}", err), format!("Error: {}", desc));
assert_eq!(format!("{:?}", err), format!("Other({:?})", desc));
- assert!(err.source().is_none());
+ assert!(err.cause().is_none());
}
#[test]
fn tuple_wrapper_trait_two_fields() {
let invalid_utf8: Vec<u8> = vec![0, 159, 146, 150];
- let source = String::from_utf8(invalid_utf8.clone())
- .unwrap_err()
- .utf8_error();
- let err: &dyn Error = &TupleWrapper::FromUtf8Error(source.clone(), invalid_utf8.clone());
- assert_eq!(
- format!("{}", err),
- format!(
- "{desc} at index {pos}: {source}",
- desc = "utf8 error",
- pos = source.valid_up_to(),
- source = source
- )
- );
- assert_eq!(
- format!("{:?}", err),
- format!("FromUtf8Error({:?}, {:?})", source, invalid_utf8)
- );
- assert_eq!(
- format!("{:?}", err.source().unwrap()),
- format!("{:?}", source)
- );
+ let cause = String::from_utf8(invalid_utf8.clone()).unwrap_err().utf8_error();
+ let err: &Error = &TupleWrapper::FromUtf8Error(cause.clone(), invalid_utf8.clone());
+ assert_eq!(format!("{}", err), format!("{desc} at index {pos}: {cause}", desc="utf8 error", pos=cause.valid_up_to(), cause=cause));
+ assert_eq!(format!("{:?}", err), format!("FromUtf8Error({:?}, {:?})", cause, invalid_utf8));
+ assert_eq!(format!("{:?}", err.cause().unwrap()), format!("{:?}", cause));
}
#[test]
fn tuple_wrapper_from() {
- let source = "one and a half times pi".parse::<f32>().unwrap_err();
- let err = TupleWrapper::ParseFloatError(source.clone());
- let err_from: TupleWrapper = From::from(source);
+ let cause = "one and a half times pi".parse::<f32>().unwrap_err();
+ let err = TupleWrapper::ParseFloatError(cause.clone());
+ let err_from: TupleWrapper = From::from(cause);
assert_eq!(err_from, err);
}
#[test]
fn tuple_wrapper_custom_from() {
let invalid_utf8: Vec<u8> = vec![0, 159, 146, 150];
- let source = String::from_utf8(invalid_utf8.clone()).unwrap_err();
- let err = TupleWrapper::FromUtf8Error(source.utf8_error().clone(), invalid_utf8);
- let err_from: TupleWrapper = From::from(source);
+ let cause = String::from_utf8(invalid_utf8.clone()).unwrap_err();
+ let err = TupleWrapper::FromUtf8Error(cause.utf8_error().clone(), invalid_utf8);
+ let err_from: TupleWrapper = From::from(cause);
assert_eq!(err_from, err);
}
@@ -1129,7 +1123,7 @@ mod test {
let err: TupleWrapper = From::from("hello");
assert_eq!(format!("{}", err), format!("Discard"));
assert_eq!(format!("{:?}", err), format!("Discard"));
- assert!(err.source().is_none());
+ assert!(err.cause().is_none());
}
#[test]
@@ -1137,7 +1131,7 @@ mod test {
let err: TupleWrapper = TupleWrapper::Singleton;
assert_eq!(format!("{}", err), format!("Just a string"));
assert_eq!(format!("{:?}", err), format!("Singleton"));
- assert!(err.source().is_none());
+ assert!(err.cause().is_none());
}
quick_error! {
@@ -1145,7 +1139,7 @@ mod test {
pub enum StructWrapper {
// Utf8 Error
Utf8Error{ err: Utf8Error, hint: Option<&'static str> } {
- source(err)
+ cause(err)
display(me) -> ("{desc} at index {pos}: {err}", desc="utf8 error", pos=err.valid_up_to(), err=err)
from(err: Utf8Error) -> { err: err, hint: None }
}
@@ -1159,47 +1153,19 @@ mod test {
#[test]
fn struct_wrapper_err() {
let invalid_utf8: Vec<u8> = vec![0, 159, 146, 150];
- let source = String::from_utf8(invalid_utf8.clone())
- .unwrap_err()
- .utf8_error();
- let err: &dyn Error = &StructWrapper::Utf8Error {
- err: source.clone(),
- hint: Some("nonsense"),
- };
- assert_eq!(
- format!("{}", err),
- format!(
- "{desc} at index {pos}: {source}",
- desc = "utf8 error",
- pos = source.valid_up_to(),
- source = source
- )
- );
- assert_eq!(
- format!("{:?}", err),
- format!(
- "Utf8Error {{ err: {:?}, hint: {:?} }}",
- source,
- Some("nonsense")
- )
- );
- assert_eq!(
- format!("{:?}", err.source().unwrap()),
- format!("{:?}", source)
- );
+ let cause = String::from_utf8(invalid_utf8.clone()).unwrap_err().utf8_error();
+ let err: &Error = &StructWrapper::Utf8Error{ err: cause.clone(), hint: Some("nonsense") };
+ assert_eq!(format!("{}", err), format!("{desc} at index {pos}: {cause}", desc="utf8 error", pos=cause.valid_up_to(), cause=cause));
+ assert_eq!(format!("{:?}", err), format!("Utf8Error {{ err: {:?}, hint: {:?} }}", cause, Some("nonsense")));
+ assert_eq!(format!("{:?}", err.cause().unwrap()), format!("{:?}", cause));
}
#[test]
fn struct_wrapper_struct_from() {
let invalid_utf8: Vec<u8> = vec![0, 159, 146, 150];
- let source = String::from_utf8(invalid_utf8.clone())
- .unwrap_err()
- .utf8_error();
- let err = StructWrapper::Utf8Error {
- err: source.clone(),
- hint: None,
- };
- let err_from: StructWrapper = From::from(source);
+ let cause = String::from_utf8(invalid_utf8.clone()).unwrap_err().utf8_error();
+ let err = StructWrapper::Utf8Error{ err: cause.clone(), hint: None };
+ let err_from: StructWrapper = From::from(cause);
assert_eq!(err_from, err);
}
@@ -1208,11 +1174,8 @@ mod test {
let descr = "hello";
let err = StructWrapper::ExcessComma { descr: descr };
assert_eq!(format!("{}", err), format!("Error: {}", descr));
- assert_eq!(
- format!("{:?}", err),
- format!("ExcessComma {{ descr: {:?} }}", descr)
- );
- assert!(err.source().is_none());
+ assert_eq!(format!("{:?}", err), format!("ExcessComma {{ descr: {:?} }}", descr));
+ assert!(err.cause().is_none());
}
quick_error! {
@@ -1243,23 +1206,19 @@ mod test {
#[test]
fn parse_float_error() {
fn parse_float(s: &str) -> Result<f32, ContextErr> {
- Ok(s.parse().context(s)?)
+ Ok(try!(s.parse().context(s)))
}
- assert_eq!(
- format!("{}", parse_float("12ab").unwrap_err()),
- r#"Float error "12ab": invalid float literal"#
- );
+ assert_eq!(format!("{}", parse_float("12ab").unwrap_err()),
+ r#"Float error "12ab": invalid float literal"#);
}
#[test]
fn parse_int_error() {
fn parse_int(s: &str) -> Result<i32, ContextErr> {
- Ok(s.parse().context(s)?)
+ Ok(try!(s.parse().context(s)))
}
- assert_eq!(
- format!("{}", parse_int("12.5").unwrap_err()),
- r#"Int error "12.5": invalid digit found in string"#
- );
+ assert_eq!(format!("{}", parse_int("12.5").unwrap_err()),
+ r#"Int error "12.5": invalid digit found in string"#);
}
#[test]
@@ -1268,24 +1227,25 @@ mod test {
s.parse().context(s).unwrap()
}
assert_eq!(parse_int("12"), 12);
- assert_eq!(
- format!("{:?}", "x".parse::<i32>().context("x")),
- r#"Err(Context("x", ParseIntError { kind: InvalidDigit }))"#
- );
+ assert_eq!(format!("{:?}", "x".parse::<i32>().context("x")),
+ r#"Err(Context("x", ParseIntError { kind: InvalidDigit }))"#);
}
#[test]
fn path_context() {
- fn parse_utf<P: AsRef<Path>>(s: &[u8], p: P) -> Result<(), ContextErr> {
- ::std::str::from_utf8(s).context(p)?;
+ fn parse_utf<P: AsRef<Path>>(s: &[u8], p: P)
+ -> Result<(), ContextErr>
+ {
+ try!(::std::str::from_utf8(s).context(p));
Ok(())
}
let etext = parse_utf(b"a\x80\x80", "/etc").unwrap_err().to_string();
- assert!(etext.starts_with("Path error at \"/etc\": invalid utf-8"));
- let etext = parse_utf(b"\x80\x80", PathBuf::from("/tmp"))
- .unwrap_err()
+ assert!(etext.starts_with(
+ "Path error at \"/etc\": invalid utf-8"));
+ let etext = parse_utf(b"\x80\x80", PathBuf::from("/tmp")).unwrap_err()
.to_string();
- assert!(etext.starts_with("Path error at \"/tmp\": invalid utf-8"));
+ assert!(etext.starts_with(
+ "Path error at \"/tmp\": invalid utf-8"));
}
#[test]
@@ -1299,38 +1259,4 @@ mod test {
}
}
}
-
- #[test]
- #[allow(deprecated)]
- fn cause_struct_wrapper_err() {
- let invalid_utf8: Vec<u8> = vec![0, 159, 146, 150];
- let cause = String::from_utf8(invalid_utf8.clone())
- .unwrap_err()
- .utf8_error();
- let err: &dyn Error = &StructWrapper::Utf8Error {
- err: cause.clone(),
- hint: Some("nonsense"),
- };
- assert_eq!(
- format!("{}", err),
- format!(
- "{desc} at index {pos}: {cause}",
- desc = "utf8 error",
- pos = cause.valid_up_to(),
- cause = cause
- )
- );
- assert_eq!(
- format!("{:?}", err),
- format!(
- "Utf8Error {{ err: {:?}, hint: {:?} }}",
- cause,
- Some("nonsense")
- )
- );
- assert_eq!(
- format!("{:?}", err.cause().unwrap()),
- format!("{:?}", cause)
- );
- }
}
diff --git a/vendor/quick-error/vagga.yaml b/vendor/quick-error/vagga.yaml
index 35eb29675..71b9be44e 100644
--- a/vendor/quick-error/vagga.yaml
+++ b/vendor/quick-error/vagga.yaml
@@ -23,12 +23,12 @@ containers:
- !Install [ca-certificates, build-essential, vim]
- !TarInstall
- url: "https://static.rust-lang.org/dist/rust-1.31.0-x86_64-unknown-linux-gnu.tar.gz"
+ url: "https://static.rust-lang.org/dist/rust-1.16.0-x86_64-unknown-linux-gnu.tar.gz"
script: "./install.sh --prefix=/usr \
--components=rustc,rust-std-x86_64-unknown-linux-gnu,cargo"
- &bulk !Tar
- url: "https://github.com/tailhook/bulk/releases/download/v0.4.10/bulk-v0.4.10.tar.gz"
- sha256: 481513f8a0306a9857d045497fb5b50b50a51e9ff748909ecf7d2bda1de275ab
+ url: "https://github.com/tailhook/bulk/releases/download/v0.4.9/bulk-v0.4.9.tar.gz"
+ sha256: 23471a9986274bb4b7098c03e2eb7e1204171869b72c45385fcee1c64db2d111
path: /
environ: