]> git.lizzy.rs Git - rust.git/commitdiff
Duplicate lint specifications are always bug!
authorMark Rousskov <mark.simulacrum@gmail.com>
Tue, 24 Sep 2019 00:13:02 +0000 (20:13 -0400)
committerMark Rousskov <mark.simulacrum@gmail.com>
Thu, 17 Oct 2019 23:16:40 +0000 (19:16 -0400)
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.

src/librustc/lint/context.rs

index fa73a3c6c4628bb1ee29573913a7f0a44b4f10d7..002c3f662351450d9e797dfc1093f03a8a05d5e2 100644 (file)
@@ -218,16 +218,7 @@ fn push_pass<P: LintPass + ?Sized + 'static>(&mut self,
 
             let id = LintId::of(lint);
             if self.by_name.insert(lint.name_lower(), Id(id)).is_some() {
-                let msg = format!("duplicate specification of lint {}", lint.name_lower());
-                match (sess, from_plugin) {
-                    // We load builtin lints first, so a duplicate is a compiler bug.
-                    // Use early_error when handling -W help with no crate.
-                    (None, _) => early_error(config::ErrorOutputType::default(), &msg[..]),
-                    (Some(_), false) => bug!("{}", msg),
-
-                    // A duplicate name from a plugin is a user error.
-                    (Some(sess), true)  => sess.err(&msg[..]),
-                }
+                bug!("duplicate specification of lint {}", lint.name_lower())
             }
         }
     }
@@ -300,16 +291,7 @@ pub fn register_group(
         }
 
         if !new {
-            let msg = format!("duplicate specification of lint group {}", name);
-            match (sess, from_plugin) {
-                // We load builtin lints first, so a duplicate is a compiler bug.
-                // Use early_error when handling -W help with no crate.
-                (None, _) => early_error(config::ErrorOutputType::default(), &msg[..]),
-                (Some(_), false) => bug!("{}", msg),
-
-                // A duplicate name from a plugin is a user error.
-                (Some(sess), true)  => sess.err(&msg[..]),
-            }
+            bug!("duplicate specification of lint group {}", name);
         }
     }