Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

std: Move the bitflags! macro to a gated crate #21254

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions mk/crates.mk
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
TARGET_CRATES := libc std flate arena term \
serialize getopts collections test rand \
log regex graphviz core rbml alloc \
unicode
unicode rustc_bitflags
RUSTC_CRATES := rustc rustc_typeck rustc_borrowck rustc_resolve rustc_driver \
rustc_trans rustc_back rustc_llvm
HOST_CRATES := syntax $(RUSTC_CRATES) rustdoc fmt_macros
Expand All @@ -64,7 +64,8 @@ DEPS_libc := core
DEPS_unicode := core
DEPS_alloc := core libc native:jemalloc
DEPS_std := core libc rand alloc collections unicode \
native:rust_builtin native:backtrace native:rustrt_native
native:rust_builtin native:backtrace native:rustrt_native \
rustc_bitflags
DEPS_graphviz := std
DEPS_syntax := std term serialize log fmt_macros arena libc
DEPS_rustc_driver := arena flate getopts graphviz libc rustc rustc_back rustc_borrowck \
Expand All @@ -80,6 +81,7 @@ DEPS_rustc_llvm := native:rustllvm libc std
DEPS_rustc_back := std syntax rustc_llvm flate log libc
DEPS_rustdoc := rustc rustc_driver native:hoedown serialize getopts \
test
DEPS_rustc_bitflags := core
DEPS_flate := std native:miniz
DEPS_arena := std
DEPS_graphviz := std
Expand Down Expand Up @@ -111,6 +113,7 @@ ONLY_RLIB_alloc := 1
ONLY_RLIB_rand := 1
ONLY_RLIB_collections := 1
ONLY_RLIB_unicode := 1
ONLY_RLIB_rustc_bitflags := 1

################################################################################
# You should not need to edit below this line
Expand Down
1 change: 1 addition & 0 deletions src/librustc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ extern crate rbml;
extern crate collections;
#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
#[macro_use] #[no_link] extern crate rustc_bitflags;

extern crate "serialize" as rustc_serialize; // used by deriving

Expand Down
14 changes: 12 additions & 2 deletions src/libstd/bitflags.rs → src/librustc_bitflags/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,16 @@
// option. This file may not be copied, modified, or distributed
// except according to those terms.

#![crate_name = "rustc_bitflags"]
#![unstable]
#![staged_api]
#![crate_type = "rlib"]
#![no_std]

//! A typesafe bitmask flag generator.

#[cfg(test)] #[macro_use] extern crate std;

/// The `bitflags!` macro generates a `struct` that holds a set of C-style
/// bitmask flags. It is useful for creating typesafe wrappers for C APIs.
///
Expand All @@ -21,6 +27,8 @@
/// # Example
///
/// ```{.rust}
/// #[macro_use] extern crate rustc_bitflags;
///
/// bitflags! {
/// flags Flags: u32 {
/// const FLAG_A = 0b00000001,
Expand All @@ -45,6 +53,8 @@
/// The generated `struct`s can also be extended with type and trait implementations:
///
/// ```{.rust}
/// #[macro_use] extern crate rustc_bitflags;
///
/// use std::fmt;
///
/// bitflags! {
Expand Down Expand Up @@ -273,8 +283,8 @@ macro_rules! bitflags {
#[cfg(test)]
#[allow(non_upper_case_globals)]
mod tests {
use hash::{self, SipHasher};
use option::Option::{Some, None};
use std::hash::{self, SipHasher};
use std::option::Option::{Some, None};

bitflags! {
#[doc = "> The first principle is that you must not fool yourself — and"]
Expand Down
1 change: 1 addition & 0 deletions src/librustc_llvm/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#![allow(unknown_features)] #![feature(int_uint)]

extern crate libc;
#[macro_use] #[no_link] extern crate rustc_bitflags;

pub use self::OtherAttribute::*;
pub use self::SpecialAttribute::*;
Expand Down
1 change: 1 addition & 0 deletions src/librustc_resolve/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

#[macro_use] extern crate log;
#[macro_use] extern crate syntax;
#[macro_use] #[no_link] extern crate rustc_bitflags;

extern crate rustc;

Expand Down
7 changes: 3 additions & 4 deletions src/libstd/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
#![feature(box_syntax)]
#![feature(old_impl_check)]
#![feature(optin_builtin_traits)]
#![allow(unknown_features)] #![feature(int_uint)]
#![feature(int_uint)]

// Don't link to std. We are std.
#![no_std]
Expand All @@ -136,6 +136,8 @@ extern crate alloc;
extern crate unicode;
extern crate libc;

#[macro_use] #[no_link] extern crate rustc_bitflags;

// Make std testable by not duplicating lang items. See #2912
#[cfg(test)] extern crate "std" as realstd;
#[cfg(test)] pub use realstd::marker;
Expand Down Expand Up @@ -181,9 +183,6 @@ pub use unicode::char;
#[macro_use]
mod macros;

#[macro_use]
pub mod bitflags;

mod rtdeps;

/* The Prelude. */
Expand Down
1 change: 1 addition & 0 deletions src/libsyntax/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ extern crate serialize;
extern crate term;
extern crate libc;
#[macro_use] extern crate log;
#[macro_use] #[no_link] extern crate rustc_bitflags;

extern crate "serialize" as rustc_serialize; // used by deriving

Expand Down