2013-02-28 13:15:32 +00:00
|
|
|
// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT
|
2012-12-04 00:48:01 +00: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.
|
|
|
|
|
2014-11-26 02:17:11 +00:00
|
|
|
//! The Rust compiler.
|
|
|
|
//!
|
|
|
|
//! # Note
|
|
|
|
//!
|
|
|
|
//! This API is completely unstable and subject to change.
|
2014-01-08 05:17:52 +00:00
|
|
|
|
2015-03-05 16:53:51 +00:00
|
|
|
// Do not remove on snapshot creation. Needed for bootstrap. (Issue #22364)
|
|
|
|
#![cfg_attr(stage0, feature(custom_attribute))]
|
2014-07-01 14:12:04 +00:00
|
|
|
#![crate_name = "rustc"]
|
2015-01-23 02:22:03 +00:00
|
|
|
#![unstable(feature = "rustc_private")]
|
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 14:26:08 +00:00
|
|
|
#![staged_api]
|
2014-03-22 01:05:05 +00:00
|
|
|
#![crate_type = "dylib"]
|
|
|
|
#![crate_type = "rlib"]
|
|
|
|
#![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
|
2014-01-08 05:17:52 +00:00
|
|
|
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
2014-10-09 17:47:22 +00:00
|
|
|
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
2011-05-06 02:44:00 +00:00
|
|
|
|
2015-02-10 21:52:44 +00:00
|
|
|
#![feature(box_patterns)]
|
2015-01-07 14:15:34 +00:00
|
|
|
#![feature(box_syntax)]
|
2015-01-23 02:22:03 +00:00
|
|
|
#![feature(collections)]
|
|
|
|
#![feature(core)]
|
2015-01-30 20:26:44 +00:00
|
|
|
#![feature(hash)]
|
|
|
|
#![feature(int_uint)]
|
2015-01-23 02:22:03 +00:00
|
|
|
#![feature(libc)]
|
2015-02-17 19:05:44 +00:00
|
|
|
#![feature(old_path)]
|
2015-01-30 20:26:44 +00:00
|
|
|
#![feature(quote)]
|
|
|
|
#![feature(rustc_diagnostic_macros)]
|
2015-01-23 02:22:03 +00:00
|
|
|
#![feature(rustc_private)]
|
2015-02-15 13:37:14 +00:00
|
|
|
#![feature(unsafe_destructor)]
|
2015-01-30 20:26:44 +00:00
|
|
|
#![feature(staged_api)]
|
2015-01-23 02:22:03 +00:00
|
|
|
#![feature(std_misc)]
|
2015-02-27 05:00:43 +00:00
|
|
|
#![feature(io)]
|
std: Stabilize the `fs` module
This commit performs a stabilization pass over the `std::fs` module now that
it's had some time to bake. The change was largely just adding `#[stable]` tags,
but there are a few APIs that remain `#[unstable]`.
The following apis are now marked `#[stable]`:
* `std::fs` (the name)
* `File`
* `Metadata`
* `ReadDir`
* `DirEntry`
* `OpenOptions`
* `Permissions`
* `File::{open, create}`
* `File::{sync_all, sync_data}`
* `File::set_len`
* `File::metadata`
* Trait implementations for `File` and `&File`
* `OpenOptions::new`
* `OpenOptions::{read, write, append, truncate, create}`
* `OpenOptions::open` - this function was modified, however, to not attempt to
reject cross-platform openings of directories. This means that some platforms
will succeed in opening a directory and others will fail.
* `Metadata::{is_dir, is_file, len, permissions}`
* `Permissions::{readonly, set_readonly}`
* `Iterator for ReadDir`
* `DirEntry::path`
* `remove_file` - like with `OpenOptions::open`, the extra windows code to
remove a readonly file has been removed. This means that removing a readonly
file will succeed on some platforms but fail on others.
* `metadata`
* `rename`
* `copy`
* `hard_link`
* `soft_link`
* `read_link`
* `create_dir`
* `create_dir_all`
* `remove_dir`
* `remove_dir_all`
* `read_dir`
The following apis remain `#[unstable]`.
* `WalkDir` and `walk` - there are many methods by which a directory walk can be
constructed, and it's unclear whether the current semantics are the right
ones. For example symlinks are not handled super well currently. This is now
behind a new `fs_walk` feature.
* `File::path` - this is an extra abstraction which the standard library
provides on top of what the system offers and it's unclear whether we should
be doing so. This is now behind a new `file_path` feature.
* `Metadata::{accessed, modified}` - we do not currently have a good
abstraction for a moment in time which is what these APIs should likely be
returning, so these remain `#[unstable]` for now. These are now behind a new
`fs_time` feature
* `set_file_times` - like with `Metadata::accessed`, we do not currently have
the appropriate abstraction for the arguments here so this API remains
unstable behind the `fs_time` feature gate.
* `PathExt` - the precise set of methods on this trait may change over time and
some methods may be removed. This API remains unstable behind the `path_ext`
feature gate.
* `set_permissions` - we may wish to expose a more granular ability to set the
permissions on a file instead of just a blanket "set all permissions" method.
This function remains behind the `fs` feature.
The following apis are now `#[deprecated]`
* The `TempDir` type is now entirely deprecated and is [located on
crates.io][tempdir] as the `tempdir` crate with [its source][github] at
rust-lang/tempdir.
[tempdir]: https://crates.io/crates/tempdir
[github]: https://github.com/rust-lang/tempdir
The stability of some of these APIs has been questioned over the past few weeks
in using these APIs, and it is intentional that the majority of APIs here are
marked `#[stable]`. The `std::fs` module has a lot of room to grow and the
material is [being tracked in a RFC issue][rfc-issue].
[rfc-issue]: https://github.com/rust-lang/rfcs/issues/939
[breaking-change]
2015-03-04 03:18:29 +00:00
|
|
|
#![feature(path_ext)]
|
2015-03-06 23:11:59 +00:00
|
|
|
#![feature(str_words)]
|
2015-01-24 17:15:42 +00:00
|
|
|
#![cfg_attr(test, feature(test))]
|
2015-03-06 23:11:59 +00:00
|
|
|
|
2014-02-14 18:10:06 +00:00
|
|
|
extern crate arena;
|
2014-05-22 18:28:01 +00:00
|
|
|
extern crate flate;
|
2015-01-10 18:21:27 +00:00
|
|
|
extern crate fmt_macros;
|
2014-05-22 18:28:01 +00:00
|
|
|
extern crate getopts;
|
2014-04-17 19:00:08 +00:00
|
|
|
extern crate graphviz;
|
2014-05-22 18:28:01 +00:00
|
|
|
extern crate libc;
|
2014-09-06 18:54:11 +00:00
|
|
|
extern crate rustc_llvm;
|
|
|
|
extern crate rustc_back;
|
2014-02-14 18:10:06 +00:00
|
|
|
extern crate serialize;
|
2014-07-30 00:06:37 +00:00
|
|
|
extern crate rbml;
|
2014-12-17 15:16:10 +00:00
|
|
|
extern crate collections;
|
2015-01-06 17:24:46 +00:00
|
|
|
#[macro_use] extern crate log;
|
|
|
|
#[macro_use] extern crate syntax;
|
2015-01-16 20:20:03 +00:00
|
|
|
#[macro_use] #[no_link] extern crate rustc_bitflags;
|
2014-07-01 16:39:41 +00:00
|
|
|
|
2014-12-19 06:52:48 +00:00
|
|
|
extern crate "serialize" as rustc_serialize; // used by deriving
|
|
|
|
|
2014-07-29 23:31:39 +00:00
|
|
|
#[cfg(test)]
|
|
|
|
extern crate test;
|
|
|
|
|
2014-09-06 18:54:11 +00:00
|
|
|
pub use rustc_llvm as llvm;
|
|
|
|
|
2015-01-16 23:54:58 +00:00
|
|
|
// NB: This module needs to be declared first so diagnostics are
|
|
|
|
// registered before they are used.
|
|
|
|
pub mod diagnostics;
|
2014-05-25 04:15:16 +00:00
|
|
|
|
2014-07-05 02:41:54 +00:00
|
|
|
pub mod back {
|
|
|
|
pub use rustc_back::abi;
|
2014-07-07 04:50:37 +00:00
|
|
|
pub use rustc_back::archive;
|
2014-07-05 02:41:54 +00:00
|
|
|
pub use rustc_back::arm;
|
|
|
|
pub use rustc_back::mips;
|
|
|
|
pub use rustc_back::mipsel;
|
2014-07-07 01:01:16 +00:00
|
|
|
pub use rustc_back::rpath;
|
2014-07-05 02:41:54 +00:00
|
|
|
pub use rustc_back::svh;
|
|
|
|
pub use rustc_back::target_strs;
|
|
|
|
pub use rustc_back::x86;
|
|
|
|
pub use rustc_back::x86_64;
|
|
|
|
}
|
|
|
|
|
2013-01-29 23:16:07 +00:00
|
|
|
pub mod middle {
|
2014-11-26 09:52:02 +00:00
|
|
|
pub mod astconv_util;
|
2014-07-13 13:12:47 +00:00
|
|
|
pub mod astencode;
|
|
|
|
pub mod cfg;
|
|
|
|
pub mod check_const;
|
2014-09-15 00:21:25 +00:00
|
|
|
pub mod check_static_recursion;
|
2013-01-29 23:16:07 +00:00
|
|
|
pub mod check_loop;
|
|
|
|
pub mod check_match;
|
2014-09-02 03:55:07 +00:00
|
|
|
pub mod check_rvalues;
|
2014-07-13 13:12:47 +00:00
|
|
|
pub mod const_eval;
|
2013-04-17 22:05:17 +00:00
|
|
|
pub mod dataflow;
|
2014-07-13 13:12:47 +00:00
|
|
|
pub mod dead;
|
|
|
|
pub mod def;
|
|
|
|
pub mod dependency_format;
|
|
|
|
pub mod effect;
|
|
|
|
pub mod entry;
|
|
|
|
pub mod expr_use_visitor;
|
2014-11-16 11:33:31 +00:00
|
|
|
pub mod fast_reject;
|
2014-07-13 13:12:47 +00:00
|
|
|
pub mod graph;
|
|
|
|
pub mod intrinsicck;
|
2014-11-25 21:59:02 +00:00
|
|
|
pub mod infer;
|
2013-01-29 23:16:07 +00:00
|
|
|
pub mod lang_items;
|
2014-07-13 13:12:47 +00:00
|
|
|
pub mod liveness;
|
|
|
|
pub mod mem_categorization;
|
|
|
|
pub mod pat_util;
|
2013-01-29 23:16:07 +00:00
|
|
|
pub mod privacy;
|
2013-06-15 01:21:47 +00:00
|
|
|
pub mod reachable;
|
2014-07-13 13:12:47 +00:00
|
|
|
pub mod region;
|
2014-12-02 17:57:38 +00:00
|
|
|
pub mod recursion_limit;
|
2014-07-13 13:12:47 +00:00
|
|
|
pub mod resolve_lifetime;
|
Add stability inheritance
This commit makes several changes to the stability index infrastructure:
* Stability levels are now inherited lexically, i.e., each item's
stability level becomes the default for any nested items.
* The computed stability level for an item is stored as part of the
metadata. When using an item from an external crate, this data is
looked up and cached.
* The stability lint works from the computed stability level, rather
than manual stability attribute annotations. However, the lint still
checks only a limited set of item uses (e.g., it does not check every
component of a path on import). This will be addressed in a later PR,
as part of issue #8962.
* The stability lint only applies to items originating from external
crates, since the stability index is intended as a promise to
downstream crates.
* The "experimental" lint is now _allow_ by default. This is because
almost all existing crates have been marked "experimental", pending
library stabilization. With inheritance in place, this would generate
a massive explosion of warnings for every Rust program.
The lint should be changed back to deny-by-default after library
stabilization is complete.
* The "deprecated" lint still warns by default.
The net result: we can begin tracking stability index for the standard
libraries as we stabilize, without impacting most clients.
Closes #13540.
2014-06-12 00:23:11 +00:00
|
|
|
pub mod stability;
|
2014-07-13 13:12:47 +00:00
|
|
|
pub mod subst;
|
2014-09-12 14:53:35 +00:00
|
|
|
pub mod traits;
|
2014-07-13 13:12:47 +00:00
|
|
|
pub mod ty;
|
|
|
|
pub mod ty_fold;
|
2014-12-26 08:20:01 +00:00
|
|
|
pub mod ty_walk;
|
2014-07-13 13:12:47 +00:00
|
|
|
pub mod weak_lang_items;
|
2011-04-19 23:40:46 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 23:16:07 +00:00
|
|
|
pub mod metadata;
|
2011-06-27 23:38:57 +00:00
|
|
|
|
2014-11-16 01:30:33 +00:00
|
|
|
pub mod session;
|
2010-06-24 04:03:09 +00:00
|
|
|
|
2014-05-26 21:48:54 +00:00
|
|
|
pub mod plugin;
|
2014-05-24 23:16:10 +00:00
|
|
|
|
2014-06-01 22:58:06 +00:00
|
|
|
pub mod lint;
|
|
|
|
|
2013-01-29 23:16:07 +00:00
|
|
|
pub mod util {
|
2014-07-07 05:13:55 +00:00
|
|
|
pub use rustc_back::fs;
|
2014-07-07 05:21:04 +00:00
|
|
|
pub use rustc_back::sha2;
|
2014-07-07 05:13:55 +00:00
|
|
|
|
2013-01-29 23:16:07 +00:00
|
|
|
pub mod common;
|
|
|
|
pub mod ppaux;
|
2014-02-28 22:34:26 +00:00
|
|
|
pub mod nodemap;
|
2014-07-22 11:40:51 +00:00
|
|
|
pub mod snapshot_vec;
|
std: Stabilize the std::str module
This commit starts out by consolidating all `str` extension traits into one
`StrExt` trait to be included in the prelude. This means that
`UnicodeStrPrelude`, `StrPrelude`, and `StrAllocating` have all been merged into
one `StrExt` exported by the standard library. Some functionality is currently
duplicated with the `StrExt` present in libcore.
This commit also currently avoids any methods which require any form of pattern
to operate. These functions will be stabilized via a separate RFC.
Next, stability of methods and structures are as follows:
Stable
* from_utf8_unchecked
* CowString - after moving to std::string
* StrExt::as_bytes
* StrExt::as_ptr
* StrExt::bytes/Bytes - also made a struct instead of a typedef
* StrExt::char_indices/CharIndices - CharOffsets was renamed
* StrExt::chars/Chars
* StrExt::is_empty
* StrExt::len
* StrExt::lines/Lines
* StrExt::lines_any/LinesAny
* StrExt::slice_unchecked
* StrExt::trim
* StrExt::trim_left
* StrExt::trim_right
* StrExt::words/Words - also made a struct instead of a typedef
Unstable
* from_utf8 - the error type was changed to a `Result`, but the error type has
yet to prove itself
* from_c_str - this function will be handled by the c_str RFC
* FromStr - this trait will have an associated error type eventually
* StrExt::escape_default - needs iterators at least, unsure if it should make
the cut
* StrExt::escape_unicode - needs iterators at least, unsure if it should make
the cut
* StrExt::slice_chars - this function has yet to prove itself
* StrExt::slice_shift_char - awaiting conventions about slicing and shifting
* StrExt::graphemes/Graphemes - this functionality may only be in libunicode
* StrExt::grapheme_indices/GraphemeIndices - this functionality may only be in
libunicode
* StrExt::width - this functionality may only be in libunicode
* StrExt::utf16_units - this functionality may only be in libunicode
* StrExt::nfd_chars - this functionality may only be in libunicode
* StrExt::nfkd_chars - this functionality may only be in libunicode
* StrExt::nfc_chars - this functionality may only be in libunicode
* StrExt::nfkc_chars - this functionality may only be in libunicode
* StrExt::is_char_boundary - naming is uncertain with container conventions
* StrExt::char_range_at - naming is uncertain with container conventions
* StrExt::char_range_at_reverse - naming is uncertain with container conventions
* StrExt::char_at - naming is uncertain with container conventions
* StrExt::char_at_reverse - naming is uncertain with container conventions
* StrVector::concat - this functionality may be replaced with iterators, but
it's not certain at this time
* StrVector::connect - as with concat, may be deprecated in favor of iterators
Deprecated
* StrAllocating and UnicodeStrPrelude have been merged into StrExit
* eq_slice - compiler implementation detail
* from_str - use the inherent parse() method
* is_utf8 - call from_utf8 instead
* replace - call the method instead
* truncate_utf16_at_nul - this is an implementation detail of windows and does
not need to be exposed.
* utf8_char_width - moved to libunicode
* utf16_items - moved to libunicode
* is_utf16 - moved to libunicode
* Utf16Items - moved to libunicode
* Utf16Item - moved to libunicode
* Utf16Encoder - moved to libunicode
* AnyLines - renamed to LinesAny and made a struct
* SendStr - use CowString<'static> instead
* str::raw - all functionality is deprecated
* StrExt::into_string - call to_string() instead
* StrExt::repeat - use iterators instead
* StrExt::char_len - use .chars().count() instead
* StrExt::is_alphanumeric - use .chars().all(..)
* StrExt::is_whitespace - use .chars().all(..)
Pending deprecation -- while slicing syntax is being worked out, these methods
are all #[unstable]
* Str - while currently used for generic programming, this trait will be
replaced with one of [], deref coercions, or a generic conversion trait.
* StrExt::slice - use slicing syntax instead
* StrExt::slice_to - use slicing syntax instead
* StrExt::slice_from - use slicing syntax instead
* StrExt::lev_distance - deprecated with no replacement
Awaiting stabilization due to patterns and/or matching
* StrExt::contains
* StrExt::contains_char
* StrExt::split
* StrExt::splitn
* StrExt::split_terminator
* StrExt::rsplitn
* StrExt::match_indices
* StrExt::split_str
* StrExt::starts_with
* StrExt::ends_with
* StrExt::trim_chars
* StrExt::trim_left_chars
* StrExt::trim_right_chars
* StrExt::find
* StrExt::rfind
* StrExt::find_str
* StrExt::subslice_offset
2014-12-10 17:02:31 +00:00
|
|
|
pub mod lev_distance;
|
2010-08-18 18:34:47 +00:00
|
|
|
}
|
|
|
|
|
2013-01-29 23:16:07 +00:00
|
|
|
pub mod lib {
|
2014-07-05 20:24:57 +00:00
|
|
|
pub use llvm;
|
2010-07-13 00:47:40 +00:00
|
|
|
}
|
|
|
|
|
2014-06-04 21:35:58 +00:00
|
|
|
// A private module so that macro-expanded idents like
|
|
|
|
// `::rustc::lint::Lint` will also work in `rustc` itself.
|
|
|
|
//
|
|
|
|
// `libstd` uses the same trick.
|
|
|
|
#[doc(hidden)]
|
|
|
|
mod rustc {
|
|
|
|
pub use lint;
|
|
|
|
}
|