Skip to content

Commit 27b703d

Browse files
committed
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.
1 parent 83dfe7b commit 27b703d

File tree

8 files changed

+35
-8
lines changed

8 files changed

+35
-8
lines changed

src/libcore/char/methods.rs

+12-7
Original file line numberDiff line numberDiff line change
@@ -553,10 +553,12 @@ impl char {
553553
/// 'XID_Start' is a Unicode Derived Property specified in
554554
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
555555
/// mostly similar to `ID_Start` but modified for closure under `NFKx`.
556-
#[unstable(feature = "rustc_private",
557-
reason = "mainly needed for compiler internals",
558-
issue = "27812")]
559-
#[inline]
556+
#[cfg_attr(bootstrap,
557+
unstable(feature = "rustc_private",
558+
reason = "mainly needed for compiler internals",
559+
issue = "27812"))]
560+
#[cfg_attr(not(bootstrap),
561+
unstable(feature = "unicode_internals", issue = "0"))]
560562
pub fn is_xid_start(self) -> bool {
561563
derived_property::XID_Start(self)
562564
}
@@ -567,9 +569,12 @@ impl char {
567569
/// 'XID_Continue' is a Unicode Derived Property specified in
568570
/// [UAX #31](http://unicode.org/reports/tr31/#NFKC_Modifications),
569571
/// mostly similar to 'ID_Continue' but modified for closure under NFKx.
570-
#[unstable(feature = "rustc_private",
571-
reason = "mainly needed for compiler internals",
572-
issue = "27812")]
572+
#[cfg_attr(bootstrap,
573+
unstable(feature = "rustc_private",
574+
reason = "mainly needed for compiler internals",
575+
issue = "27812"))]
576+
#[cfg_attr(not(bootstrap),
577+
unstable(feature = "unicode_internals", issue = "0"))]
573578
#[inline]
574579
pub fn is_xid_continue(self) -> bool {
575580
derived_property::XID_Continue(self)

src/libfmt_macros/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#![feature(nll)]
1515
#![feature(rustc_private)]
16+
#![feature(unicode_internals)]
1617

1718
pub use Piece::*;
1819
pub use Position::*;

src/librustc_lexer/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// We want to be able to build this crate with a stable compiler, so feature
22
// flags should optional.
3-
#![cfg_attr(not(feature = "unicode-xid"), feature(rustc_private))]
43
#![cfg_attr(not(feature = "unicode-xid"), feature(unicode_internals))]
54

65
mod cursor;

src/librustdoc/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#![feature(inner_deref)]
2222
#![feature(never_type)]
2323
#![feature(mem_take)]
24+
#![feature(unicode_internals)]
2425

2526
#![recursion_limit="256"]
2627

src/libsyntax/feature_gate.rs

+3
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ declare_features! (
126126

127127
// no-tracking-issue-start
128128

129+
// Allows using compiler's own crates.
130+
(active, rustc_private, "1.0.0", Some(27812), None),
131+
129132
// Allows using the `rust-intrinsic`'s "ABI".
130133
(active, intrinsics, "1.0.0", None, None),
131134

src/libsyntax_ext/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#![feature(decl_macro)]
1313
#![feature(nll)]
1414
#![feature(rustc_diagnostic_macros)]
15+
#![feature(unicode_internals)]
1516

1617
#![recursion_limit="256"]
1718

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// gate-test-rustc_private
2+
3+
extern crate libc; //~ ERROR use of unstable library feature 'rustc_private'
4+
5+
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
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?
2+
--> $DIR/rustc-private.rs:3:1
3+
|
4+
LL | extern crate libc;
5+
| ^^^^^^^^^^^^^^^^^^
6+
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/27812
8+
= help: add `#![feature(rustc_private)]` to the crate attributes to enable
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0658`.

0 commit comments

Comments
 (0)