rust/src/libcore/lib.rs

172 lines
4.7 KiB
Rust
Raw Normal View History

2014-04-30 22:05:14 -05:00
// Copyright 2014 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.
2014-05-22 11:44:54 -05:00
//! # The Rust Core Library
2014-05-12 23:22:35 -05:00
//!
2014-05-19 23:53:00 -05:00
//! The Rust Core Library is the dependency-free foundation of [The
//! Rust Standard Library](../std/index.html). It is the portable glue
//! between the language and its libraries, defining the intrinsic and
//! primitive building blocks of all Rust code. It links to no
2014-05-20 13:39:40 -05:00
//! upstream libraries, no system libraries, and no libc.
2014-05-19 23:53:00 -05:00
//!
//! The core library is *minimal*: it isn't even aware of heap allocation,
//! nor does it provide concurrency or I/O. These things require
2014-05-20 13:39:40 -05:00
//! platform integration, and this library is platform-agnostic.
2014-05-19 23:53:00 -05:00
//!
//! *It is not recommended to use the core library*. The stable
//! functionality of libcore is reexported from the
//! [standard library](../std/index.html). The composition of this library is
//! subject to change over time; only the interface exposed through libstd is
//! intended to be stable.
//!
//! # How to use the core library
//!
2014-05-20 12:40:14 -05:00
// FIXME: Fill me in with more detail when the interface settles
2014-05-19 23:53:00 -05:00
//! This library is built on the assumption of a few existing symbols:
2014-05-12 23:22:35 -05:00
//!
//! * `memcpy`, `memcmp`, `memset` - These are core memory routines which are
//! often generated by LLVM. Additionally, this library can make explicit
2014-05-19 10:51:16 -05:00
//! calls to these functions. Their signatures are the same as found in C.
//! These functions are often provided by the system libc, but can also be
//! provided by `librlibc` which is distributed with the standard rust
//! distribution.
2014-05-12 23:22:35 -05:00
//!
//! * `rust_begin_unwind` - This function takes three arguments, a
2015-02-18 16:46:22 -06:00
//! `fmt::Arguments`, a `&str`, and a `usize`. These three arguments dictate
//! the panic message, the file at which panic was invoked, and the line.
//! It is up to consumers of this core library to define this panic
2014-05-12 23:22:35 -05:00
//! function; it is only required to never return.
// Since libcore defines many fundamental lang items, all tests live in a
// separate crate, libcoretest, to avoid bizarre issues.
2014-04-30 22:05:14 -05:00
#![crate_name = "core"]
#![unstable(feature = "core")]
Preliminary feature staging This partially implements the feature staging described in the [release channel RFC][rc]. It does not yet fully conform to the RFC as written, but does accomplish its goals sufficiently for the 1.0 alpha release. It has three primary user-visible effects: * On the nightly channel, use of unstable APIs generates a warning. * On the beta channel, use of unstable APIs generates a warning. * On the beta channel, use of feature gates generates a warning. Code that does not trigger these warnings is considered 'stable', modulo pre-1.0 bugs. Disabling the warnings for unstable APIs continues to be done in the existing (i.e. old) style, via `#[allow(...)]`, not that specified in the RFC. I deem this marginally acceptable since any code that must do this is not using the stable dialect of Rust. Use of feature gates is itself gated with the new 'unstable_features' lint, on nightly set to 'allow', and on beta 'warn'. The attribute scheme used here corresponds to an older version of the RFC, with the `#[staged_api]` crate attribute toggling the staging behavior of the stability attributes, but the user impact is only in-tree so I'm not concerned about having to make design changes later (and I may ultimately prefer the scheme here after all, with the `#[staged_api]` crate attribute). Since the Rust codebase itself makes use of unstable features the compiler and build system to a midly elaborate dance to allow it to bootstrap while disobeying these lints (which would otherwise be errors because Rust builds with `-D warnings`). This patch includes one significant hack that causes a regression. Because the `format_args!` macro emits calls to unstable APIs it would trigger the lint. I added a hack to the lint to make it not trigger, but this in turn causes arguments to `println!` not to be checked for feature gates. I don't presently understand macro expansion well enough to fix. This is bug #20661. Closes #16678 [rc]: https://github.com/rust-lang/rfcs/blob/master/text/0507-release-channels.md
2015-01-06 08:26:08 -06:00
#![staged_api]
2014-04-30 22:05:14 -05:00
#![crate_type = "rlib"]
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
html_root_url = "http://doc.rust-lang.org/nightly/",
html_playground_url = "http://play.rust-lang.org/")]
2014-04-30 22:05:14 -05:00
#![feature(no_std)]
2014-04-30 22:05:14 -05:00
#![no_std]
#![allow(raw_pointer_derive)]
#![deny(missing_docs)]
#![feature(int_uint)]
#![feature(intrinsics, lang_items)]
#![feature(on_unimplemented)]
2015-02-15 07:37:14 -06:00
#![feature(simd, unsafe_destructor)]
#![feature(staged_api)]
#![feature(unboxed_closures)]
2015-02-16 14:16:36 -06:00
#![feature(rustc_attrs)]
#![feature(optin_builtin_traits)]
#![feature(concat_idents)]
#[macro_use]
mod macros;
#[macro_use]
mod cmp_macros;
#[path = "num/float_macros.rs"]
#[macro_use]
mod float_macros;
#[path = "num/int_macros.rs"]
#[macro_use]
mod int_macros;
#[path = "num/uint_macros.rs"]
#[macro_use]
mod uint_macros;
#[path = "num/isize.rs"] pub mod isize;
#[path = "num/i8.rs"] pub mod i8;
#[path = "num/i16.rs"] pub mod i16;
#[path = "num/i32.rs"] pub mod i32;
#[path = "num/i64.rs"] pub mod i64;
#[path = "num/usize.rs"] pub mod usize;
#[path = "num/u8.rs"] pub mod u8;
#[path = "num/u16.rs"] pub mod u16;
#[path = "num/u32.rs"] pub mod u32;
#[path = "num/u64.rs"] pub mod u64;
#[path = "num/f32.rs"] pub mod f32;
#[path = "num/f64.rs"] pub mod f64;
pub mod num;
/* The libcore prelude, not as all-encompassing as the libstd prelude */
pub mod prelude;
2014-04-30 22:04:56 -05:00
/* Core modules for ownership management */
pub mod intrinsics;
2014-04-30 22:13:05 -05:00
pub mod mem;
2014-12-11 21:29:24 -06:00
pub mod nonzero;
2014-04-30 22:17:50 -05:00
pub mod ptr;
2014-04-30 22:22:55 -05:00
/* Core language traits */
2015-01-06 16:33:42 -06:00
pub mod marker;
pub mod ops;
pub mod cmp;
2014-04-30 22:55:38 -05:00
pub mod clone;
2014-04-30 22:46:51 -05:00
pub mod default;
2014-04-30 22:33:08 -05:00
/* Core types and methods on primitives */
2014-04-30 22:36:58 -05:00
pub mod any;
pub mod atomic;
2014-05-01 13:19:56 -05:00
pub mod cell;
pub mod char;
pub mod panicking;
2014-04-30 22:34:41 -05:00
pub mod finally;
2014-04-30 23:41:03 -05:00
pub mod iter;
2014-04-30 23:35:56 -05:00
pub mod option;
2014-04-30 22:38:31 -05:00
pub mod raw;
pub mod result;
pub mod simd;
pub mod slice;
pub mod str;
pub mod hash;
pub mod fmt;
std: Rename Show/String to Debug/Display This commit is an implementation of [RFC 565][rfc] which is a stabilization of the `std::fmt` module and the implementations of various formatting traits. Specifically, the following changes were performed: [rfc]: https://github.com/rust-lang/rfcs/blob/master/text/0565-show-string-guidelines.md * The `Show` trait is now deprecated, it was renamed to `Debug` * The `String` trait is now deprecated, it was renamed to `Display` * Many `Debug` and `Display` implementations were audited in accordance with the RFC and audited implementations now have the `#[stable]` attribute * Integers and floats no longer print a suffix * Smart pointers no longer print details that they are a smart pointer * Paths with `Debug` are now quoted and escape characters * The `unwrap` methods on `Result` now require `Display` instead of `Debug` * The `Error` trait no longer has a `detail` method and now requires that `Display` must be implemented. With the loss of `String`, this has moved into libcore. * `impl<E: Error> FromError<E> for Box<Error>` now exists * `derive(Show)` has been renamed to `derive(Debug)`. This is not currently warned about due to warnings being emitted on stage1+ While backwards compatibility is attempted to be maintained with a blanket implementation of `Display` for the old `String` trait (and the same for `Show`/`Debug`) this is still a breaking change due to primitives no longer implementing `String` as well as modifications such as `unwrap` and the `Error` trait. Most code is fairly straightforward to update with a rename or tweaks of method calls. [breaking-change] Closes #21436
2015-01-20 17:45:07 -06:00
pub mod error;
#[doc(primitive = "bool")]
mod bool {
}
// note: does not need to be public
mod tuple;
mod array;
#[doc(hidden)]
mod core {
pub use panicking;
pub use fmt;
2015-02-17 21:49:22 -06:00
pub use clone;
pub use cmp;
pub use hash;
pub use marker;
pub use option;
pub use iter;
}
#[doc(hidden)]
mod std {
// range syntax
pub use ops;
}