@@ -2151,24 +2151,26 @@ fn ensure_libclang_is_loaded() {}
2151
2151
#[ non_exhaustive]
2152
2152
pub enum BindgenError {
2153
2153
/// The header was a folder.
2154
- FolderAsHeader ( String ) ,
2154
+ FolderAsHeader ( PathBuf ) ,
2155
2155
/// Permissions to read the header is insufficient.
2156
- InsufficientPermissions ( String ) ,
2156
+ InsufficientPermissions ( PathBuf ) ,
2157
2157
/// The header does not exist.
2158
- NotExist ( String ) ,
2158
+ NotExist ( PathBuf ) ,
2159
2159
/// Clang diagnosed an error.
2160
2160
ClangDiagnostic ( String ) ,
2161
2161
}
2162
2162
2163
2163
impl std:: fmt:: Display for BindgenError {
2164
2164
fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
2165
2165
match self {
2166
- BindgenError :: FolderAsHeader ( h) => write ! ( f, "'{}' is a folder" , h) ,
2166
+ BindgenError :: FolderAsHeader ( h) => {
2167
+ write ! ( f, "'{}' is a folder" , h. display( ) )
2168
+ }
2167
2169
BindgenError :: InsufficientPermissions ( h) => {
2168
- write ! ( f, "insufficient permissions to read '{}'" , h)
2170
+ write ! ( f, "insufficient permissions to read '{}'" , h. display ( ) )
2169
2171
}
2170
2172
BindgenError :: NotExist ( h) => {
2171
- write ! ( f, "header '{}' does not exist." , h)
2173
+ write ! ( f, "header '{}' does not exist." , h. display ( ) )
2172
2174
}
2173
2175
BindgenError :: ClangDiagnostic ( message) => {
2174
2176
write ! ( f, "clang diagnosed error: {}" , message)
@@ -2353,18 +2355,19 @@ impl Bindings {
2353
2355
}
2354
2356
2355
2357
if let Some ( h) = options. input_header . as_ref ( ) {
2356
- if let Ok ( md) = std:: fs:: metadata ( h) {
2358
+ let path = Path :: new ( h) ;
2359
+ if let Ok ( md) = std:: fs:: metadata ( path) {
2357
2360
if md. is_dir ( ) {
2358
- return Err ( BindgenError :: FolderAsHeader ( h . into ( ) ) ) ;
2361
+ return Err ( BindgenError :: FolderAsHeader ( path . into ( ) ) ) ;
2359
2362
}
2360
2363
if !can_read ( & md. permissions ( ) ) {
2361
2364
return Err ( BindgenError :: InsufficientPermissions (
2362
- h . into ( ) ,
2365
+ path . into ( ) ,
2363
2366
) ) ;
2364
2367
}
2365
2368
options. clang_args . push ( h. clone ( ) )
2366
2369
} else {
2367
- return Err ( BindgenError :: NotExist ( h . into ( ) ) ) ;
2370
+ return Err ( BindgenError :: NotExist ( path . into ( ) ) ) ;
2368
2371
}
2369
2372
}
2370
2373
0 commit comments