@@ -217,28 +217,22 @@ fn explain_lint_level_source(
217
217
src : LintLevelSource ,
218
218
err : & mut Diag < ' _ , ( ) > ,
219
219
) {
220
- /// Find the name of the lint group that contains the given lint.
221
- /// Assumes the lint only belongs to one group.
222
- fn lint_group_name (
223
- lint : & ' static Lint ,
224
- sess : & Session ,
225
- allow_external : bool ,
226
- ) -> Option < & ' static str > {
227
- let mut lint_groups_iter = sess. lint_groups_iter ( ) ;
220
+ // Find the name of the lint group that contains the given lint.
221
+ // Assumes the lint only belongs to one group.
222
+ let lint_group_name = |lint| {
223
+ let lint_groups_iter = sess. lint_groups_iter ( ) ;
228
224
let lint_id = LintId :: of ( lint) ;
229
225
lint_groups_iter
226
+ . filter ( |lint_group| !lint_group. is_externally_loaded )
230
227
. find ( |lint_group| {
231
- if !allow_external && lint_group. is_externally_loaded {
232
- return false ;
233
- }
234
228
lint_group
235
229
. lints
236
230
. iter ( )
237
231
. find ( |lint_group_lint| * * lint_group_lint == lint_id)
238
232
. is_some ( )
239
233
} )
240
234
. map ( |lint_group| lint_group. name )
241
- }
235
+ } ;
242
236
let name = lint. name_lower ( ) ;
243
237
if let Level :: Allow = level {
244
238
// Do not point at `#[allow(compat_lint)]` as the reason for a compatibility lint
@@ -248,7 +242,7 @@ fn explain_lint_level_source(
248
242
match src {
249
243
LintLevelSource :: Default => {
250
244
let level_str = level. as_str ( ) ;
251
- match lint_group_name ( lint, sess , false ) {
245
+ match lint_group_name ( lint) {
252
246
Some ( group_name) => {
253
247
err. note_once ( format ! ( "`#[{level_str}({name})]` (part of `#[{level_str}({group_name})]`) on by default" ) ) ;
254
248
}
0 commit comments