Rollup merge of #62869 - matklad:feature-gate, r=Mark-Simulacrum

add rustc_private as a proper language feature gate

At the moment, `rustc_private` as a (library) feature exists by
accident: `char::is_xid_start`, `char::is_xid_continue` methods in
libcore define it.

cc https://rust-lang.zulipchat.com/#narrow/stream/131828-t-compiler/topic/How.20to.20declare.20new.20langauge.20feature.3F

I don't know if this is at all reasonable, but at least tests seem to pass locally. That probably means that we can remove/rename to something more resonable the feature in libcore in the next release?
This commit is contained in:
Mark Rousskov 2019-07-23 12:51:18 -04:00 committed by GitHub
commit f11ffd3a6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 36 additions and 9 deletions

View File

@ -553,10 +553,12 @@ impl char {
/// 'XID_Start' is a Unicode Derived Property specified in
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
/// mostly similar to `ID_Start` but modified for closure under `NFKx`.
#[unstable(feature = "rustc_private",
reason = "mainly needed for compiler internals",
issue = "27812")]
#[inline]
#[cfg_attr(bootstrap,
unstable(feature = "rustc_private",
reason = "mainly needed for compiler internals",
issue = "27812"))]
#[cfg_attr(not(bootstrap),
unstable(feature = "unicode_internals", issue = "0"))]
pub fn is_xid_start(self) -> bool {
derived_property::XID_Start(self)
}
@ -567,9 +569,12 @@ impl char {
/// 'XID_Continue' is a Unicode Derived Property specified in
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
/// mostly similar to 'ID_Continue' but modified for closure under NFKx.
#[unstable(feature = "rustc_private",
reason = "mainly needed for compiler internals",
issue = "27812")]
#[cfg_attr(bootstrap,
unstable(feature = "rustc_private",
reason = "mainly needed for compiler internals",
issue = "27812"))]
#[cfg_attr(not(bootstrap),
unstable(feature = "unicode_internals", issue = "0"))]
#[inline]
pub fn is_xid_continue(self) -> bool {
derived_property::XID_Continue(self)

View File

@ -13,6 +13,7 @@
#![feature(nll)]
#![feature(rustc_private)]
#![feature(unicode_internals)]
pub use Piece::*;
pub use Position::*;

View File

@ -1,6 +1,5 @@
// We want to be able to build this crate with a stable compiler, so feature
// flags should optional.
#![cfg_attr(not(feature = "unicode-xid"), feature(rustc_private))]
// flags should be optional.
#![cfg_attr(not(feature = "unicode-xid"), feature(unicode_internals))]
mod cursor;

View File

@ -21,6 +21,7 @@
#![feature(inner_deref)]
#![feature(never_type)]
#![feature(mem_take)]
#![feature(unicode_internals)]
#![recursion_limit="256"]

View File

@ -126,6 +126,9 @@ declare_features! (
// no-tracking-issue-start
// Allows using compiler's own crates.
(active, rustc_private, "1.0.0", Some(27812), None),
// Allows using the `rust-intrinsic`'s "ABI".
(active, intrinsics, "1.0.0", None, None),

View File

@ -12,6 +12,7 @@
#![feature(decl_macro)]
#![feature(nll)]
#![feature(rustc_diagnostic_macros)]
#![feature(unicode_internals)]
#![recursion_limit="256"]

View File

@ -0,0 +1,5 @@
// gate-test-rustc_private
extern crate libc; //~ ERROR use of unstable library feature 'rustc_private'
fn main() {}

View File

@ -0,0 +1,12 @@
error[E0658]: use of unstable library feature 'rustc_private': this crate is being loaded from the sysroot, an unstable location; did you mean to load this crate from crates.io via `Cargo.toml` instead?
--> $DIR/rustc-private.rs:3:1
|
LL | extern crate libc;
| ^^^^^^^^^^^^^^^^^^
|
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
error: aborting due to previous error
For more information about this error, try `rustc --explain E0658`.