@@ -66,9 +66,7 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
66
66
}
67
67
68
68
pub fn eq_block ( & mut self , left : & Block < ' _ > , right : & Block < ' _ > ) -> bool {
69
- !self . cannot_be_compared_block ( left)
70
- && !self . cannot_be_compared_block ( right)
71
- && self . inter_expr ( ) . eq_block ( left, right)
69
+ self . inter_expr ( ) . eq_block ( left, right)
72
70
}
73
71
74
72
pub fn eq_expr ( & mut self , left : & Expr < ' _ > , right : & Expr < ' _ > ) -> bool {
@@ -86,38 +84,6 @@ impl<'a, 'tcx> SpanlessEq<'a, 'tcx> {
86
84
pub fn eq_path_segments ( & mut self , left : & [ PathSegment < ' _ > ] , right : & [ PathSegment < ' _ > ] ) -> bool {
87
85
self . inter_expr ( ) . eq_path_segments ( left, right)
88
86
}
89
-
90
- fn cannot_be_compared_block ( & mut self , block : & Block < ' _ > ) -> bool {
91
- if block. stmts . last ( ) . map_or ( false , |stmt| {
92
- matches ! (
93
- stmt. kind,
94
- StmtKind :: Semi ( semi_expr) if self . should_ignore( semi_expr)
95
- )
96
- } ) {
97
- return true ;
98
- }
99
-
100
- if let Some ( block_expr) = block. expr
101
- && self . should_ignore ( block_expr)
102
- {
103
- return true
104
- }
105
-
106
- false
107
- }
108
-
109
- fn should_ignore ( & mut self , expr : & Expr < ' _ > ) -> bool {
110
- if macro_backtrace ( expr. span ) . last ( ) . map_or ( false , |macro_call| {
111
- matches ! (
112
- & self . cx. tcx. get_diagnostic_name( macro_call. def_id) ,
113
- Some ( sym:: todo_macro | sym:: unimplemented_macro)
114
- )
115
- } ) {
116
- return true ;
117
- }
118
-
119
- false
120
- }
121
87
}
122
88
123
89
pub struct HirEqInterExpr < ' a , ' b , ' tcx > {
@@ -156,6 +122,9 @@ impl HirEqInterExpr<'_, '_, '_> {
156
122
157
123
/// Checks whether two blocks are the same.
158
124
fn eq_block ( & mut self , left : & Block < ' _ > , right : & Block < ' _ > ) -> bool {
125
+ if self . cannot_be_compared_block ( left) || self . cannot_be_compared_block ( right) {
126
+ return false ;
127
+ }
159
128
match ( left. stmts , left. expr , right. stmts , right. expr ) {
160
129
( [ ] , None , [ ] , None ) => {
161
130
// For empty blocks, check to see if the tokens are equal. This will catch the case where a macro
@@ -206,6 +175,38 @@ impl HirEqInterExpr<'_, '_, '_> {
206
175
}
207
176
}
208
177
178
+ fn cannot_be_compared_block ( & mut self , block : & Block < ' _ > ) -> bool {
179
+ if block. stmts . last ( ) . map_or ( false , |stmt| {
180
+ matches ! (
181
+ stmt. kind,
182
+ StmtKind :: Semi ( semi_expr) if self . should_ignore( semi_expr)
183
+ )
184
+ } ) {
185
+ return true ;
186
+ }
187
+
188
+ if let Some ( block_expr) = block. expr
189
+ && self . should_ignore ( block_expr)
190
+ {
191
+ return true
192
+ }
193
+
194
+ false
195
+ }
196
+
197
+ fn should_ignore ( & mut self , expr : & Expr < ' _ > ) -> bool {
198
+ if macro_backtrace ( expr. span ) . last ( ) . map_or ( false , |macro_call| {
199
+ matches ! (
200
+ & self . inner. cx. tcx. get_diagnostic_name( macro_call. def_id) ,
201
+ Some ( sym:: todo_macro | sym:: unimplemented_macro)
202
+ )
203
+ } ) {
204
+ return true ;
205
+ }
206
+
207
+ false
208
+ }
209
+
209
210
pub fn eq_array_length ( & mut self , left : ArrayLen , right : ArrayLen ) -> bool {
210
211
match ( left, right) {
211
212
( ArrayLen :: Infer ( ..) , ArrayLen :: Infer ( ..) ) => true ,
0 commit comments