2013-02-28 07:15:32 -06:00
|
|
|
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
2012-12-03 18:48:01 -06:00
|
|
|
// 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.
|
|
|
|
|
2013-10-31 17:09:24 -05:00
|
|
|
//! # The Rust standard library
|
|
|
|
//!
|
|
|
|
//! The Rust standard library is a group of interrelated modules defining
|
|
|
|
//! the core language traits, operations on built-in data types, collections,
|
|
|
|
//! platform abstractions, the task scheduler, runtime support for language
|
|
|
|
//! features and other common functionality.
|
|
|
|
//!
|
|
|
|
//! `std` includes modules corresponding to each of the integer types,
|
|
|
|
//! each of the floating point types, the `bool` type, tuples, characters,
|
|
|
|
//! strings (`str`), vectors (`vec`), managed boxes (`managed`), owned
|
|
|
|
//! boxes (`owned`), and unsafe and borrowed pointers (`ptr`, `borrowed`).
|
|
|
|
//! Additionally, `std` provides pervasive types (`option` and `result`),
|
|
|
|
//! task creation and communication primitives (`task`, `comm`), platform
|
2013-11-11 00:46:32 -06:00
|
|
|
//! abstractions (`os` and `path`), basic I/O abstractions (`io`), common
|
2013-10-31 17:09:24 -05:00
|
|
|
//! traits (`kinds`, `ops`, `cmp`, `num`, `to_str`), and complete bindings
|
|
|
|
//! to the C standard library (`libc`).
|
|
|
|
//!
|
|
|
|
//! # Standard library injection and the Rust prelude
|
|
|
|
//!
|
|
|
|
//! `std` is imported at the topmost level of every crate by default, as
|
|
|
|
//! if the first line of each crate was
|
|
|
|
//!
|
|
|
|
//! extern mod std;
|
|
|
|
//!
|
|
|
|
//! This means that the contents of std can be accessed from any context
|
|
|
|
//! with the `std::` path prefix, as in `use std::vec`, `use std::task::spawn`,
|
|
|
|
//! etc.
|
|
|
|
//!
|
|
|
|
//! Additionally, `std` contains a `prelude` module that reexports many of the
|
|
|
|
//! most common types, traits and functions. The contents of the prelude are
|
|
|
|
//! imported into every *module* by default. Implicitly, all modules behave as if
|
|
|
|
//! they contained the following prologue:
|
|
|
|
//!
|
|
|
|
//! use std::prelude::*;
|
2012-11-30 02:47:45 -06:00
|
|
|
|
2014-01-02 12:24:26 -06:00
|
|
|
#[crate_id = "std#0.9"];
|
2013-06-13 20:41:11 -05:00
|
|
|
#[comment = "The Rust standard library"];
|
2013-03-01 10:41:31 -06:00
|
|
|
#[license = "MIT/ASL2"];
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 16:03:29 -06:00
|
|
|
#[crate_type = "rlib"];
|
|
|
|
#[crate_type = "dylib"];
|
2013-09-19 00:18:38 -05:00
|
|
|
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
|
2013-10-02 17:39:32 -05:00
|
|
|
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
|
|
|
html_root_url = "http://static.rust-lang.org/doc/master")];
|
2013-09-19 00:18:38 -05:00
|
|
|
|
2013-11-30 18:38:07 -06:00
|
|
|
#[feature(macro_rules, globs, asm, managed_boxes, thread_local, link_args)];
|
2013-10-02 20:10:16 -05:00
|
|
|
|
2013-05-17 15:12:42 -05:00
|
|
|
// Don't link to std. We are std.
|
|
|
|
#[no_std];
|
2012-04-19 03:00:52 -05:00
|
|
|
|
2012-09-09 16:51:56 -05:00
|
|
|
#[deny(non_camel_case_types)];
|
2013-05-28 16:35:52 -05:00
|
|
|
#[deny(missing_doc)];
|
2012-06-04 20:34:24 -05:00
|
|
|
|
2013-10-22 17:13:18 -05:00
|
|
|
// When testing libstd, bring in libuv as the I/O backend so tests can print
|
2013-11-11 00:46:32 -06:00
|
|
|
// things and all of the std::io tests have an I/O interface to run on top
|
2013-10-22 17:13:18 -05:00
|
|
|
// of
|
2013-12-12 23:38:57 -06:00
|
|
|
#[cfg(test)] extern mod rustuv = "rustuv";
|
|
|
|
#[cfg(test)] extern mod native = "native";
|
|
|
|
#[cfg(test)] extern mod green = "green";
|
2013-10-22 17:13:18 -05:00
|
|
|
|
2013-07-22 11:49:04 -05:00
|
|
|
// Make extra accessible for benchmarking
|
2013-12-12 23:38:57 -06:00
|
|
|
#[cfg(test)] extern mod extra = "extra";
|
2013-07-22 11:49:04 -05:00
|
|
|
|
2013-06-17 01:21:49 -05:00
|
|
|
// Make std testable by not duplicating lang items. See #2912
|
2013-12-12 23:38:57 -06:00
|
|
|
#[cfg(test)] extern mod realstd = "std";
|
2013-05-17 17:28:44 -05:00
|
|
|
#[cfg(test)] pub use kinds = realstd::kinds;
|
|
|
|
#[cfg(test)] pub use ops = realstd::ops;
|
|
|
|
#[cfg(test)] pub use cmp = realstd::cmp;
|
2013-03-26 21:53:33 -05:00
|
|
|
|
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate
and result static rust libraries. This is an implementation of my thoughts in
https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html.
When compiling a library, we still retain the "lib" option, although now there
are "rlib", "staticlib", and "dylib" as options for crate_type (and these are
stackable). The idea of "lib" is to generate the "compiler default" instead of
having too choose (although all are interchangeable). For now I have left the
"complier default" to be a dynamic library for size reasons.
Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an
rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a
dynamic object. I chose this for size reasons, but also because you're probably
not going to be embedding the rustc compiler anywhere any time soon.
Other than the options outlined above, there are a few defaults/preferences that
are now opinionated in the compiler:
* If both a .dylib and .rlib are found for a rust library, the compiler will
prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option
* If generating a "lib", the compiler will generate a dynamic library. This is
overridable by explicitly saying what flavor you'd like (rlib, staticlib,
dylib).
* If no options are passed to the command line, and no crate_type is found in
the destination crate, then an executable is generated
With this change, you can successfully build a rust program with 0 dynamic
dependencies on rust libraries. There is still a dynamic dependency on
librustrt, but I plan on removing that in a subsequent commit.
This change includes no tests just yet. Our current testing
infrastructure/harnesses aren't very amenable to doing flavorful things with
linking, so I'm planning on adding a new mode of testing which I believe belongs
as a separate commit.
Closes #552
2013-11-15 16:03:29 -06:00
|
|
|
mod rtdeps;
|
2013-03-06 21:09:17 -06:00
|
|
|
|
2013-01-08 21:37:25 -06:00
|
|
|
/* The Prelude. */
|
|
|
|
|
|
|
|
pub mod prelude;
|
2011-12-13 18:25:51 -06:00
|
|
|
|
2013-10-31 17:09:24 -05:00
|
|
|
|
2012-11-30 02:47:45 -06:00
|
|
|
/* Primitive types */
|
2012-04-14 19:21:10 -05:00
|
|
|
|
2013-05-12 20:14:40 -05:00
|
|
|
#[path = "num/int_macros.rs"] mod int_macros;
|
|
|
|
#[path = "num/uint_macros.rs"] mod uint_macros;
|
|
|
|
|
|
|
|
#[path = "num/int.rs"] pub mod int;
|
|
|
|
#[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/uint.rs"] pub mod uint;
|
|
|
|
#[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;
|
2012-11-30 02:47:45 -06:00
|
|
|
|
2013-08-10 21:21:31 -05:00
|
|
|
pub mod unit;
|
2012-10-03 21:24:06 -05:00
|
|
|
pub mod bool;
|
2012-11-30 02:47:45 -06:00
|
|
|
pub mod char;
|
2012-10-03 21:24:06 -05:00
|
|
|
pub mod tuple;
|
2012-11-30 02:47:45 -06:00
|
|
|
|
|
|
|
pub mod vec;
|
|
|
|
pub mod at_vec;
|
|
|
|
pub mod str;
|
|
|
|
|
2013-04-22 14:42:25 -05:00
|
|
|
pub mod ascii;
|
2013-09-14 12:37:45 -05:00
|
|
|
pub mod send_str;
|
2013-04-22 14:42:25 -05:00
|
|
|
|
2012-11-30 02:47:45 -06:00
|
|
|
pub mod ptr;
|
2012-10-25 16:44:26 -05:00
|
|
|
pub mod owned;
|
2013-01-11 23:01:42 -06:00
|
|
|
pub mod managed;
|
2013-06-02 18:16:40 -05:00
|
|
|
pub mod borrow;
|
2013-10-10 10:45:52 -05:00
|
|
|
pub mod rc;
|
2013-11-19 22:20:06 -06:00
|
|
|
pub mod gc;
|
2011-12-13 18:25:51 -06:00
|
|
|
|
|
|
|
|
2012-11-30 02:47:45 -06:00
|
|
|
/* Core language traits */
|
|
|
|
|
2013-05-08 06:11:23 -05:00
|
|
|
#[cfg(not(test))] pub mod kinds;
|
|
|
|
#[cfg(not(test))] pub mod ops;
|
|
|
|
#[cfg(not(test))] pub mod cmp;
|
2012-11-30 02:47:45 -06:00
|
|
|
|
|
|
|
|
|
|
|
/* Common traits */
|
|
|
|
|
|
|
|
pub mod from_str;
|
2012-10-03 21:24:06 -05:00
|
|
|
pub mod num;
|
2013-09-08 10:01:16 -05:00
|
|
|
pub mod iter;
|
2012-10-03 21:24:06 -05:00
|
|
|
pub mod to_str;
|
|
|
|
pub mod to_bytes;
|
2012-11-26 18:12:47 -06:00
|
|
|
pub mod clone;
|
2012-11-30 02:47:45 -06:00
|
|
|
pub mod hash;
|
2013-01-20 12:46:06 -06:00
|
|
|
pub mod container;
|
2013-08-10 08:38:00 -05:00
|
|
|
pub mod default;
|
2013-10-11 16:20:34 -05:00
|
|
|
pub mod any;
|
2012-08-01 18:04:43 -05:00
|
|
|
|
2013-10-31 17:09:24 -05:00
|
|
|
|
2012-11-30 02:47:45 -06:00
|
|
|
/* Common data structures */
|
|
|
|
|
|
|
|
pub mod option;
|
|
|
|
pub mod result;
|
2013-01-23 09:25:27 -06:00
|
|
|
pub mod hashmap;
|
2013-02-25 15:23:16 -06:00
|
|
|
pub mod cell;
|
2013-03-02 13:41:31 -06:00
|
|
|
pub mod trie;
|
2012-02-22 06:06:38 -06:00
|
|
|
|
2012-11-30 02:47:45 -06:00
|
|
|
|
|
|
|
/* Tasks and communication */
|
|
|
|
|
2012-11-28 14:33:00 -06:00
|
|
|
pub mod task;
|
2013-02-02 05:10:12 -06:00
|
|
|
pub mod comm;
|
2013-05-08 08:02:21 -05:00
|
|
|
pub mod local_data;
|
2013-12-12 19:27:37 -06:00
|
|
|
pub mod sync;
|
2012-02-22 06:06:38 -06:00
|
|
|
|
2012-11-30 02:47:45 -06:00
|
|
|
|
|
|
|
/* Runtime and platform support */
|
2011-12-13 18:25:51 -06:00
|
|
|
|
2012-10-03 21:24:06 -05:00
|
|
|
pub mod libc;
|
2013-08-03 19:13:14 -05:00
|
|
|
pub mod c_str;
|
2012-10-03 21:24:06 -05:00
|
|
|
pub mod os;
|
2013-11-11 00:46:32 -06:00
|
|
|
pub mod io;
|
2012-10-03 21:24:06 -05:00
|
|
|
pub mod path;
|
|
|
|
pub mod rand;
|
|
|
|
pub mod run;
|
|
|
|
pub mod cast;
|
2013-07-29 03:12:41 -05:00
|
|
|
pub mod fmt;
|
2012-10-03 21:24:06 -05:00
|
|
|
pub mod repr;
|
|
|
|
pub mod cleanup;
|
|
|
|
pub mod reflect;
|
2012-10-17 18:40:18 -05:00
|
|
|
pub mod condition;
|
2012-11-30 02:47:45 -06:00
|
|
|
pub mod logging;
|
|
|
|
pub mod util;
|
2013-10-16 20:34:01 -05:00
|
|
|
pub mod mem;
|
2012-11-30 02:47:45 -06:00
|
|
|
|
2013-10-31 17:09:24 -05:00
|
|
|
|
2012-11-30 02:47:45 -06:00
|
|
|
/* Unsupported interfaces */
|
|
|
|
|
|
|
|
// Private APIs
|
2013-02-27 21:53:31 -06:00
|
|
|
pub mod unstable;
|
2012-11-30 02:47:45 -06:00
|
|
|
|
2013-10-31 17:09:24 -05:00
|
|
|
|
2012-11-30 02:47:45 -06:00
|
|
|
/* For internal use, not exported */
|
|
|
|
|
2013-05-03 16:10:32 -05:00
|
|
|
mod unicode;
|
2013-01-19 15:41:25 -06:00
|
|
|
#[path = "num/cmath.rs"]
|
2013-05-03 16:10:32 -05:00
|
|
|
mod cmath;
|
2013-04-27 20:57:15 -05:00
|
|
|
|
2013-07-12 16:43:57 -05:00
|
|
|
// FIXME #7809: This shouldn't be pub, and it should be reexported under 'unstable'
|
2013-04-27 20:57:15 -05:00
|
|
|
// but name resolution doesn't work without it being pub.
|
|
|
|
pub mod rt;
|
2012-11-30 02:47:45 -06:00
|
|
|
|
2012-11-28 14:33:00 -06:00
|
|
|
// A curious inner-module that's not exported that contains the binding
|
2013-05-17 17:28:44 -05:00
|
|
|
// 'std' so that macro-expanded references to std::error and such
|
|
|
|
// can be resolved within libstd.
|
2013-03-13 21:12:55 -05:00
|
|
|
#[doc(hidden)]
|
2013-05-20 17:20:16 -05:00
|
|
|
mod std {
|
|
|
|
pub use clone;
|
|
|
|
pub use cmp;
|
2013-12-05 19:56:17 -06:00
|
|
|
pub use comm;
|
2013-05-20 17:20:16 -05:00
|
|
|
pub use condition;
|
2013-10-11 16:20:34 -05:00
|
|
|
pub use fmt;
|
2013-12-05 19:56:17 -06:00
|
|
|
pub use io;
|
2013-05-20 17:20:16 -05:00
|
|
|
pub use kinds;
|
2013-07-14 03:43:31 -05:00
|
|
|
pub use local_data;
|
2013-08-28 01:12:05 -05:00
|
|
|
pub use logging;
|
2013-10-11 16:20:34 -05:00
|
|
|
pub use logging;
|
|
|
|
pub use option;
|
2013-05-24 21:35:29 -05:00
|
|
|
pub use os;
|
2013-10-27 14:12:40 -05:00
|
|
|
pub use rt;
|
2013-10-11 16:20:34 -05:00
|
|
|
pub use str;
|
2013-07-29 03:12:41 -05:00
|
|
|
pub use to_bytes;
|
2013-10-11 16:20:34 -05:00
|
|
|
pub use to_str;
|
|
|
|
pub use unstable;
|
2013-05-20 17:20:16 -05:00
|
|
|
}
|