Stabilize the compile_error_macro feature
Stabilizes: * `compile_error!` as a macro defined by rustc Closes #40872
This commit is contained in:
@@ -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
|
|
||||||
}
|
|
||||||
```
|
|
||||||
@@ -574,7 +574,7 @@ mod builtin {
|
|||||||
/// For more information, see the [RFC].
|
/// For more information, see the [RFC].
|
||||||
///
|
///
|
||||||
/// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md
|
/// [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_export]
|
||||||
#[cfg(dox)]
|
#[cfg(dox)]
|
||||||
macro_rules! compile_error { ($msg:expr) => ({ /* compiler built-in */ }) }
|
macro_rules! compile_error { ($msg:expr) => ({ /* compiler built-in */ }) }
|
||||||
|
|||||||
@@ -249,7 +249,7 @@ pub mod builtin {
|
|||||||
/// For more information, see the [RFC].
|
/// For more information, see the [RFC].
|
||||||
///
|
///
|
||||||
/// [RFC]: https://github.com/rust-lang/rfcs/blob/master/text/1695-add-error-macro.md
|
/// [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_export]
|
||||||
macro_rules! compile_error { ($msg:expr) => ({ /* compiler built-in */ }) }
|
macro_rules! compile_error { ($msg:expr) => ({ /* compiler built-in */ }) }
|
||||||
|
|
||||||
|
|||||||
@@ -1041,7 +1041,6 @@ impl<'feat> ExpansionConfig<'feat> {
|
|||||||
fn enable_allow_internal_unstable = allow_internal_unstable,
|
fn enable_allow_internal_unstable = allow_internal_unstable,
|
||||||
fn enable_custom_derive = custom_derive,
|
fn enable_custom_derive = custom_derive,
|
||||||
fn proc_macro_enabled = proc_macro,
|
fn proc_macro_enabled = proc_macro,
|
||||||
fn enable_compile_error = compile_error,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,7 +117,6 @@ macro_rules! declare_features {
|
|||||||
|
|
||||||
declare_features! (
|
declare_features! (
|
||||||
(active, asm, "1.0.0", Some(29722)),
|
(active, asm, "1.0.0", Some(29722)),
|
||||||
(active, compile_error, "1.20.0", Some(40872)),
|
|
||||||
(active, concat_idents, "1.0.0", Some(29599)),
|
(active, concat_idents, "1.0.0", Some(29599)),
|
||||||
(active, link_args, "1.0.0", Some(29596)),
|
(active, link_args, "1.0.0", Some(29596)),
|
||||||
(active, log_syntax, "1.0.0", Some(29598)),
|
(active, log_syntax, "1.0.0", Some(29598)),
|
||||||
@@ -445,6 +444,8 @@ declare_features! (
|
|||||||
// Allows the definition of associated constants in `trait` or `impl`
|
// Allows the definition of associated constants in `trait` or `impl`
|
||||||
// blocks.
|
// blocks.
|
||||||
(accepted, associated_consts, "1.20.0", Some(29646)),
|
(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
|
// 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 =
|
pub const EXPLAIN_CONCAT_IDENTS: &'static str =
|
||||||
"`concat_idents` is not stable enough for use and is subject to change";
|
"`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 =
|
pub const EXPLAIN_TRACE_MACROS: &'static str =
|
||||||
"`trace_macros` is not stable enough for use and is subject to change";
|
"`trace_macros` is not stable enough for use and is subject to change";
|
||||||
pub const EXPLAIN_ALLOW_INTERNAL_UNSTABLE: &'static str =
|
pub const EXPLAIN_ALLOW_INTERNAL_UNSTABLE: &'static str =
|
||||||
|
|||||||
@@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
use syntax::ext::base::*;
|
use syntax::ext::base::*;
|
||||||
use syntax::ext::base;
|
use syntax::ext::base;
|
||||||
use syntax::feature_gate;
|
|
||||||
use syntax_pos::Span;
|
use syntax_pos::Span;
|
||||||
use syntax::tokenstream;
|
use syntax::tokenstream;
|
||||||
|
|
||||||
@@ -20,15 +19,6 @@ pub fn expand_compile_error<'cx>(cx: &'cx mut ExtCtxt,
|
|||||||
sp: Span,
|
sp: Span,
|
||||||
tts: &[tokenstream::TokenTree])
|
tts: &[tokenstream::TokenTree])
|
||||||
-> Box<base::MacResult + 'cx> {
|
-> Box<base::MacResult + 'cx> {
|
||||||
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!") {
|
let var = match get_single_str_from_tts(cx, sp, tts, "compile_error!") {
|
||||||
None => return DummyResult::expr(sp),
|
None => return DummyResult::expr(sp),
|
||||||
Some(v) => v,
|
Some(v) => v,
|
||||||
|
|||||||
@@ -8,8 +8,6 @@
|
|||||||
// option. This file may not be copied, modified, or distributed
|
// option. This file may not be copied, modified, or distributed
|
||||||
// except according to those terms.
|
// except according to those terms.
|
||||||
|
|
||||||
#![feature(compile_error)]
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
compile_error!("a very descriptive error message"); //~ ERROR: a very descriptive error message
|
compile_error!("a very descriptive error message"); //~ ERROR: a very descriptive error message
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 <LICENSE-APACHE or
|
|
||||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
|
||||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, 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
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user