@@ -11,24 +11,19 @@ use super::JOIN_ABSOLUTE_PATHS;
11
11
12
12
pub ( super ) fn check < ' tcx > ( cx : & LateContext < ' tcx > , expr : & ' tcx Expr < ' tcx > , join_arg : & ' tcx Expr < ' tcx > ) {
13
13
let ty = cx. typeck_results ( ) . expr_ty ( expr) . peel_refs ( ) ;
14
- if !expr. span . from_expansion ( ) {
15
- if is_type_diagnostic_item ( cx, ty, Path ) {
16
- let applicability = Applicability :: MachineApplicable ;
17
- if let ExprKind :: Lit ( spanned) = & join_arg. kind {
18
- if let LitKind :: Str ( symbol, _) = spanned. node {
19
- if symbol. as_str ( ) . starts_with ( '/' ) || symbol. as_str ( ) . starts_with ( '\\' ) {
20
- span_lint_and_sugg (
21
- cx,
22
- JOIN_ABSOLUTE_PATHS ,
23
- join_arg. span ( ) . with_hi ( expr. span . hi ( ) ) ,
24
- r#"argument to `Path::join` starts with a path separator"# ,
25
- "try removing first '/' or '\\ '" ,
26
- "join(\" your/path/here\" )" . to_owned ( ) ,
27
- applicability,
28
- ) ;
29
- }
30
- }
31
- }
32
- }
14
+ if !expr. span . from_expansion ( ) && is_type_diagnostic_item ( cx, ty, Path ) {
15
+ let applicability = Applicability :: MachineApplicable ;
16
+ if let ExprKind :: Lit ( spanned) = & join_arg. kind && let LitKind :: Str ( symbol, _) = spanned. node
17
+ && ( symbol. as_str ( ) . starts_with ( '/' ) || symbol. as_str ( ) . starts_with ( '\\' ) ) {
18
+ span_lint_and_sugg (
19
+ cx,
20
+ JOIN_ABSOLUTE_PATHS ,
21
+ join_arg. span ( ) . with_hi ( expr. span . hi ( ) ) ,
22
+ r#"argument to `Path::join` starts with a path separator"# ,
23
+ "try removing first '/' or '\\ '" ,
24
+ "join(\" your/path/here\" )" . to_owned ( ) ,
25
+ applicability,
26
+ ) ;
27
+ }
33
28
} ;
34
29
}
0 commit comments