about summary refs log tree commit diff
diff options
context:
space:
mode:
authorVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-11-04 00:36:45 +0300
committerVadim Petrochenkov <vadim.petrochenkov@gmail.com>2019-11-09 17:50:51 +0300
commit441e5aed2501de4dcafff8c1e2442ee4145737be (patch)
treead8a31eb1cfc7296066acebba1e15df707360baf
parent3a223a917378f439fd9107e26ee7355f5f92c62d (diff)
downloadrust-441e5aed2501de4dcafff8c1e2442ee4145737be.tar.gz
rust-441e5aed2501de4dcafff8c1e2442ee4145737be.zip
Remove `#[feature(custom_attribute)]`
-rw-r--r--src/librustc/hir/def.rs3
-rw-r--r--src/librustc_plugin/registry.rs1
-rw-r--r--src/librustc_resolve/macros.rs26
-rw-r--r--src/libsyntax/feature_gate/active.rs3
-rw-r--r--src/libsyntax/feature_gate/removed.rs3
-rw-r--r--src/test/ui-fulldeps/issue-15778-pass.rs10
-rw-r--r--src/test/ui-fulldeps/issue-15778-pass.stderr2
-rw-r--r--src/test/ui/feature-gates/feature-gate-custom_attribute2.rs2
-rw-r--r--src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr34
-rw-r--r--src/test/ui/proc-macro/expand-to-unstable-2.rs4
-rw-r--r--src/test/ui/proc-macro/expand-to-unstable-2.stderr2
-rw-r--r--src/test/ui/proc-macro/issue-41211.rs6
-rw-r--r--src/test/ui/proc-macro/issue-41211.stderr19
-rw-r--r--src/test/ui/span/issue-36530.rs4
-rw-r--r--src/test/ui/span/issue-36530.stderr2
15 files changed, 60 insertions, 61 deletions
diff --git a/src/librustc/hir/def.rs b/src/librustc/hir/def.rs
index 486d6dfb095..9eb6baeb4ba 100644
--- a/src/librustc/hir/def.rs
+++ b/src/librustc/hir/def.rs
@@ -44,8 +44,6 @@ pub enum NonMacroAttrKind {
     Registered,
     /// Single-segment custom attribute registered by a legacy plugin (`register_attribute`).
     LegacyPluginHelper,
-    /// Single-segment custom attribute not registered in any way (`#[my_attr]`).
-    Custom,
 }
 
 #[derive(Clone, Copy, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Debug, HashStable)]
@@ -333,7 +331,6 @@ impl NonMacroAttrKind {
             NonMacroAttrKind::DeriveHelper => "derive helper attribute",
             NonMacroAttrKind::Registered => "explicitly registered attribute",
             NonMacroAttrKind::LegacyPluginHelper => "legacy plugin helper attribute",
-            NonMacroAttrKind::Custom => "custom attribute",
         }
     }
 }
diff --git a/src/librustc_plugin/registry.rs b/src/librustc_plugin/registry.rs
index 2e23b8c870c..3f4b87a97c7 100644
--- a/src/librustc_plugin/registry.rs
+++ b/src/librustc_plugin/registry.rs
@@ -101,7 +101,6 @@ impl<'a> Registry<'a> {
 
     /// Register an attribute with an attribute type.
     ///
-    /// Registered attributes will bypass the `custom_attribute` feature gate.
     /// `Whitelisted` attributes will additionally not trigger the `unused_attribute`
     /// lint. `CrateLevel` attributes will not be allowed on anything other than a crate.
     pub fn register_attribute(&mut self, name: Symbol, ty: AttributeType) {
diff --git a/src/librustc_resolve/macros.rs b/src/librustc_resolve/macros.rs
index 9d8d035ab70..1138716d591 100644
--- a/src/librustc_resolve/macros.rs
+++ b/src/librustc_resolve/macros.rs
@@ -732,20 +732,7 @@ impl<'a> Resolver<'a> {
             return Ok(binding);
         }
 
-        let determinacy = Determinacy::determined(determinacy == Determinacy::Determined || force);
-        if determinacy == Determinacy::Determined && macro_kind == Some(MacroKind::Attr) &&
-           self.session.features_untracked().custom_attribute {
-            // For single-segment attributes interpret determinate "no resolution" as a custom
-            // attribute. (Lexical resolution implies the first segment and attr kind should imply
-            // the last segment, so we are certainly working with a single-segment attribute here.)
-            assert!(ns == MacroNS);
-            let binding = (Res::NonMacroAttr(NonMacroAttrKind::Custom),
-                           ty::Visibility::Public, orig_ident.span, ExpnId::root())
-                           .to_name_binding(self.arenas);
-            Ok(binding)
-        } else {
-            Err(determinacy)
-        }
+        Err(Determinacy::determined(determinacy == Determinacy::Determined || force))
     }
 
     crate fn finalize_macro_resolutions(&mut self) {
@@ -756,16 +743,7 @@ impl<'a> Resolver<'a> {
                     // Make sure compilation does not succeed if preferred macro resolution
                     // has changed after the macro had been expanded. In theory all such
                     // situations should be reported as ambiguity errors, so this is a bug.
-                    if initial_res == Res::NonMacroAttr(NonMacroAttrKind::Custom) {
-                        // Yeah, legacy custom attributes are implemented using forced resolution
-                        // (which is a best effort error recovery tool, basically), so we can't
-                        // promise their resolution won't change later.
-                        let msg = format!("inconsistent resolution for a macro: first {}, then {}",
-                                          initial_res.descr(), res.descr());
-                        this.session.span_err(span, &msg);
-                    } else {
-                        span_bug!(span, "inconsistent resolution for a macro");
-                    }
+                    span_bug!(span, "inconsistent resolution for a macro");
                 }
             } else {
                 // It's possible that the macro was unresolved (indeterminate) and silently
diff --git a/src/libsyntax/feature_gate/active.rs b/src/libsyntax/feature_gate/active.rs
index 087a754b27e..319ca5fd3e2 100644
--- a/src/libsyntax/feature_gate/active.rs
+++ b/src/libsyntax/feature_gate/active.rs
@@ -265,9 +265,6 @@ declare_features! (
     /// Allows the use of SIMD types in functions declared in `extern` blocks.
     (active, simd_ffi, "1.0.0", Some(27731), None),
 
-    /// Allows using custom attributes (RFC 572).
-    (active, custom_attribute, "1.0.0", Some(29642), None),
-
     /// Allows using non lexical lifetimes (RFC 2094).
     (active, nll, "1.0.0", Some(43234), None),
 
diff --git a/src/libsyntax/feature_gate/removed.rs b/src/libsyntax/feature_gate/removed.rs
index c7b931a6f70..f0aa74c65df 100644
--- a/src/libsyntax/feature_gate/removed.rs
+++ b/src/libsyntax/feature_gate/removed.rs
@@ -67,6 +67,9 @@ declare_features! (
      Some("merged into `#![feature(slice_patterns)]`")),
     (removed, macro_reexport, "1.0.0", Some(29638), None,
      Some("subsumed by `pub use`")),
+    /// Allows using custom attributes (RFC 572).
+    (removed, custom_attribute, "1.0.0", Some(29642), None,
+     Some("removed in favor of `#![register_tool]` and `#![register_attr]`")),
     (removed, pushpop_unsafe, "1.2.0", None, None, None),
     (removed, needs_allocator, "1.4.0", Some(27389), None,
      Some("subsumed by `#![feature(allocator_internals)]`")),
diff --git a/src/test/ui-fulldeps/issue-15778-pass.rs b/src/test/ui-fulldeps/issue-15778-pass.rs
index b93630d56b0..55f19ab4ee3 100644
--- a/src/test/ui-fulldeps/issue-15778-pass.rs
+++ b/src/test/ui-fulldeps/issue-15778-pass.rs
@@ -3,7 +3,15 @@
 // ignore-stage1
 // compile-flags: -D crate-not-okay
 
-#![feature(plugin, custom_attribute, custom_inner_attributes, rustc_attrs)]
+#![feature(plugin, register_attr, custom_inner_attributes, rustc_attrs)]
+
+#![register_attr(
+    rustc_crate_okay,
+    rustc_crate_blue,
+    rustc_crate_red,
+    rustc_crate_grey,
+    rustc_crate_green,
+)]
 
 #![plugin(lint_for_crate_rpass)]
 #![rustc_crate_okay]
diff --git a/src/test/ui-fulldeps/issue-15778-pass.stderr b/src/test/ui-fulldeps/issue-15778-pass.stderr
index 0c30d2cdcbf..48b42958489 100644
--- a/src/test/ui-fulldeps/issue-15778-pass.stderr
+++ b/src/test/ui-fulldeps/issue-15778-pass.stderr
@@ -1,5 +1,5 @@
 warning: use of deprecated attribute `plugin`: compiler plugins are deprecated. See https://github.com/rust-lang/rust/pull/64675
-  --> $DIR/issue-15778-pass.rs:8:1
+  --> $DIR/issue-15778-pass.rs:16:1
    |
 LL | #![plugin(lint_for_crate_rpass)]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: may be removed in a future compiler version
diff --git a/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs b/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs
index e4c80141aa2..724e53debeb 100644
--- a/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs
+++ b/src/test/ui/feature-gates/feature-gate-custom_attribute2.rs
@@ -1,8 +1,6 @@
 // This test ensures that attributes on formals in generic parameter
 // lists are included when we are checking for unstable attributes.
 
-// gate-test-custom_attribute
-
 struct StLt<#[lt_struct] 'a>(&'a u32);
 //~^ ERROR cannot find attribute `lt_struct` in this scope
 struct StTy<#[ty_struct] I>(I);
diff --git a/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr b/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr
index bc89caddb44..b33710ce049 100644
--- a/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr
+++ b/src/test/ui/feature-gates/feature-gate-custom_attribute2.stderr
@@ -1,101 +1,101 @@
 error: cannot find attribute `lt_hof` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:53:21
+  --> $DIR/feature-gate-custom_attribute2.rs:51:21
    |
 LL |     where Q: for <#[lt_hof] 'i> Fn(&'i [u32]) -> &'i u32
    |                     ^^^^^^
 
 error: cannot find attribute `ty_meth` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:48:15
+  --> $DIR/feature-gate-custom_attribute2.rs:46:15
    |
 LL |     fn m_ty<#[ty_meth] P>(_: P) { }
    |               ^^^^^^^
 
 error: cannot find attribute `lt_meth` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:46:15
+  --> $DIR/feature-gate-custom_attribute2.rs:44:15
    |
 LL |     fn m_lt<#[lt_meth] 'h>(_: &'h [u32]) -> &'h u32 { loop { } }
    |               ^^^^^^^
 
 error: cannot find attribute `ty_fn` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:42:11
+  --> $DIR/feature-gate-custom_attribute2.rs:40:11
    |
 LL | fn f_ty<#[ty_fn] O>(_: O) { }
    |           ^^^^^
 
 error: cannot find attribute `lt_fn` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:40:11
+  --> $DIR/feature-gate-custom_attribute2.rs:38:11
    |
 LL | fn f_lt<#[lt_fn] 'g>(_: &'g [u32]) -> &'g u32 { loop { } }
    |           ^^^^^
 
 error: cannot find attribute `ty_impl_for` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:35:8
+  --> $DIR/feature-gate-custom_attribute2.rs:33:8
    |
 LL | impl<#[ty_impl_for] N> TrTy<N> for StTy<N> {
    |        ^^^^^^^^^^^
 
 error: cannot find attribute `lt_impl_for` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:31:8
+  --> $DIR/feature-gate-custom_attribute2.rs:29:8
    |
 LL | impl<#[lt_impl_for] 'f> TrLt<'f> for StLt<'f> {
    |        ^^^^^^^^^^^
 
 error: cannot find attribute `ty_inherent` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:28:8
+  --> $DIR/feature-gate-custom_attribute2.rs:26:8
    |
 LL | impl<#[ty_inherent] M> StTy<M> { }
    |        ^^^^^^^^^^^
 
 error: cannot find attribute `lt_inherent` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:26:8
+  --> $DIR/feature-gate-custom_attribute2.rs:24:8
    |
 LL | impl<#[lt_inherent] 'e> StLt<'e> { }
    |        ^^^^^^^^^^^
 
 error: cannot find attribute `ty_type` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:23:13
+  --> $DIR/feature-gate-custom_attribute2.rs:21:13
    |
 LL | type TyTy<#[ty_type] L> = (L, );
    |             ^^^^^^^
 
 error: cannot find attribute `lt_type` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:21:13
+  --> $DIR/feature-gate-custom_attribute2.rs:19:13
    |
 LL | type TyLt<#[lt_type] 'd> = &'d u32;
    |             ^^^^^^^
 
 error: cannot find attribute `ty_trait` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:18:14
+  --> $DIR/feature-gate-custom_attribute2.rs:16:14
    |
 LL | trait TrTy<#[ty_trait] K> { fn foo(&self, _: K); }
    |              ^^^^^^^^
 
 error: cannot find attribute `lt_trait` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:16:14
+  --> $DIR/feature-gate-custom_attribute2.rs:14:14
    |
 LL | trait TrLt<#[lt_trait] 'c> { fn foo(&self, _: &'c [u32]) -> &'c u32; }
    |              ^^^^^^^^
 
 error: cannot find attribute `ty_enum` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:13:13
+  --> $DIR/feature-gate-custom_attribute2.rs:11:13
    |
 LL | enum EnTy<#[ty_enum] J> { A(J), B }
    |             ^^^^^^^
 
 error: cannot find attribute `lt_enum` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:11:13
+  --> $DIR/feature-gate-custom_attribute2.rs:9:13
    |
 LL | enum EnLt<#[lt_enum] 'b> { A(&'b u32), B }
    |             ^^^^^^^
 
 error: cannot find attribute `ty_struct` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:8:15
+  --> $DIR/feature-gate-custom_attribute2.rs:6:15
    |
 LL | struct StTy<#[ty_struct] I>(I);
    |               ^^^^^^^^^
 
 error: cannot find attribute `lt_struct` in this scope
-  --> $DIR/feature-gate-custom_attribute2.rs:6:15
+  --> $DIR/feature-gate-custom_attribute2.rs:4:15
    |
 LL | struct StLt<#[lt_struct] 'a>(&'a u32);
    |               ^^^^^^^^^
diff --git a/src/test/ui/proc-macro/expand-to-unstable-2.rs b/src/test/ui/proc-macro/expand-to-unstable-2.rs
index da7c89fdd46..4160e5418b7 100644
--- a/src/test/ui/proc-macro/expand-to-unstable-2.rs
+++ b/src/test/ui/proc-macro/expand-to-unstable-2.rs
@@ -1,6 +1,8 @@
 // aux-build:derive-unstable-2.rs
 
-#![feature(custom_attribute)]
+#![feature(register_attr)]
+
+#![register_attr(rustc_foo)]
 
 #[macro_use]
 extern crate derive_unstable_2;
diff --git a/src/test/ui/proc-macro/expand-to-unstable-2.stderr b/src/test/ui/proc-macro/expand-to-unstable-2.stderr
index 01e6a4a8ab9..5b6184afacd 100644
--- a/src/test/ui/proc-macro/expand-to-unstable-2.stderr
+++ b/src/test/ui/proc-macro/expand-to-unstable-2.stderr
@@ -1,5 +1,5 @@
 error[E0658]: attributes starting with `rustc` are reserved for use by the `rustc` compiler
-  --> $DIR/expand-to-unstable-2.rs:8:10
+  --> $DIR/expand-to-unstable-2.rs:10:10
    |
 LL | #[derive(Unstable)]
    |          ^^^^^^^^
diff --git a/src/test/ui/proc-macro/issue-41211.rs b/src/test/ui/proc-macro/issue-41211.rs
index 491b89b2f55..072a63baf3a 100644
--- a/src/test/ui/proc-macro/issue-41211.rs
+++ b/src/test/ui/proc-macro/issue-41211.rs
@@ -3,11 +3,13 @@
 // FIXME: https://github.com/rust-lang/rust/issues/41430
 // This is a temporary regression test for the ICE reported in #41211
 
-#![feature(custom_attribute)]
 #![feature(custom_inner_attributes)]
+#![feature(register_attr)]
+
+#![register_attr(identity_attr)]
 
 #![identity_attr]
-//~^ ERROR inconsistent resolution for a macro: first custom attribute, then attribute macro
+//~^ ERROR `identity_attr` is ambiguous
 extern crate test_macros;
 use test_macros::identity_attr;
 
diff --git a/src/test/ui/proc-macro/issue-41211.stderr b/src/test/ui/proc-macro/issue-41211.stderr
index f01cba0c930..22ad4aa147b 100644
--- a/src/test/ui/proc-macro/issue-41211.stderr
+++ b/src/test/ui/proc-macro/issue-41211.stderr
@@ -1,8 +1,21 @@
-error: inconsistent resolution for a macro: first custom attribute, then attribute macro
-  --> $DIR/issue-41211.rs:9:4
+error[E0659]: `identity_attr` is ambiguous (macro-expanded name vs less macro-expanded name from outer scope during import/macro resolution)
+  --> $DIR/issue-41211.rs:11:4
    |
 LL | #![identity_attr]
-   |    ^^^^^^^^^^^^^
+   |    ^^^^^^^^^^^^^ ambiguous name
+   |
+note: `identity_attr` could refer to the attribute macro imported here
+  --> $DIR/issue-41211.rs:14:5
+   |
+LL | use test_macros::identity_attr;
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = help: use `crate::identity_attr` to refer to this attribute macro unambiguously
+note: `identity_attr` could also refer to the explicitly registered attribute defined here
+  --> $DIR/issue-41211.rs:9:18
+   |
+LL | #![register_attr(identity_attr)]
+   |                  ^^^^^^^^^^^^^
 
 error: aborting due to previous error
 
+For more information about this error, try `rustc --explain E0659`.
diff --git a/src/test/ui/span/issue-36530.rs b/src/test/ui/span/issue-36530.rs
index 14b2c8644e0..4776740d8de 100644
--- a/src/test/ui/span/issue-36530.rs
+++ b/src/test/ui/span/issue-36530.rs
@@ -1,6 +1,8 @@
 // gate-test-custom_inner_attributes
 
-#![feature(custom_attribute)]
+#![feature(register_attr)]
+
+#![register_attr(foo)]
 
 #[foo]
 mod foo {
diff --git a/src/test/ui/span/issue-36530.stderr b/src/test/ui/span/issue-36530.stderr
index c6b7895e65a..2d3972917df 100644
--- a/src/test/ui/span/issue-36530.stderr
+++ b/src/test/ui/span/issue-36530.stderr
@@ -1,5 +1,5 @@
 error[E0658]: non-builtin inner attributes are unstable
-  --> $DIR/issue-36530.rs:7:5
+  --> $DIR/issue-36530.rs:9:5
    |
 LL |     #![foo]
    |     ^^^^^^^