@@ -134,13 +134,28 @@ impl<'tcx> LateLintPass<'tcx> for BorrowOfReborrowable {
134
134
#[ derive( Debug ) ]
135
135
enum Reborrowable {
136
136
Commands ,
137
+ // Deferred,
138
+ // DeferredWorld,
139
+ EntityCommands ,
140
+ // EntityMut,
141
+ // EntityMutExcept,
142
+ // FilteredEntityMut,
143
+ // FilteredResourcesMut,
144
+ // Mut,
145
+ // MutUntyped,
146
+ // NonSendMut,
147
+ // PtrMut,
137
148
Query ,
149
+ // QueryIterationCursor,
150
+ // ResMut,
138
151
}
139
152
140
153
impl Reborrowable {
141
154
fn try_from_ty < ' tcx > ( cx : & LateContext < ' tcx > , ty : Ty < ' tcx > ) -> Option < Self > {
142
155
if match_type ( cx, ty, & crate :: paths:: COMMANDS ) {
143
156
Some ( Self :: Commands )
157
+ } else if match_type ( cx, ty, & crate :: paths:: ENTITY_COMMANDS ) {
158
+ Some ( Self :: EntityCommands )
144
159
} else if match_type ( cx, ty, & crate :: paths:: QUERY ) {
145
160
Some ( Self :: Query )
146
161
} else {
@@ -151,30 +166,31 @@ impl Reborrowable {
151
166
fn lint ( & self ) -> & ' static Lint {
152
167
match self {
153
168
Self :: Commands => BORROW_OF_COMMANDS . lint ,
169
+ Self :: EntityCommands => BORROW_OF_COMMANDS . lint ,
154
170
Self :: Query => BORROW_OF_QUERY . lint ,
155
171
}
156
172
}
157
173
158
- fn message ( & self ) -> & ' static str {
159
- match self {
160
- Self :: Commands => BORROW_OF_COMMANDS . lint . desc ,
161
- Self :: Query => BORROW_OF_QUERY . lint . desc ,
162
- }
174
+ fn message ( & self ) -> String {
175
+ let name = self . name ( ) ;
176
+ format ! ( "parameter takes `&mut {name}` instead of a re-borrowed `{name}`" , )
163
177
}
164
178
165
179
fn name ( & self ) -> & ' static str {
166
180
match self {
167
181
Self :: Commands => "Commands" ,
182
+ Self :: EntityCommands => "EntityCommands" ,
168
183
Self :: Query => "Query" ,
169
184
}
170
185
}
171
186
172
187
fn help ( & self ) -> String {
173
- format ! ( "use `{}` instead" , self . name( ) )
188
+ let name = self . name ( ) ;
189
+ format ! ( "use `{name}` instead" )
174
190
}
175
191
176
192
fn suggest ( & self , ident : Ident , ty : String ) -> String {
177
- format ! ( "mut {}: {}" , ident , ty )
193
+ format ! ( "mut {ident }: {ty}" )
178
194
}
179
195
}
180
196
0 commit comments