@@ -978,17 +978,17 @@ impl Bindings {
978978 }
979979
980980 /// Gets the rustfmt path to rustfmt the generated bindings.
981- fn rustfmt_path ( & self ) -> io :: Result < Cow < ' _ , Path > > {
981+ fn rustfmt_path ( & self ) -> Cow < ' _ , Path > {
982982 debug_assert ! ( matches!( self . options. formatter, Formatter :: Rustfmt ) ) ;
983983 if let Some ( ref p) = self . options . rustfmt_path {
984- return Ok ( Cow :: Borrowed ( p) ) ;
985- }
986- if let Ok ( rustfmt) = env:: var ( "RUSTFMT" ) {
987- return Ok ( Cow :: Owned ( rustfmt. into ( ) ) ) ;
984+ Cow :: Borrowed ( p)
985+ } else if let Ok ( rustfmt) = env:: var ( "RUSTFMT" ) {
986+ Cow :: Owned ( rustfmt. into ( ) )
987+ } else {
988+ // No rustfmt binary was specified, so assume that the binary is called
989+ // "rustfmt" and that it is in the user's PATH.
990+ Cow :: Borrowed ( Path :: new ( "rustfmt" ) )
988991 }
989- // No rustfmt binary was specified, so assume that the binary is called
990- // "rustfmt" and that it is in the user's PATH.
991- Ok ( Cow :: Owned ( "rustfmt" . into ( ) ) )
992992 }
993993
994994 /// Formats a token stream with the formatter set up in `BindgenOptions`.
@@ -1008,7 +1008,7 @@ impl Bindings {
10081008 Formatter :: Rustfmt => ( ) ,
10091009 }
10101010
1011- let rustfmt = self . rustfmt_path ( ) ? ;
1011+ let rustfmt = self . rustfmt_path ( ) ;
10121012 let mut cmd = Command :: new ( & * rustfmt) ;
10131013
10141014 cmd. stdin ( Stdio :: piped ( ) ) . stdout ( Stdio :: piped ( ) ) ;
0 commit comments