From 20b4f86d13b177bf66d1fa4fefbfcc1bb552cb94 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 20 Jul 2017 15:50:33 -0700 Subject: [PATCH] Stabilize the `compile_error_macro` feature Stabilizes: * `compile_error!` as a macro defined by rustc Closes #40872 --- .../src/language-features/compile-error.md | 20 ------------------- src/libcore/macros.rs | 2 +- src/libstd/macros.rs | 2 +- src/libsyntax/ext/expand.rs | 1 - src/libsyntax/feature_gate.rs | 6 ++---- src/libsyntax_ext/compile_error.rs | 10 ---------- src/test/compile-fail/compile_error_macro.rs | 2 -- .../feature-gate-compile_error.rs | 13 ------------ 8 files changed, 4 insertions(+), 52 deletions(-) delete mode 100644 src/doc/unstable-book/src/language-features/compile-error.md delete mode 100644 src/test/compile-fail/feature-gate-compile_error.rs diff --git a/src/doc/unstable-book/src/language-features/compile-error.md b/src/doc/unstable-book/src/language-features/compile-error.md deleted file mode 100644 index 4de631e1fb30..000000000000 --- a/src/doc/unstable-book/src/language-features/compile-error.md +++ /dev/null @@ -1,20 +0,0 @@ -# `compile_error` - -The tracking issue for this feature is: [#40872] - -[#40872]: https://github.com/rust-lang/rust/issues/40872 - ------------------------- - -The `compile_error` feature adds a macro which will generate a compilation -error with the specified error message. - -## Examples - -```rust,compile_fail -#![feature(compile_error)] - -fn main() { - compile_error!("The error message"); //ERROR The error message -} -``` diff --git a/src/libcore/macros.rs b/src/libcore/macros.rs index ae74016ad744..2edf8e1fa886 100644 --- a/src/libcore/macros.rs +++ b/src/libcore/macros.rs @@ -574,7 +574,7 @@ mod builtin { /// For more information, see the [RFC]. /// /// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md - #[unstable(feature = "compile_error_macro", issue = "40872")] + #[stable(feature = "compile_error_macro", since = "1.20.0")] #[macro_export] #[cfg(dox)] macro_rules! compile_error { ($msg:expr) => ({ /* compiler built-in */ }) } diff --git a/src/libstd/macros.rs b/src/libstd/macros.rs index 6ad22820a7d9..343c499b3ff7 100644 --- a/src/libstd/macros.rs +++ b/src/libstd/macros.rs @@ -249,7 +249,7 @@ pub mod builtin { /// For more information, see the [RFC]. /// /// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md - #[unstable(feature = "compile_error_macro", issue = "40872")] + #[stable(feature = "compile_error_macro", since = "1.20.0")] #[macro_export] macro_rules! compile_error { ($msg:expr) => ({ /* compiler built-in */ }) } diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index dc0848176d6c..f6d56557166d 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -1041,7 +1041,6 @@ impl<'feat> ExpansionConfig<'feat> { fn enable_allow_internal_unstable = allow_internal_unstable, fn enable_custom_derive = custom_derive, fn proc_macro_enabled = proc_macro, - fn enable_compile_error = compile_error, } } diff --git a/src/libsyntax/feature_gate.rs b/src/libsyntax/feature_gate.rs index 448f95c93a08..e8de8cf41c97 100644 --- a/src/libsyntax/feature_gate.rs +++ b/src/libsyntax/feature_gate.rs @@ -117,7 +117,6 @@ macro_rules! declare_features { declare_features! ( (active, asm, "1.0.0", Some(29722)), - (active, compile_error, "1.20.0", Some(40872)), (active, concat_idents, "1.0.0", Some(29599)), (active, link_args, "1.0.0", Some(29596)), (active, log_syntax, "1.0.0", Some(29598)), @@ -445,6 +444,8 @@ declare_features! ( // Allows the definition of associated constants in `trait` or `impl` // blocks. (accepted, associated_consts, "1.20.0", Some(29646)), + // Usage of the `compile_error!` macro + (accepted, compile_error, "1.20.0", Some(40872)), ); // If you change this, please modify src/doc/unstable-book as well. You must @@ -1040,9 +1041,6 @@ pub const EXPLAIN_LOG_SYNTAX: &'static str = pub const EXPLAIN_CONCAT_IDENTS: &'static str = "`concat_idents` is not stable enough for use and is subject to change"; -pub const EXPLAIN_COMPILE_ERROR: &'static str = - "`compile_error` is not stable enough for use and is subject to change"; - pub const EXPLAIN_TRACE_MACROS: &'static str = "`trace_macros` is not stable enough for use and is subject to change"; pub const EXPLAIN_ALLOW_INTERNAL_UNSTABLE: &'static str = diff --git a/src/libsyntax_ext/compile_error.rs b/src/libsyntax_ext/compile_error.rs index bb496716d8c4..7bc7afba63cb 100644 --- a/src/libsyntax_ext/compile_error.rs +++ b/src/libsyntax_ext/compile_error.rs @@ -12,7 +12,6 @@ use syntax::ext::base::*; use syntax::ext::base; -use syntax::feature_gate; use syntax_pos::Span; use syntax::tokenstream; @@ -20,15 +19,6 @@ pub fn expand_compile_error<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[tokenstream::TokenTree]) -> Box { - if !cx.ecfg.enable_compile_error() { - feature_gate::emit_feature_err(&cx.parse_sess, - "compile_error", - sp, - feature_gate::GateIssue::Language, - feature_gate::EXPLAIN_COMPILE_ERROR); - return DummyResult::expr(sp); - } - let var = match get_single_str_from_tts(cx, sp, tts, "compile_error!") { None => return DummyResult::expr(sp), Some(v) => v, diff --git a/src/test/compile-fail/compile_error_macro.rs b/src/test/compile-fail/compile_error_macro.rs index 2a2c3fd80923..e9c5993098c3 100644 --- a/src/test/compile-fail/compile_error_macro.rs +++ b/src/test/compile-fail/compile_error_macro.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![feature(compile_error)] - fn main() { compile_error!("a very descriptive error message"); //~ ERROR: a very descriptive error message } diff --git a/src/test/compile-fail/feature-gate-compile_error.rs b/src/test/compile-fail/feature-gate-compile_error.rs deleted file mode 100644 index 545c6852961c..000000000000 --- a/src/test/compile-fail/feature-gate-compile_error.rs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2017 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -fn main() { - compile_error!("test"); //~ ERROR: `compile_error` is not stable enough -}