@@ -12,17 +12,14 @@ use regex::Regex;
12
12
use std:: cell:: Cell ;
13
13
use std:: default:: Default ;
14
14
use std:: fs:: File ;
15
- use std:: io:: { ErrorKind , Read } ;
15
+ use std:: io:: { Error , ErrorKind , Read } ;
16
16
use std:: path:: { Path , PathBuf } ;
17
17
use std:: { env, fs} ;
18
18
19
- use FmtResult ;
20
-
21
19
use config:: config_type:: ConfigType ;
22
20
use config:: file_lines:: FileLines ;
23
21
pub use config:: lists:: * ;
24
22
pub use config:: options:: * ;
25
- use failure:: Error ;
26
23
27
24
#[ macro_use]
28
25
pub mod config_type;
@@ -155,7 +152,7 @@ create_config! {
155
152
pub fn load_config (
156
153
file_path : Option < & Path > ,
157
154
options : Option < & CliOptions > ,
158
- ) -> FmtResult < ( Config , Option < PathBuf > ) > {
155
+ ) -> Result < ( Config , Option < PathBuf > ) , Error > {
159
156
let over_ride = match options {
160
157
Some ( opts) => config_path ( opts) ?,
161
158
None => None ,
@@ -180,7 +177,7 @@ pub fn load_config(
180
177
// Check for the presence of known config file names (`rustfmt.toml, `.rustfmt.toml`) in `dir`
181
178
//
182
179
// Return the path if a config file exists, empty if no file exists, and Error for IO errors
183
- fn get_toml_path ( dir : & Path ) -> FmtResult < Option < PathBuf > > {
180
+ fn get_toml_path ( dir : & Path ) -> Result < Option < PathBuf > , Error > {
184
181
const CONFIG_FILE_NAMES : [ & str ; 2 ] = [ ".rustfmt.toml" , "rustfmt.toml" ] ;
185
182
for config_file_name in & CONFIG_FILE_NAMES {
186
183
let config_file = dir. join ( config_file_name) ;
@@ -192,7 +189,7 @@ fn get_toml_path(dir: &Path) -> FmtResult<Option<PathBuf>> {
192
189
// find the project file yet, and continue searching.
193
190
Err ( e) => {
194
191
if e. kind ( ) != ErrorKind :: NotFound {
195
- return Err ( Error :: from ( e ) ) ;
192
+ return Err ( e ) ;
196
193
}
197
194
}
198
195
_ => { }
@@ -201,11 +198,14 @@ fn get_toml_path(dir: &Path) -> FmtResult<Option<PathBuf>> {
201
198
Ok ( None )
202
199
}
203
200
204
- fn config_path ( options : & CliOptions ) -> FmtResult < Option < PathBuf > > {
205
- let config_path_not_found = |path : & str | -> FmtResult < Option < PathBuf > > {
206
- Err ( format_err ! (
207
- "Error: unable to find a config file for the given path: `{}`" ,
208
- path
201
+ fn config_path ( options : & CliOptions ) -> Result < Option < PathBuf > , Error > {
202
+ let config_path_not_found = |path : & str | -> Result < Option < PathBuf > , Error > {
203
+ Err ( Error :: new (
204
+ ErrorKind :: NotFound ,
205
+ format ! (
206
+ "Error: unable to find a config file for the given path: `{}`" ,
207
+ path
208
+ ) ,
209
209
) )
210
210
} ;
211
211
0 commit comments