@@ -217,28 +217,22 @@ fn explain_lint_level_source(
217217 src : LintLevelSource ,
218218 err : & mut Diag < ' _ , ( ) > ,
219219) {
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 ( ) ;
228224 let lint_id = LintId :: of ( lint) ;
229225 lint_groups_iter
226+ . filter ( |lint_group| !lint_group. is_externally_loaded )
230227 . find ( |lint_group| {
231- if !allow_external && lint_group. is_externally_loaded {
232- return false ;
233- }
234228 lint_group
235229 . lints
236230 . iter ( )
237231 . find ( |lint_group_lint| * * lint_group_lint == lint_id)
238232 . is_some ( )
239233 } )
240234 . map ( |lint_group| lint_group. name )
241- }
235+ } ;
242236 let name = lint. name_lower ( ) ;
243237 if let Level :: Allow = level {
244238 // Do not point at `#[allow(compat_lint)]` as the reason for a compatibility lint
@@ -248,7 +242,7 @@ fn explain_lint_level_source(
248242 match src {
249243 LintLevelSource :: Default => {
250244 let level_str = level. as_str ( ) ;
251- match lint_group_name ( lint, sess , false ) {
245+ match lint_group_name ( lint) {
252246 Some ( group_name) => {
253247 err. note_once ( format ! ( "`#[{level_str}({name})]` (part of `#[{level_str}({group_name})]`) on by default" ) ) ;
254248 }
0 commit comments