Skip to content

Commit d144fcb

Browse files
committed
don't show the group name for external lints
1 parent 8588f8f commit d144fcb

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

compiler/rustc_middle/src/lint.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,12 +217,19 @@ fn explain_lint_level_source(
217217
src: LintLevelSource,
218218
err: &mut Diag<'_, ()>,
219219
) {
220-
fn lint_group_name(lint: &'static Lint, sess: &Session) -> Option<&'static str> {
220+
fn lint_group_name(
221+
lint: &'static Lint,
222+
sess: &Session,
223+
allow_external: bool,
224+
) -> Option<&'static str> {
221225
let mut lint_groups_iter = sess.lint_groups();
222226
let lint_id = LintId::of(lint);
223227
lint_groups_iter
224228
.find(|lint_group| {
225229
let lints = &lint_group.1;
230+
if !allow_external && lint_group.2 {
231+
return false;
232+
}
226233
lints.iter().find(|lint_group_lint| **lint_group_lint == lint_id).is_some()
227234
})
228235
.map(|lint_group| lint_group.0)
@@ -236,7 +243,7 @@ fn explain_lint_level_source(
236243
match src {
237244
LintLevelSource::Default => {
238245
let level_str = level.as_str();
239-
match lint_group_name(lint, sess) {
246+
match lint_group_name(lint, sess, false) {
240247
Some(group_name) => {
241248
err.note_once(format!("`#[{level_str}({name})]` (part of `#[{level_str}({group_name})]`) on by default"));
242249
}

0 commit comments

Comments
 (0)