@@ -9,19 +9,21 @@ use super::JOIN_ABSOLUTE_PATHS;
99
1010pub ( super ) fn check< ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > , join_arg : & ' tcx Expr < ' tcx > ) {
1111 let ty = cx. typeck_results ( ) . expr_ty ( expr) . peel_refs ( ) ;
12- if !expr. span . from_expansion ( ) && is_type_diagnostic_item ( cx, ty, Path )
13- && let ExprKind :: Lit ( spanned) = & join_arg. kind && let LitKind :: Str ( symbol, _) = spanned. node
14- && ( symbol. as_str ( ) . starts_with ( '/' ) || symbol. as_str ( ) . starts_with ( '\\' ) ) {
15- span_lint_and_then (
16- cx,
17- JOIN_ABSOLUTE_PATHS ,
18- join_arg. span ,
19- "argument to `Path::join` starts with a path separator" ,
20- |diag| {
21- diag. note ( "joining a path starting with separator will replace the path instead" ) ;
22- diag. help ( r#"if this is unintentional, try removing the starting separator"# ) ;
23- diag. help ( r#"if this is intentional, try creating a new Path instead"# ) ;
24- } ,
25- ) ;
26- } ;
27- }
12+ if is_type_diagnostic_item ( cx, ty, Path )
13+ && let ExprKind :: Lit ( spanned) = & join_arg. kind
14+ && let LitKind :: Str ( symbol, _) = spanned. node
15+ && ( symbol. as_str ( ) . starts_with ( '/' ) || symbol. as_str ( ) . starts_with ( '\\' ) )
16+ {
17+ span_lint_and_then (
18+ cx,
19+ JOIN_ABSOLUTE_PATHS ,
20+ join_arg. span ,
21+ "argument to `Path::join` starts with a path separator" ,
22+ |diag| {
23+ diag
24+ . note ( "joining a path starting with separator will replace the path instead" )
25+ . help ( r#"if this is unintentional, try removing the starting separator"# )
26+ . help ( r#"if this is intentional, try creating a new Path instead"# ) ;
27+ } ,
28+ ) ;
29+ }
0 commit comments