Skip to content

Commit 47a443c

Browse files
Duplicate lint specifications are always bug!
Replace early_error and sess.err with bug!, in all cases. If the compiler we're running with, including plugins, is registering something twice, that's a (compiler/plugin) programmer error -- we should not try to be nice at the cost of developer ergononomics (hiding the stacktrace of the second registration is bad). This also is basically a static bug in ~all cases so it should not be a detriment to users, including with plugins.
1 parent fa0f7d0 commit 47a443c

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

src/librustc/lint/context.rs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -218,16 +218,7 @@ impl LintStore {
218218

219219
let id = LintId::of(lint);
220220
if self.by_name.insert(lint.name_lower(), Id(id)).is_some() {
221-
let msg = format!("duplicate specification of lint {}", lint.name_lower());
222-
match (sess, from_plugin) {
223-
// We load builtin lints first, so a duplicate is a compiler bug.
224-
// Use early_error when handling -W help with no crate.
225-
(None, _) => early_error(config::ErrorOutputType::default(), &msg[..]),
226-
(Some(_), false) => bug!("{}", msg),
227-
228-
// A duplicate name from a plugin is a user error.
229-
(Some(sess), true) => sess.err(&msg[..]),
230-
}
221+
bug!("duplicate specification of lint {}", lint.name_lower())
231222
}
232223
}
233224
}
@@ -300,16 +291,7 @@ impl LintStore {
300291
}
301292

302293
if !new {
303-
let msg = format!("duplicate specification of lint group {}", name);
304-
match (sess, from_plugin) {
305-
// We load builtin lints first, so a duplicate is a compiler bug.
306-
// Use early_error when handling -W help with no crate.
307-
(None, _) => early_error(config::ErrorOutputType::default(), &msg[..]),
308-
(Some(_), false) => bug!("{}", msg),
309-
310-
// A duplicate name from a plugin is a user error.
311-
(Some(sess), true) => sess.err(&msg[..]),
312-
}
294+
bug!("duplicate specification of lint group {}", name);
313295
}
314296
}
315297

0 commit comments

Comments
 (0)