@@ -40,7 +40,8 @@ fn main() {
40
40
let status_code = 500 ; // Value doesn't matter for the lint
41
41
let status = Status { code : status_code } ;
42
42
43
- status_code >= 400 && status_code < 500 ; // Correct
43
+ // Correct
44
+ status_code >= 400 && status_code < 500 ;
44
45
status_code <= 400 && status_code > 500 ;
45
46
//~^ ERROR: boolean expression will never evaluate to 'true'
46
47
//~| NOTE: since `400` < `500`, the expression evaluates to false for any value of `st
@@ -80,22 +81,30 @@ fn main() {
80
81
//~| NOTE: `status` cannot simultaneously be greater than and less than `STATUS_SERVER
81
82
82
83
// Yoda conditions
83
- 500 <= status_code && 600 > status_code; // Correct
84
- 500 <= status_code && status_code <= 600 ; // Correct
85
- 500 >= status_code && 600 < status_code; // Incorrect
84
+ // Correct
85
+ 500 <= status_code && 600 > status_code;
86
+ // Correct
87
+ 500 <= status_code && status_code <= 600 ;
88
+ // Incorrect
89
+ 500 >= status_code && 600 < status_code;
86
90
//~^ ERROR: boolean expression will never evaluate to 'true'
87
91
//~| NOTE: since `500` < `600`, the expression evaluates to false for any value of `st
88
- 500 >= status_code && status_code > 600 ; // Incorrect
92
+ // Incorrect
93
+ 500 >= status_code && status_code > 600 ;
89
94
//~^ ERROR: boolean expression will never evaluate to 'true'
90
95
//~| NOTE: since `500` < `600`, the expression evaluates to false for any value of `st
91
96
92
97
// Yoda conditions, comparing two different types
93
- 500 <= status && 600 > status; // Correct
94
- 500 <= status && status <= 600 ; // Correct
95
- 500 >= status && 600 < status; // Incorrect
98
+ // Correct
99
+ 500 <= status && 600 > status;
100
+ // Correct
101
+ 500 <= status && status <= 600 ;
102
+ // Incorrect
103
+ 500 >= status && 600 < status;
96
104
//~^ ERROR: boolean expression will never evaluate to 'true'
97
105
//~| NOTE: since `500` < `600`, the expression evaluates to false for any value of `st
98
- 500 >= status && status > 600 ; // Incorrect
106
+ // Incorrect
107
+ 500 >= status && status > 600 ;
99
108
//~^ ERROR: boolean expression will never evaluate to 'true'
100
109
//~| NOTE: since `500` < `600`, the expression evaluates to false for any value of `st
101
110
@@ -105,13 +114,17 @@ fn main() {
105
114
status_code > 200 && status_code >= 299 ;
106
115
//~^ ERROR: left-hand side of `&&` operator has no effect
107
116
108
- status_code >= 500 && status_code > 500 ; // Useless left
117
+ // Useless left
118
+ status_code >= 500 && status_code > 500 ;
109
119
//~^ ERROR: left-hand side of `&&` operator has no effect
110
- status_code > 500 && status_code >= 500 ; // Useless right
120
+ // Useless right
121
+ status_code > 500 && status_code >= 500 ;
111
122
//~^ ERROR: right-hand side of `&&` operator has no effect
112
- status_code <= 500 && status_code < 500 ; // Useless left
123
+ // Useless left
124
+ status_code <= 500 && status_code < 500 ;
113
125
//~^ ERROR: left-hand side of `&&` operator has no effect
114
- status_code < 500 && status_code <= 500 ; // Useless right
126
+ // Useless right
127
+ status_code < 500 && status_code <= 500 ;
115
128
//~^ ERROR: right-hand side of `&&` operator has no effect
116
129
117
130
// Other types
0 commit comments