@@ -17,7 +17,7 @@ use std::{
1717} ;
1818
1919use {
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 ;
4343pub 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,
0 commit comments