File tree 1 file changed +11
-9
lines changed
1 file changed +11
-9
lines changed Original file line number Diff line number Diff line change @@ -56,14 +56,17 @@ impl<'tcx> LateLintPass<'tcx> for PathFromFormat {
56
56
let order_of_real_vars: Vec <usize > = format_args. formatters. iter( ) . map( |( x, _) | * x) . collect( ) ;
57
57
let mut sugg = String :: new( ) ;
58
58
for n in 0 ..real_vars. len( ) {
59
- if ( !string_parts[ n] . is_empty( ) && !( string_parts[ n] . ends_with( '/' ) || string_parts[ n] . ends_with( '\\' ) ) ) || ( !string_parts[ n+1 ] . is_empty( ) && ( !( string_parts[ n+1 ] . starts_with( '/' ) || string_parts[ n+1 ] . starts_with( '\\' ) ) ) ) {
59
+ if ( !string_parts[ n] . is_empty( )
60
+ && !( string_parts[ n] . ends_with( '/' ) || string_parts[ n] . ends_with( '\\' ) ) )
61
+ || ( !string_parts[ n+1 ] . is_empty( )
62
+ && ( !( string_parts[ n+1 ] . starts_with( '/' ) || string_parts[ n+1 ] . starts_with( '\\' ) ) ) ) {
60
63
span_lint_and_note(
61
- cx,
62
- PATH_FROM_FORMAT ,
63
- expr. span,
64
- "`format!(..)` used to form `PathBuf`" ,
65
- None ,
66
- "if it fits your use case, you may want to consider using `Path::new()` and `.join()` to make it OS-agnostic and improve code readability." ,
64
+ cx,
65
+ PATH_FROM_FORMAT ,
66
+ expr. span,
67
+ "`format!(..)` used to form `PathBuf`" ,
68
+ None ,
69
+ "if it fits your use case, you may want to consider using `Path::new()` and `.join()` to make it OS-agnostic and improve code readability." ,
67
70
) ;
68
71
return ;
69
72
}
@@ -115,8 +118,7 @@ fn push_comps(string: &mut String, path: &Path) {
115
118
let x = n. as_os_str ( ) . to_string_lossy ( ) . to_string ( ) ;
116
119
if string. is_empty ( ) {
117
120
string. push_str ( & format ! ( "Path::new(\" {x}\" )" ) ) ;
118
- }
119
- else {
121
+ } else {
120
122
string. push_str ( & format ! ( ".join(\" {x}\" )" ) ) ;
121
123
}
122
124
}
You can’t perform that action at this time.
0 commit comments