Skip to content

Commit

Permalink
add rustc_private as a proper language feature gate
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
matklad committed Jul 22, 2019
1 parent 83dfe7b commit 27b703d
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/libcore/char/methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand All @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/libfmt_macros/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

#![feature(nll)]
#![feature(rustc_private)]
#![feature(unicode_internals)]

pub use Piece::*;
pub use Position::*;
Expand Down
1 change: 0 additions & 1 deletion src/librustc_lexer/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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))]
#![cfg_attr(not(feature = "unicode-xid"), feature(unicode_internals))]

mod cursor;
Expand Down
1 change: 1 addition & 0 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#![feature(inner_deref)]
#![feature(never_type)]
#![feature(mem_take)]
#![feature(unicode_internals)]

#![recursion_limit="256"]

Expand Down
3 changes: 3 additions & 0 deletions src/libsyntax/feature_gate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),

Expand Down
1 change: 1 addition & 0 deletions src/libsyntax_ext/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#![feature(decl_macro)]
#![feature(nll)]
#![feature(rustc_diagnostic_macros)]
#![feature(unicode_internals)]

#![recursion_limit="256"]

Expand Down
5 changes: 5 additions & 0 deletions src/test/ui/feature-gate/rustc-private.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// gate-test-rustc_private

extern crate libc; //~ ERROR use of unstable library feature 'rustc_private'

fn main() {}
12 changes: 12 additions & 0 deletions src/test/ui/feature-gate/rustc-private.stderr
Original file line number Diff line number Diff line change
@@ -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`.

0 comments on commit 27b703d

Please sign in to comment.