@@ -96,9 +96,11 @@ fn check_assign(cx: &EarlyContext, expr: &ast::Expr) {
9696 span_note_and_lint ( cx,
9797 SUSPICIOUS_ASSIGNMENT_FORMATTING ,
9898 eqop_span,
99- & format ! ( "this looks like you are trying to use `.. {op}= ..`, but you really are doing `.. = ({op} ..)`" , op=op) ,
99+ & format ! ( "this looks like you are trying to use `.. {op}= ..`, but you \
100+ really are doing `.. = ({op} ..)`",
101+ op = op) ,
100102 eqop_span,
101- & format ! ( "to remove this lint, use either `{op}=` or `= {op}`" , op= op) ) ;
103+ & format ! ( "to remove this lint, use either `{op}=` or `= {op}`" , op = op) ) ;
102104 }
103105 }
104106 }
@@ -109,9 +111,7 @@ fn check_assign(cx: &EarlyContext, expr: &ast::Expr) {
109111/// Implementation of the SUSPICIOUS_ELSE_FORMATTING lint for weird `else if`.
110112fn check_else_if ( cx : & EarlyContext , expr : & ast:: Expr ) {
111113 if let Some ( ( then, & Some ( ref else_) ) ) = unsugar_if ( expr) {
112- if unsugar_if ( else_) . is_some ( ) &&
113- !differing_macro_contexts ( then. span , else_. span ) &&
114- !in_macro ( cx, then. span ) {
114+ if unsugar_if ( else_) . is_some ( ) && !differing_macro_contexts ( then. span , else_. span ) && !in_macro ( cx, then. span ) {
115115 // this will be a span from the closing ‘}’ of the “then” block (excluding) to the
116116 // “if” of the “else if” block (excluding)
117117 let else_span = mk_sp ( then. span . hi , else_. span . lo ) ;
@@ -127,7 +127,8 @@ fn check_else_if(cx: &EarlyContext, expr: &ast::Expr) {
127127 else_span,
128128 "this is an `else if` but the formatting might hide it" ,
129129 else_span,
130- "to remove this lint, remove the `else` or remove the new line between `else` and `if`" ) ;
130+ "to remove this lint, remove the `else` or remove the new line between `else` \
131+ and `if`") ;
131132 }
132133 }
133134 }
@@ -136,10 +137,8 @@ fn check_else_if(cx: &EarlyContext, expr: &ast::Expr) {
136137
137138/// Implementation of the `SUSPICIOUS_ELSE_FORMATTING` lint for consecutive ifs.
138139fn check_consecutive_ifs ( cx : & EarlyContext , first : & ast:: Expr , second : & ast:: Expr ) {
139- if !differing_macro_contexts ( first. span , second. span ) &&
140- !in_macro ( cx, first. span ) &&
141- unsugar_if ( first) . is_some ( ) &&
142- unsugar_if ( second) . is_some ( ) {
140+ if !differing_macro_contexts ( first. span , second. span ) && !in_macro ( cx, first. span ) &&
141+ unsugar_if ( first) . is_some ( ) && unsugar_if ( second) . is_some ( ) {
143142 // where the else would be
144143 let else_span = mk_sp ( first. span . hi , second. span . lo ) ;
145144
@@ -150,14 +149,15 @@ fn check_consecutive_ifs(cx: &EarlyContext, first: &ast::Expr, second: &ast::Exp
150149 else_span,
151150 "this looks like an `else if` but the `else` is missing" ,
152151 else_span,
153- "to remove this lint, add the missing `else` or add a new line before the second `if`" ) ;
152+ "to remove this lint, add the missing `else` or add a new line before the second \
153+ `if`") ;
154154 }
155155 }
156156 }
157157}
158158
159159/// Match `if` or `else if` expressions and return the `then` and `else` block.
160- fn unsugar_if ( expr : & ast:: Expr ) -> Option < ( & P < ast:: Block > , & Option < P < ast:: Expr > > ) > {
160+ fn unsugar_if ( expr : & ast:: Expr ) -> Option < ( & P < ast:: Block > , & Option < P < ast:: Expr > > ) > {
161161 match expr. node {
162162 ast:: ExprKind :: If ( _, ref then, ref else_) |
163163 ast:: ExprKind :: IfLet ( _, _, ref then, ref else_) => Some ( ( then, else_) ) ,
0 commit comments