about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorMark Mansi <markm@cs.wisc.edu>2019-03-28 12:36:13 -0500
committerMark Mansi <markm@cs.wisc.edu>2019-04-10 21:29:17 -0500
commitd7f5c50a335204e00565c978f5eb7fac40468f96 (patch)
tree15d27ac1f1f231c95a2af63e82bd82fca50a4953 /src
parent96d700f1b7bc9c53fa0d11567adb1ed2c1c27e79 (diff)
downloadrust-d7f5c50a335204e00565c978f5eb7fac40468f96.tar.gz
rust-d7f5c50a335204e00565c978f5eb7fac40468f96.zip
make duplicate matcher bindings a hard error
Diffstat (limited to 'src')
-rw-r--r--src/librustc/lint/builtin.rs6
-rw-r--r--src/librustc/lint/mod.rs3
-rw-r--r--src/librustc_lint/lib.rs7
-rw-r--r--src/libsyntax/early_buffered_lints.rs2
-rw-r--r--src/libsyntax/ext/tt/macro_rules.rs16
-rw-r--r--src/test/ui/macros/macro-multiple-matcher-bindings.rs12
-rw-r--r--src/test/ui/macros/macro-multiple-matcher-bindings.stderr57
7 files changed, 44 insertions, 59 deletions
diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs
index cbdeda7b902..bfb0b3e4a6b 100644
--- a/src/librustc/lint/builtin.rs
+++ b/src/librustc/lint/builtin.rs
@@ -352,12 +352,6 @@ declare_lint! {
     "outlives requirements can be inferred"
 }
 
-declare_lint! {
-    pub DUPLICATE_MATCHER_BINDING_NAME,
-    Deny,
-    "duplicate macro matcher binding name"
-}
-
 /// Some lints that are buffered from `libsyntax`. See `syntax::early_buffered_lints`.
 pub mod parser {
     declare_lint! {
diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs
index 5ebb915d57f..112c247d4d6 100644
--- a/src/librustc/lint/mod.rs
+++ b/src/librustc/lint/mod.rs
@@ -26,7 +26,7 @@ use rustc_data_structures::sync::{self, Lrc};
 use crate::hir::def_id::{CrateNum, LOCAL_CRATE};
 use crate::hir::intravisit;
 use crate::hir;
-use crate::lint::builtin::{BuiltinLintDiagnostics, DUPLICATE_MATCHER_BINDING_NAME};
+use crate::lint::builtin::BuiltinLintDiagnostics;
 use crate::lint::builtin::parser::{QUESTION_MARK_MACRO_SEP, ILL_FORMED_ATTRIBUTE_INPUT};
 use crate::session::{Session, DiagnosticMessageId};
 use crate::ty::TyCtxt;
@@ -82,7 +82,6 @@ impl Lint {
         match lint_id {
             BufferedEarlyLintId::QuestionMarkMacroSep => QUESTION_MARK_MACRO_SEP,
             BufferedEarlyLintId::IllFormedAttributeInput => ILL_FORMED_ATTRIBUTE_INPUT,
-            BufferedEarlyLintId::DuplicateMacroMatcherBindingName => DUPLICATE_MATCHER_BINDING_NAME,
         }
     }
 
diff --git a/src/librustc_lint/lib.rs b/src/librustc_lint/lib.rs
index 07c505c6bde..4a2d6dc68ae 100644
--- a/src/librustc_lint/lib.rs
+++ b/src/librustc_lint/lib.rs
@@ -429,11 +429,6 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
             edition: None,
         },
         FutureIncompatibleInfo {
-            id: LintId::of(DUPLICATE_MATCHER_BINDING_NAME),
-            reference: "issue #57593 <https://github.com/rust-lang/rust/issues/57593>",
-            edition: None,
-        },
-        FutureIncompatibleInfo {
             id: LintId::of(NESTED_IMPL_TRAIT),
             reference: "issue #59014 <https://github.com/rust-lang/rust/issues/59014>",
             edition: None,
@@ -494,6 +489,8 @@ pub fn register_builtins(store: &mut lint::LintStore, sess: Option<&Session>) {
         "no longer a warning, #[no_mangle] statics always exported");
     store.register_removed("bad_repr",
         "replaced with a generic attribute input check");
+    store.register_removed("duplicate_matcher_binding_name",
+        "converted into hard error, see https://github.com/rust-lang/rust/issues/57742");
 }
 
 pub fn register_internals(store: &mut lint::LintStore, sess: Option<&Session>) {
diff --git a/src/libsyntax/early_buffered_lints.rs b/src/libsyntax/early_buffered_lints.rs
index 29cb9cd7f30..977e6d45877 100644
--- a/src/libsyntax/early_buffered_lints.rs
+++ b/src/libsyntax/early_buffered_lints.rs
@@ -12,8 +12,6 @@ pub enum BufferedEarlyLintId {
     /// Usage of `?` as a macro separator is deprecated.
     QuestionMarkMacroSep,
     IllFormedAttributeInput,
-    /// Usage of a duplicate macro matcher binding name.
-    DuplicateMacroMatcherBindingName,
 }
 
 /// Stores buffered lint info which can later be passed to `librustc`.
diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs
index 12912044e4e..b1b9d25b3d5 100644
--- a/src/libsyntax/ext/tt/macro_rules.rs
+++ b/src/libsyntax/ext/tt/macro_rules.rs
@@ -497,22 +497,14 @@ fn check_lhs_duplicate_matcher_bindings(
     node_id: ast::NodeId,
 ) -> bool {
     use self::quoted::TokenTree;
-    use crate::early_buffered_lints::BufferedEarlyLintId;
     for tt in tts {
         match *tt {
             TokenTree::MetaVarDecl(span, name, _kind) => {
                 if let Some(&prev_span) = metavar_names.get(&name) {
-                    // FIXME(mark-i-m): in a few cycles, make this a hard error.
-                    // sess.span_diagnostic
-                    //     .struct_span_err(span, "duplicate matcher binding")
-                    //     .span_note(prev_span, "previous declaration was here")
-                    //     .emit();
-                    sess.buffer_lint(
-                        BufferedEarlyLintId::DuplicateMacroMatcherBindingName,
-                        crate::source_map::MultiSpan::from(vec![prev_span, span]),
-                        node_id,
-                        "duplicate matcher binding"
-                    );
+                    sess.span_diagnostic
+                        .struct_span_err(span, "duplicate matcher binding")
+                        .span_note(prev_span, "previous declaration was here")
+                        .emit();
                     return false;
                 } else {
                     metavar_names.insert(name, span);
diff --git a/src/test/ui/macros/macro-multiple-matcher-bindings.rs b/src/test/ui/macros/macro-multiple-matcher-bindings.rs
index 23d566780c8..f31af2365ff 100644
--- a/src/test/ui/macros/macro-multiple-matcher-bindings.rs
+++ b/src/test/ui/macros/macro-multiple-matcher-bindings.rs
@@ -1,16 +1,12 @@
 // Test that duplicate matcher binding names are caught at declaration time, rather than at macro
 // invocation time.
-//
-// FIXME(mark-i-m): Update this when it becomes a hard error.
-
-// compile-pass
 
 #![allow(unused_macros)]
 #![warn(duplicate_matcher_binding_name)]
 
 macro_rules! foo1 {
-    ($a:ident, $a:ident) => {}; //~WARNING duplicate matcher binding
-    ($a:ident, $a:path) => {};  //~WARNING duplicate matcher binding
+    ($a:ident, $a:ident) => {}; //~ERROR duplicate matcher binding
+    ($a:ident, $a:path) => {};  //~ERROR duplicate matcher binding
 }
 
 macro_rules! foo2 {
@@ -19,8 +15,8 @@ macro_rules! foo2 {
 }
 
 macro_rules! foo3 {
-    ($a:ident, $($a:ident),*) => {}; //~WARNING duplicate matcher binding
-    ($($a:ident)+ # $($($a:path),+);*) => {}; //~WARNING duplicate matcher binding
+    ($a:ident, $($a:ident),*) => {}; //~ERROR duplicate matcher binding
+    ($($a:ident)+ # $($($a:path),+);*) => {}; //~ERROR duplicate matcher binding
 }
 
 fn main() {}
diff --git a/src/test/ui/macros/macro-multiple-matcher-bindings.stderr b/src/test/ui/macros/macro-multiple-matcher-bindings.stderr
index f7970dbd2eb..65362388d7d 100644
--- a/src/test/ui/macros/macro-multiple-matcher-bindings.stderr
+++ b/src/test/ui/macros/macro-multiple-matcher-bindings.stderr
@@ -1,41 +1,50 @@
-warning: duplicate matcher binding
-  --> $DIR/macro-multiple-matcher-bindings.rs:12:6
+error: duplicate matcher binding
+  --> $DIR/macro-multiple-matcher-bindings.rs:7:16
    |
 LL |     ($a:ident, $a:ident) => {};
-   |      ^^^^^^^^  ^^^^^^^^
+   |                ^^^^^^^^
    |
-note: lint level defined here
-  --> $DIR/macro-multiple-matcher-bindings.rs:9:9
+note: previous declaration was here
+  --> $DIR/macro-multiple-matcher-bindings.rs:7:6
    |
-LL | #![warn(duplicate_matcher_binding_name)]
-   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-   = note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/57593>
+LL |     ($a:ident, $a:ident) => {};
+   |      ^^^^^^^^
 
-warning: duplicate matcher binding
-  --> $DIR/macro-multiple-matcher-bindings.rs:13:6
+error: duplicate matcher binding
+  --> $DIR/macro-multiple-matcher-bindings.rs:8:16
    |
 LL |     ($a:ident, $a:path) => {};
-   |      ^^^^^^^^  ^^^^^^^
+   |                ^^^^^^^
+   |
+note: previous declaration was here
+  --> $DIR/macro-multiple-matcher-bindings.rs:8:6
    |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-   = note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/57593>
+LL |     ($a:ident, $a:path) => {};
+   |      ^^^^^^^^
 
-warning: duplicate matcher binding
-  --> $DIR/macro-multiple-matcher-bindings.rs:22:6
+error: duplicate matcher binding
+  --> $DIR/macro-multiple-matcher-bindings.rs:17:18
    |
 LL |     ($a:ident, $($a:ident),*) => {};
-   |      ^^^^^^^^    ^^^^^^^^
+   |                  ^^^^^^^^
+   |
+note: previous declaration was here
+  --> $DIR/macro-multiple-matcher-bindings.rs:17:6
    |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-   = note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/57593>
+LL |     ($a:ident, $($a:ident),*) => {};
+   |      ^^^^^^^^
 
-warning: duplicate matcher binding
-  --> $DIR/macro-multiple-matcher-bindings.rs:23:8
+error: duplicate matcher binding
+  --> $DIR/macro-multiple-matcher-bindings.rs:18:25
    |
 LL |     ($($a:ident)+ # $($($a:path),+);*) => {};
-   |        ^^^^^^^^         ^^^^^^^
+   |                         ^^^^^^^
+   |
+note: previous declaration was here
+  --> $DIR/macro-multiple-matcher-bindings.rs:18:8
    |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-   = note: for more information, see issue #57593 <https://github.com/rust-lang/rust/issues/57593>
+LL |     ($($a:ident)+ # $($($a:path),+);*) => {};
+   |        ^^^^^^^^
+
+error: aborting due to 4 previous errors