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.
|
|
|
|
|
2014-11-25 20:17:11 -06:00
|
|
|
//! The Rust compiler.
|
|
|
|
//!
|
|
|
|
//! # Note
|
|
|
|
//!
|
|
|
|
//! This API is completely unstable and subject to change.
|
2014-01-07 23:17:52 -06:00
|
|
|
|
2014-07-01 09:12:04 -05:00
|
|
|
#![crate_name = "rustc"]
|
2014-06-18 00:13:36 -05:00
|
|
|
#![experimental]
|
2014-03-21 20:05:05 -05: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-07 23:17:52 -06:00
|
|
|
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
|
2014-10-09 12:47:22 -05:00
|
|
|
html_root_url = "http://doc.rust-lang.org/nightly/")]
|
2011-05-05 21:44:00 -05:00
|
|
|
|
Fix orphan checking (cc #19470). (This is not a complete fix of #19470 because of the backwards compatibility feature gate.)
This is a [breaking-change]. The new rules require that, for an impl of a trait defined
in some other crate, two conditions must hold:
1. Some type must be local.
2. Every type parameter must appear "under" some local type.
Here are some examples that are legal:
```rust
struct MyStruct<T> { ... }
// Here `T` appears "under' `MyStruct`.
impl<T> Clone for MyStruct<T> { }
// Here `T` appears "under' `MyStruct` as well. Note that it also appears
// elsewhere.
impl<T> Iterator<T> for MyStruct<T> { }
```
Here is an illegal example:
```rust
// Here `U` does not appear "under" `MyStruct` or any other local type.
// We call `U` "uncovered".
impl<T,U> Iterator<U> for MyStruct<T> { }
```
There are a couple of ways to rewrite this last example so that it is
legal:
1. In some cases, the uncovered type parameter (here, `U`) should be converted
into an associated type. This is however a non-local change that requires access
to the original trait. Also, associated types are not fully baked.
2. Add `U` as a type parameter of `MyStruct`:
```rust
struct MyStruct<T,U> { ... }
impl<T,U> Iterator<U> for MyStruct<T,U> { }
```
3. Create a newtype wrapper for `U`
```rust
impl<T,U> Iterator<Wrapper<U>> for MyStruct<T,U> { }
```
Because associated types are not fully baked, which in the case of the
`Hash` trait makes adhering to this rule impossible, you can
temporarily disable this rule in your crate by using
`#![feature(old_orphan_check)]`. Note that the `old_orphan_check`
feature will be removed before 1.0 is released.
2014-12-26 02:30:51 -06:00
|
|
|
#![allow(unknown_features)]
|
2014-12-03 17:58:26 -06:00
|
|
|
#![feature(default_type_params, globs, macro_rules, phase, quote)]
|
2014-12-09 16:08:10 -06:00
|
|
|
#![feature(slicing_syntax, unsafe_destructor)]
|
2014-07-01 11:39:41 -05:00
|
|
|
#![feature(rustc_diagnostic_macros)]
|
2014-12-02 13:56:00 -06:00
|
|
|
#![feature(unboxed_closures)]
|
Fix orphan checking (cc #19470). (This is not a complete fix of #19470 because of the backwards compatibility feature gate.)
This is a [breaking-change]. The new rules require that, for an impl of a trait defined
in some other crate, two conditions must hold:
1. Some type must be local.
2. Every type parameter must appear "under" some local type.
Here are some examples that are legal:
```rust
struct MyStruct<T> { ... }
// Here `T` appears "under' `MyStruct`.
impl<T> Clone for MyStruct<T> { }
// Here `T` appears "under' `MyStruct` as well. Note that it also appears
// elsewhere.
impl<T> Iterator<T> for MyStruct<T> { }
```
Here is an illegal example:
```rust
// Here `U` does not appear "under" `MyStruct` or any other local type.
// We call `U` "uncovered".
impl<T,U> Iterator<U> for MyStruct<T> { }
```
There are a couple of ways to rewrite this last example so that it is
legal:
1. In some cases, the uncovered type parameter (here, `U`) should be converted
into an associated type. This is however a non-local change that requires access
to the original trait. Also, associated types are not fully baked.
2. Add `U` as a type parameter of `MyStruct`:
```rust
struct MyStruct<T,U> { ... }
impl<T,U> Iterator<U> for MyStruct<T,U> { }
```
3. Create a newtype wrapper for `U`
```rust
impl<T,U> Iterator<Wrapper<U>> for MyStruct<T,U> { }
```
Because associated types are not fully baked, which in the case of the
`Hash` trait makes adhering to this rule impossible, you can
temporarily disable this rule in your crate by using
`#![feature(old_orphan_check)]`. Note that the `old_orphan_check`
feature will be removed before 1.0 is released.
2014-12-26 02:30:51 -06:00
|
|
|
#![feature(old_orphan_check)]
|
2015-01-01 22:26:38 -06:00
|
|
|
#![feature(associated_types)]
|
2014-07-01 11:39:41 -05:00
|
|
|
|
2014-02-14 12:10:06 -06:00
|
|
|
extern crate arena;
|
2014-05-22 13:28:01 -05:00
|
|
|
extern crate flate;
|
|
|
|
extern crate getopts;
|
2014-04-17 14:00:08 -05:00
|
|
|
extern crate graphviz;
|
2014-05-22 13:28:01 -05:00
|
|
|
extern crate libc;
|
2014-09-06 13:54:11 -05:00
|
|
|
extern crate rustc_llvm;
|
|
|
|
extern crate rustc_back;
|
2014-02-14 12:10:06 -06:00
|
|
|
extern crate serialize;
|
2014-07-29 19:06:37 -05:00
|
|
|
extern crate rbml;
|
2014-12-17 09:16:10 -06:00
|
|
|
extern crate collections;
|
2014-06-11 20:47:09 -05:00
|
|
|
#[phase(plugin, link)] extern crate log;
|
2014-07-01 11:39:41 -05:00
|
|
|
#[phase(plugin, link)] extern crate syntax;
|
|
|
|
|
2014-12-19 00:52:48 -06:00
|
|
|
extern crate "serialize" as rustc_serialize; // used by deriving
|
|
|
|
|
2014-07-29 18:31:39 -05:00
|
|
|
#[cfg(test)]
|
|
|
|
extern crate test;
|
|
|
|
|
2014-09-06 13:54:11 -05:00
|
|
|
pub use rustc_llvm as llvm;
|
|
|
|
|
2014-07-01 11:39:41 -05:00
|
|
|
mod diagnostics;
|
2014-05-24 23:15:16 -05:00
|
|
|
|
2014-07-04 21:41:54 -05:00
|
|
|
pub mod back {
|
|
|
|
pub use rustc_back::abi;
|
2014-07-06 23:50:37 -05:00
|
|
|
pub use rustc_back::archive;
|
2014-07-04 21:41:54 -05:00
|
|
|
pub use rustc_back::arm;
|
|
|
|
pub use rustc_back::mips;
|
|
|
|
pub use rustc_back::mipsel;
|
2014-07-06 20:01:16 -05:00
|
|
|
pub use rustc_back::rpath;
|
2014-07-04 21:41:54 -05: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 17:16:07 -06:00
|
|
|
pub mod middle {
|
2014-11-26 03:52:02 -06:00
|
|
|
pub mod astconv_util;
|
2014-07-13 08:12:47 -05:00
|
|
|
pub mod astencode;
|
|
|
|
pub mod cfg;
|
|
|
|
pub mod check_const;
|
2014-09-14 19:21:25 -05:00
|
|
|
pub mod check_static_recursion;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod check_loop;
|
|
|
|
pub mod check_match;
|
2014-09-01 22:55:07 -05:00
|
|
|
pub mod check_rvalues;
|
2014-02-26 12:22:41 -06:00
|
|
|
pub mod check_static;
|
2014-07-13 08:12:47 -05:00
|
|
|
pub mod const_eval;
|
2013-04-17 17:05:17 -05:00
|
|
|
pub mod dataflow;
|
2014-07-13 08:12:47 -05: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 05:33:31 -06:00
|
|
|
pub mod fast_reject;
|
2014-07-13 08:12:47 -05:00
|
|
|
pub mod graph;
|
|
|
|
pub mod intrinsicck;
|
2014-11-25 15:59:02 -06:00
|
|
|
pub mod infer;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod lang_items;
|
2014-07-13 08:12:47 -05:00
|
|
|
pub mod liveness;
|
|
|
|
pub mod mem_categorization;
|
|
|
|
pub mod pat_util;
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod privacy;
|
2013-06-14 20:21:47 -05:00
|
|
|
pub mod reachable;
|
2014-07-13 08:12:47 -05:00
|
|
|
pub mod region;
|
2014-12-02 11:57:38 -06:00
|
|
|
pub mod recursion_limit;
|
2014-07-13 08:12:47 -05: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-11 19:23:11 -05:00
|
|
|
pub mod stability;
|
2014-07-13 08:12:47 -05:00
|
|
|
pub mod subst;
|
2014-09-12 09:53:35 -05:00
|
|
|
pub mod traits;
|
2014-07-13 08:12:47 -05:00
|
|
|
pub mod ty;
|
|
|
|
pub mod ty_fold;
|
2014-12-26 02:20:01 -06:00
|
|
|
pub mod ty_walk;
|
2014-07-13 08:12:47 -05:00
|
|
|
pub mod weak_lang_items;
|
2011-04-19 18:40:46 -05:00
|
|
|
}
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod metadata;
|
2011-06-27 18:38:57 -05:00
|
|
|
|
2014-11-15 19:30:33 -06:00
|
|
|
pub mod session;
|
2010-06-23 23:03:09 -05:00
|
|
|
|
2014-05-26 16:48:54 -05:00
|
|
|
pub mod plugin;
|
2014-05-24 18:16:10 -05:00
|
|
|
|
2014-06-01 17:58:06 -05:00
|
|
|
pub mod lint;
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod util {
|
2014-07-07 00:13:55 -05:00
|
|
|
pub use rustc_back::fs;
|
2014-07-07 00:21:04 -05:00
|
|
|
pub use rustc_back::sha2;
|
2014-07-07 00:13:55 -05:00
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod common;
|
|
|
|
pub mod ppaux;
|
2014-02-28 16:34:26 -06:00
|
|
|
pub mod nodemap;
|
2014-07-22 06:40:51 -05: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 11:02:31 -06:00
|
|
|
pub mod lev_distance;
|
2010-08-18 13:34:47 -05:00
|
|
|
}
|
|
|
|
|
2013-01-29 17:16:07 -06:00
|
|
|
pub mod lib {
|
2014-07-05 15:24:57 -05:00
|
|
|
pub use llvm;
|
2010-07-12 19:47:40 -05:00
|
|
|
}
|
|
|
|
|
2014-11-14 11:18:10 -06:00
|
|
|
__build_diagnostic_array! { DIAGNOSTICS }
|
2014-07-01 11:39:41 -05:00
|
|
|
|
2014-06-04 16:35:58 -05: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;
|
|
|
|
}
|