From 4389c4c2572a2af7cfe68843fbc93c9ccad0342d Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 9 Oct 2019 22:42:43 -0700 Subject: [PATCH] Switch from `failure` to `anyhow` This moves us back to `std::error::Error` compatibility and helps build times since it doesn't rely on an older version of `syn` --- Cargo.toml | 2 +- crates/fuzz-utils/Cargo.toml | 2 +- crates/fuzz-utils/src/lib.rs | 17 ++++----- crates/tests-utils/Cargo.toml | 2 +- crates/tests-utils/src/lib.rs | 26 ++++++-------- crates/tests/Cargo.toml | 2 +- crates/tests/tests/function_imports.rs | 2 +- crates/tests/tests/invalid.rs | 9 ++--- crates/tests/tests/round_trip.rs | 2 +- crates/tests/tests/spec-tests.rs | 6 ++-- crates/tests/tests/valid.rs | 2 +- examples/round-trip.rs | 16 ++------- src/error.rs | 4 +-- src/init_expr.rs | 2 +- src/module/data.rs | 4 +-- src/module/elements.rs | 4 +-- .../functions/local_function/context.rs | 35 +++++++++---------- src/module/functions/local_function/mod.rs | 4 +-- src/module/functions/mod.rs | 2 +- src/module/imports.rs | 3 +- src/module/mod.rs | 4 +-- src/module/tables.rs | 5 +-- src/parse.rs | 2 +- src/passes/validate.rs | 8 ++--- src/ty.rs | 3 +- 25 files changed, 72 insertions(+), 96 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 9731a15b..907c90be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -23,7 +23,7 @@ path = "benches/benches.rs" harness = false [dependencies] -failure = { version = "0.1.5", default-features = false, features = ['std'] } +anyhow = "1.0" id-arena = "2.2.1" leb128 = "0.2.4" log = "0.4.8" diff --git a/crates/fuzz-utils/Cargo.toml b/crates/fuzz-utils/Cargo.toml index 49125cd3..630eea1b 100644 --- a/crates/fuzz-utils/Cargo.toml +++ b/crates/fuzz-utils/Cargo.toml @@ -8,7 +8,7 @@ publish = false [dependencies] rand = { version = "0.7.0", features = ['small_rng'] } tempfile = "3.1.0" -failure = "0.1.5" +anyhow = "1.0" env_logger = "0.7.0" [dependencies.walrus] diff --git a/crates/fuzz-utils/src/lib.rs b/crates/fuzz-utils/src/lib.rs index 35b1bc03..baac8175 100755 --- a/crates/fuzz-utils/src/lib.rs +++ b/crates/fuzz-utils/src/lib.rs @@ -2,7 +2,7 @@ #![deny(missing_docs)] -use failure::ResultExt; +use anyhow::Context; use rand::{rngs::SmallRng, Rng, SeedableRng}; use std::cmp; use std::fmt; @@ -12,8 +12,8 @@ use std::path::Path; use std::time; use walrus_tests_utils::{wasm_interp, wat2wasm}; -/// `Ok(T)` or a `Err(failure::Error)` -pub type Result = std::result::Result; +/// `Ok(T)` or a `Err(anyhow::Error)` +pub type Result = std::result::Result; #[derive(Copy, Clone, Debug)] enum ValType { @@ -139,7 +139,7 @@ where pub fn run_one(&mut self) -> Result<()> { let wat = self.gen_wat(); self.test_wat(&wat) - .with_context(|_| format!("wat = {}", wat))?; + .with_context(|| format!("wat = {}", wat))?; Ok(()) } @@ -436,12 +436,9 @@ impl TestCaseGenerator for WasmOptTtf { } } -/// Print a `failure::Error` with its chain. -pub fn print_err(e: &failure::Error) { - eprintln!("Error:"); - for c in e.iter_chain() { - eprintln!(" - {}", c); - } +/// Print a `anyhow::Error` with its chain. +pub fn print_err(e: &anyhow::Error) { + eprintln!("Error: {:?}", e); } #[cfg(test)] diff --git a/crates/tests-utils/Cargo.toml b/crates/tests-utils/Cargo.toml index 60771674..3a20e761 100644 --- a/crates/tests-utils/Cargo.toml +++ b/crates/tests-utils/Cargo.toml @@ -7,4 +7,4 @@ publish = false [dependencies] tempfile = "3.1.0" -failure = "0.1.5" +anyhow = "1.0" diff --git a/crates/tests-utils/src/lib.rs b/crates/tests-utils/src/lib.rs index a2529f97..e4b76a67 100644 --- a/crates/tests-utils/src/lib.rs +++ b/crates/tests-utils/src/lib.rs @@ -1,11 +1,11 @@ -use failure::ResultExt; +use anyhow::{bail, Context}; use std::ffi::OsStr; use std::fs; use std::path::{Path, PathBuf}; use std::process::{Command, Stdio}; use std::sync::Once; -pub type Result = std::result::Result; +pub type Result = std::result::Result; pub const FEATURES: &[&str] = &[ "--enable-threads", @@ -56,7 +56,7 @@ pub fn wat2wasm(path: &Path, extra_args: &[&str]) -> Result> { let output = cmd.output().context("could not spawn wat2wasm")?; if !output.status.success() { - failure::bail!( + bail!( "wat2wasm exited with status {:?}\n\nstderr = '''\n{}\n'''", output.status, String::from_utf8_lossy(&output.stderr) @@ -82,7 +82,7 @@ pub fn wasm2wat(path: &Path) -> Result { println!("running: {:?}", cmd); let output = cmd.output().context("could not run wasm2wat")?; if !output.status.success() { - failure::bail!( + bail!( "wasm2wat exited with status {:?}\n\nstderr = '''\n{}\n'''", output.status, String::from_utf8_lossy(&output.stderr) @@ -111,7 +111,7 @@ pub fn wasm_interp(path: &Path) -> Result { println!("running: {:?}", cmd); let output = cmd.output().context("could notrun wasm-interp")?; if !output.status.success() { - failure::bail!( + bail!( "wasm-interp exited with status {:?}\n\nstderr = '''\n{}\n'''", output.status, String::from_utf8_lossy(&output.stderr) @@ -151,7 +151,7 @@ where println!("running: {:?}", cmd); let output = cmd.output().context("could not run wasm-opt")?; if !output.status.success() { - failure::bail!( + bail!( "wasm-opt exited with status {:?}\n\nstderr = '''\n{}\n'''", output.status, String::from_utf8_lossy(&output.stderr) @@ -174,17 +174,11 @@ impl TestResult for () { fn handle(self) {} } -impl TestResult for std::result::Result<(), failure::Error> { +impl TestResult for Result<()> { fn handle(self) { - let err = match self { - Ok(()) => return, - Err(e) => e, - }; - eprintln!("got an error:"); - for c in err.iter_chain() { - eprintln!(" {}", c); + match self { + Ok(()) => {} + Err(e) => panic!("got an error: {:?}", e), } - eprintln!("{}", err.backtrace()); - panic!("test failed"); } } diff --git a/crates/tests/Cargo.toml b/crates/tests/Cargo.toml index aca30bff..5855ee1f 100644 --- a/crates/tests/Cargo.toml +++ b/crates/tests/Cargo.toml @@ -9,7 +9,7 @@ publish = false walkdir = "2.2.9" [dev-dependencies] -failure = "0.1.5" +anyhow = "1.0" walrus = { path = "../.." } walrus-tests-utils = { path = "../tests-utils" } tempfile = "3.1.0" diff --git a/crates/tests/tests/function_imports.rs b/crates/tests/tests/function_imports.rs index 8da7440d..e1ab743d 100644 --- a/crates/tests/tests/function_imports.rs +++ b/crates/tests/tests/function_imports.rs @@ -1,7 +1,7 @@ use std::path::Path; use walrus_tests_utils::wat2wasm; -fn run(wat_path: &Path) -> Result<(), failure::Error> { +fn run(wat_path: &Path) -> Result<(), anyhow::Error> { static INIT_LOGS: std::sync::Once = std::sync::Once::new(); INIT_LOGS.call_once(|| { env_logger::init(); diff --git a/crates/tests/tests/invalid.rs b/crates/tests/tests/invalid.rs index 66a27534..5f97c7b8 100644 --- a/crates/tests/tests/invalid.rs +++ b/crates/tests/tests/invalid.rs @@ -1,7 +1,7 @@ use std::path::Path; use std::sync::Once; -fn run(wat: &Path) -> Result<(), failure::Error> { +fn run(wat: &Path) -> Result<(), anyhow::Error> { static INIT_LOGS: Once = Once::new(); INIT_LOGS.call_once(|| { env_logger::init(); @@ -12,12 +12,9 @@ fn run(wat: &Path) -> Result<(), failure::Error> { // NB: reading the module will do the validation. match walrus::Module::from_buffer(&wasm) { Err(e) => { - eprintln!("Got error, as expected:"); - for c in e.iter_chain() { - eprintln!(" - {}", c); - } + eprintln!("Got error, as expected: {:?}", e); } - Ok(_) => failure::bail!("expected {} to be invalid, but it was valid", wat.display()), + Ok(_) => anyhow::bail!("expected {} to be invalid, but it was valid", wat.display()), } Ok(()) diff --git a/crates/tests/tests/round_trip.rs b/crates/tests/tests/round_trip.rs index ac80ffbd..80154d19 100644 --- a/crates/tests/tests/round_trip.rs +++ b/crates/tests/tests/round_trip.rs @@ -2,7 +2,7 @@ use std::env; use std::path::Path; use walrus_tests_utils::{wasm2wat, wat2wasm}; -fn run(wat_path: &Path) -> Result<(), failure::Error> { +fn run(wat_path: &Path) -> Result<(), anyhow::Error> { static INIT_LOGS: std::sync::Once = std::sync::Once::new(); INIT_LOGS.call_once(|| { env_logger::init(); diff --git a/crates/tests/tests/spec-tests.rs b/crates/tests/tests/spec-tests.rs index 5ee8363a..9eff5c08 100644 --- a/crates/tests/tests/spec-tests.rs +++ b/crates/tests/tests/spec-tests.rs @@ -1,4 +1,4 @@ -use failure::ResultExt; +use anyhow::Context; use std::fs; use std::path::Path; use std::process::Command; @@ -10,7 +10,7 @@ struct Test { commands: Vec, } -fn run(wast: &Path) -> Result<(), failure::Error> { +fn run(wast: &Path) -> Result<(), anyhow::Error> { static INIT_LOGS: std::sync::Once = std::sync::Once::new(); INIT_LOGS.call_once(|| { env_logger::init(); @@ -145,7 +145,7 @@ fn run(wast: &Path) -> Result<(), failure::Error> { Ok(()) } -fn run_spectest_interp(cwd: &Path, extra_args: &[&str]) -> Result<(), failure::Error> { +fn run_spectest_interp(cwd: &Path, extra_args: &[&str]) -> Result<(), anyhow::Error> { let output = Command::new("spectest-interp") .current_dir(cwd) .arg("foo.json") diff --git a/crates/tests/tests/valid.rs b/crates/tests/tests/valid.rs index db4a6dbc..7413a22c 100644 --- a/crates/tests/tests/valid.rs +++ b/crates/tests/tests/valid.rs @@ -2,7 +2,7 @@ use std::env; use std::path::Path; use std::sync::Once; -fn run(wat: &Path) -> Result<(), failure::Error> { +fn run(wat: &Path) -> Result<(), anyhow::Error> { static INIT_LOGS: Once = Once::new(); INIT_LOGS.call_once(|| { env_logger::init(); diff --git a/examples/round-trip.rs b/examples/round-trip.rs index 5a556aec..0dd75d89 100644 --- a/examples/round-trip.rs +++ b/examples/round-trip.rs @@ -1,21 +1,9 @@ //! A small example which is primarily used to help benchmark walrus right now. -use std::process; - -fn main() { - if let Err(e) = try_main() { - eprintln!("Error!"); - for c in e.iter_chain() { - eprintln!("{}", c); - } - process::exit(1); - } -} - -fn try_main() -> Result<(), failure::Error> { +fn main() -> anyhow::Result<()> { env_logger::init(); let a = std::env::args().nth(1).ok_or_else(|| { - failure::format_err!("must provide the input wasm file as the first argument") + anyhow::anyhow!("must provide the input wasm file as the first argument") })?; let m = walrus::Module::from_file(&a)?; let wasm = m.emit_wasm(); diff --git a/src/error.rs b/src/error.rs index 55dd32bc..97e5d33a 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,10 +1,10 @@ //! Error types and utilities. -pub use failure::Error; +pub use anyhow::Error; use std::fmt; /// Either `Ok(T)` or `Err(failure::Error)`. -pub type Result = ::std::result::Result; +pub type Result = ::std::result::Result; /// A leaf wasm error type. /// diff --git a/src/init_expr.rs b/src/init_expr.rs index 06d537f8..a81dbc79 100644 --- a/src/init_expr.rs +++ b/src/init_expr.rs @@ -4,7 +4,7 @@ use crate::emit::{Emit, EmitContext}; use crate::ir::Value; use crate::parse::IndicesToIds; use crate::{GlobalId, Result}; -use failure::bail; +use anyhow::bail; /// A constant which is produced in WebAssembly, typically used in global /// initializers or element/data offsets. diff --git a/src/module/data.rs b/src/module/data.rs index 4424a509..1647bdfa 100644 --- a/src/module/data.rs +++ b/src/module/data.rs @@ -5,7 +5,7 @@ use crate::ir::Value; use crate::parse::IndicesToIds; use crate::tombstone_arena::{Id, Tombstone, TombstoneArena}; use crate::{GlobalId, InitExpr, MemoryId, Module, Result, ValType}; -use failure::{bail, ResultExt}; +use anyhow::{bail, Context}; /// A passive element segment identifier pub type DataId = Id; @@ -217,7 +217,7 @@ impl Module { memory.data_segments.insert(data.id); let offset = InitExpr::eval(&init_expr, ids) - .with_context(|_e| format!("in segment {}", i))?; + .with_context(|| format!("in segment {}", i))?; data.kind = DataKind::Active(ActiveData { memory: memory_id, location: match offset { diff --git a/src/module/elements.rs b/src/module/elements.rs index 8b4ccd2a..bb350cf3 100644 --- a/src/module/elements.rs +++ b/src/module/elements.rs @@ -5,7 +5,7 @@ use crate::ir::Value; use crate::parse::IndicesToIds; use crate::tombstone_arena::{Id, Tombstone, TombstoneArena}; use crate::{FunctionId, InitExpr, Module, Result, TableKind, ValType}; -use failure::{bail, ResultExt}; +use anyhow::{bail, Context}; /// A passive element segment identifier pub type ElementId = Id; @@ -92,7 +92,7 @@ impl Module { }; let offset = InitExpr::eval(&init_expr, ids) - .with_context(|_e| format!("in segment {}", i))?; + .with_context(|| format!("in segment {}", i))?; let functions = segment.items.get_items_reader()?.into_iter().map(|func| { let func = func?; ids.get_func(func) diff --git a/src/module/functions/local_function/context.rs b/src/module/functions/local_function/context.rs index fd74037f..522bae9c 100644 --- a/src/module/functions/local_function/context.rs +++ b/src/module/functions/local_function/context.rs @@ -7,7 +7,7 @@ use crate::module::Module; use crate::parse::IndicesToIds; use crate::ty::ValType; use crate::{ModuleTypes, TypeId}; -use failure::Fail; +use anyhow::Context; #[derive(Debug)] pub(crate) struct ControlFrame { @@ -173,7 +173,7 @@ impl<'a> ValidationContext<'a> { pub fn control(&self, n: usize) -> Result<&ControlFrame> { if n >= self.controls.len() { - failure::bail!("jump to nonexistent control block"); + anyhow::bail!("jump to nonexistent control block"); } let idx = self.controls.len() - n - 1; Ok(&self.controls[idx]) @@ -217,9 +217,8 @@ fn impl_pop_operand( log::trace!("pop operand: None"); return Ok(None); } - return Err(ErrorKind::InvalidWasm - .context("popped operand past control frame height in non-unreachable code") - .into()); + return Err(ErrorKind::InvalidWasm) + .context("popped operand past control frame height in non-unreachable code"); } } let op = operands.pop().unwrap(); @@ -237,10 +236,9 @@ fn impl_pop_operand_expected( (actual, None) => Ok(actual), (Some(actual), Some(expected)) => { if actual != expected { - Err(ErrorKind::InvalidWasm + Err(ErrorKind::InvalidWasm) .context(format!("expected type {}", expected)) .context(format!("found type {}", actual)) - .into()) } else { Ok(Some(actual)) } @@ -275,7 +273,7 @@ fn impl_push_control( end_types: Box<[ValType]>, ) -> Result { let ty = InstrSeqType::existing(types, &start_types, &end_types).ok_or_else(|| { - failure::format_err!( + anyhow::anyhow!( "attempted to push a control frame for an instruction \ sequence with a type that does not exist" ) @@ -330,19 +328,18 @@ fn impl_pop_control( controls: &mut ControlStack, operands: &mut OperandStack, ) -> Result { - let frame = controls.last().ok_or_else(|| { - ErrorKind::InvalidWasm.context("attempted to pop a frame from an empty control stack") - })?; + let frame = controls + .last() + .ok_or_else(|| ErrorKind::InvalidWasm) + .context("attempted to pop a frame from an empty control stack")?; impl_pop_operands(operands, controls, &frame.end_types)?; if operands.len() != frame.height { - return Err(ErrorKind::InvalidWasm - .context(format!( - "incorrect number of operands on the stack at the end of a control frame; \ - found {}, expected {}", - operands.len(), - frame.height - )) - .into()); + return Err(ErrorKind::InvalidWasm).context(format!( + "incorrect number of operands on the stack at the end of a control frame; \ + found {}, expected {}", + operands.len(), + frame.height + )); } let frame = controls.pop().unwrap(); Ok(frame) diff --git a/src/module/functions/local_function/mod.rs b/src/module/functions/local_function/mod.rs index f9ba925c..a723df48 100644 --- a/src/module/functions/local_function/mod.rs +++ b/src/module/functions/local_function/mod.rs @@ -12,7 +12,7 @@ use crate::parse::IndicesToIds; use crate::{ Data, DataId, FunctionBuilder, FunctionId, Module, Result, TableKind, TypeId, ValType, }; -use failure::{bail, ResultExt}; +use anyhow::{bail, Context}; use std::collections::BTreeMap; use wasmparser::Operator; @@ -308,7 +308,7 @@ fn validate_instruction(ctx: &mut ValidationContext, inst: Operator) -> Result<( let mem_arg = |arg: &wasmparser::MemoryImmediate| -> Result { if arg.flags >= 32 { - failure::bail!("invalid alignment"); + bail!("invalid alignment"); } Ok(MemArg { align: 1 << (arg.flags as i32), diff --git a/src/module/functions/mod.rs b/src/module/functions/mod.rs index 4018a4a1..0dfc50b2 100644 --- a/src/module/functions/mod.rs +++ b/src/module/functions/mod.rs @@ -11,7 +11,7 @@ use crate::parse::IndicesToIds; use crate::tombstone_arena::{Id, Tombstone, TombstoneArena}; use crate::ty::TypeId; use crate::ty::ValType; -use failure::bail; +use anyhow::bail; use std::cmp; #[cfg(feature = "parallel")] diff --git a/src/module/imports.rs b/src/module/imports.rs index f56937ec..519fa4e1 100644 --- a/src/module/imports.rs +++ b/src/module/imports.rs @@ -5,6 +5,7 @@ use crate::parse::IndicesToIds; use crate::tombstone_arena::{Id, Tombstone, TombstoneArena}; use crate::{FunctionId, FunctionTable, GlobalId, MemoryId, Result, TableId}; use crate::{Module, TableKind, TypeId, ValType}; +use anyhow::bail; /// The id of an import. pub type ImportId = Id; @@ -123,7 +124,7 @@ impl Module { wasmparser::ImportSectionEntryType::Table(t) => { let kind = match t.element_type { wasmparser::Type::AnyFunc => TableKind::Function(FunctionTable::default()), - _ => failure::bail!("invalid table type"), + _ => bail!("invalid table type"), }; let id = self.add_import_table( entry.module, diff --git a/src/module/mod.rs b/src/module/mod.rs index 1bf63925..16951b18 100644 --- a/src/module/mod.rs +++ b/src/module/mod.rs @@ -35,7 +35,7 @@ pub use crate::module::tables::FunctionTable; pub use crate::module::tables::{ModuleTables, Table, TableId, TableKind}; pub use crate::module::types::ModuleTypes; use crate::parse::IndicesToIds; -use failure::{bail, ResultExt}; +use anyhow::{bail, Context}; use std::fs; use std::mem; use std::path::Path; @@ -189,7 +189,7 @@ impl Module { } "name" => section .get_name_section_reader() - .map_err(failure::Error::from) + .map_err(anyhow::Error::from) .and_then(|r| ret.parse_name_section(r, &indices)), _ => { log::debug!("parsing custom section `{}`", name); diff --git a/src/module/tables.rs b/src/module/tables.rs index 480ea9ff..82fcbfc0 100644 --- a/src/module/tables.rs +++ b/src/module/tables.rs @@ -4,6 +4,7 @@ use crate::emit::{Emit, EmitContext, Section}; use crate::parse::IndicesToIds; use crate::tombstone_arena::{Id, Tombstone, TombstoneArena}; use crate::{FunctionId, GlobalId, ImportId, Module, Result, ValType}; +use anyhow::bail; /// The id of a table. pub type TableId = Id; @@ -179,7 +180,7 @@ impl ModuleTables { None => return Ok(None), }; if tables.next().is_some() { - failure::bail!("module contains more than one function table"); + bail!("module contains more than one function table"); } Ok(Some(id)) } @@ -206,7 +207,7 @@ impl Module { match t.element_type { wasmparser::Type::AnyFunc => TableKind::Function(FunctionTable::default()), wasmparser::Type::AnyRef => TableKind::Anyref(AnyrefTable::default()), - _ => failure::bail!("invalid table type"), + _ => bail!("invalid table type"), }, ); ids.push_table(id); diff --git a/src/parse.rs b/src/parse.rs index f73b5102..3f46be72 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -1,7 +1,7 @@ use crate::map::IdHashMap; use crate::{DataId, ElementId, Function, FunctionId, GlobalId, Result}; use crate::{LocalId, MemoryId, TableId, TypeId}; -use failure::bail; +use anyhow::bail; /// Maps from old indices in the original Wasm binary to `walrus` IDs. /// diff --git a/src/passes/validate.rs b/src/passes/validate.rs index 555d9838..15ed0dbc 100644 --- a/src/passes/validate.rs +++ b/src/passes/validate.rs @@ -7,7 +7,7 @@ use crate::ir::*; use crate::ValType; use crate::{Function, FunctionKind, InitExpr, Result}; use crate::{Global, GlobalKind, Memory, MemoryId, Module, Table, TableKind}; -use failure::{bail, ResultExt}; +use anyhow::{anyhow, bail, Context}; use std::collections::HashSet; #[cfg(feature = "parallel")] @@ -72,7 +72,7 @@ pub fn run(module: &Module) -> Result<()> { let mut msg = format!("errors validating module:\n"); for error in errs.into_iter().flat_map(|v| v) { msg.push_str(&format!(" * {}\n", error)); - for cause in error.iter_causes() { + for cause in error.chain() { msg.push_str(&format!(" * {}\n", cause)); } } @@ -164,7 +164,7 @@ fn validate_value(value: Value, ty: ValType) -> Result<()> { } struct Validate<'a> { - errs: &'a mut Vec, + errs: &'a mut Vec, function: &'a Function, module: &'a Module, } @@ -194,7 +194,7 @@ impl Validate<'_> { } fn err(&mut self, msg: &str) { - let mut err = failure::format_err!("{}", msg); + let mut err = anyhow!("{}", msg); if let Some(name) = &self.function.name { err = err.context(format!("in function {}", name)).into(); } diff --git a/src/ty.rs b/src/ty.rs index eb7a3755..1ee15eee 100644 --- a/src/ty.rs +++ b/src/ty.rs @@ -4,6 +4,7 @@ use crate::emit::{Emit, EmitContext}; use crate::encode::Encoder; use crate::error::Result; use crate::tombstone_arena::Tombstone; +use anyhow::bail; use id_arena::Id; use std::cmp::Ordering; use std::fmt; @@ -166,7 +167,7 @@ impl ValType { wasmparser::Type::F64 => Ok(ValType::F64), wasmparser::Type::V128 => Ok(ValType::V128), wasmparser::Type::AnyRef => Ok(ValType::Anyref), - _ => failure::bail!("not a value type"), + _ => bail!("not a value type"), } }